diff --git a/nukebuild/RefAssemblyGenerator.cs b/nukebuild/RefAssemblyGenerator.cs index dc96849fe74..54e428c4427 100644 --- a/nukebuild/RefAssemblyGenerator.cs +++ b/nukebuild/RefAssemblyGenerator.cs @@ -123,6 +123,16 @@ static void ProcessType(TypeDefinition type, MethodReference obsoleteCtor) } } + foreach (var cl in type.NestedTypes) + { + ProcessType(cl, obsoleteCtor); + if (hideMembers) + { + var dflags = TypeAttributes.Public; + cl.Attributes = ((cl.Attributes | dflags) ^ dflags) | TypeAttributes.NotPublic; + } + } + foreach (var m in type.Properties) MarkAsUnstable(m, obsoleteCtor, forceUnstable); foreach (var m in type.Events) diff --git a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj index 877d475fb66..37719b77d81 100644 --- a/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj +++ b/samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj @@ -16,6 +16,7 @@ + diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs index 47297a4f768..3fb78591bcb 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs @@ -10,7 +10,7 @@ namespace Avalonia.Android { - internal abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, IPlatformNativeSurfaceHandle + internal abstract class InvalidationAwareSurfaceView : SurfaceView, ISurfaceHolderCallback, INativePlatformHandleSurface { bool _invalidateQueued; readonly object _lock = new object(); diff --git a/src/Avalonia.Base/AvaloniaLocator.cs b/src/Avalonia.Base/AvaloniaLocator.cs index 8ec245507bb..1fd266cca35 100644 --- a/src/Avalonia.Base/AvaloniaLocator.cs +++ b/src/Avalonia.Base/AvaloniaLocator.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using Avalonia.Metadata; #pragma warning disable CS1591 // Enable me later namespace Avalonia { + [PrivateApi] public class AvaloniaLocator : IAvaloniaDependencyResolver { private readonly IAvaloniaDependencyResolver? _parentScope; @@ -114,11 +116,13 @@ public static IDisposable EnterScope() } } + [PrivateApi] public interface IAvaloniaDependencyResolver { object? GetService(Type t); } + [PrivateApi] public static class LocatorExtensions { public static T? GetService(this IAvaloniaDependencyResolver resolver) diff --git a/src/Avalonia.Base/Input/DragDropDevice.cs b/src/Avalonia.Base/Input/DragDropDevice.cs index 04d46933521..5ad20111fcc 100644 --- a/src/Avalonia.Base/Input/DragDropDevice.cs +++ b/src/Avalonia.Base/Input/DragDropDevice.cs @@ -2,9 +2,11 @@ using Avalonia.VisualTree; using System.Linq; using Avalonia.Input.Raw; +using Avalonia.Metadata; namespace Avalonia.Input { + [PrivateApi] public class DragDropDevice : IDragDropDevice { public static readonly DragDropDevice Instance = new DragDropDevice(); diff --git a/src/Avalonia.Base/Input/IInputDevice.cs b/src/Avalonia.Base/Input/IInputDevice.cs index fe4f584f186..658b87c6b28 100644 --- a/src/Avalonia.Base/Input/IInputDevice.cs +++ b/src/Avalonia.Base/Input/IInputDevice.cs @@ -3,7 +3,7 @@ namespace Avalonia.Input { - [NotClientImplementable] + [NotClientImplementable, PrivateApi] public interface IInputDevice { /// diff --git a/src/Avalonia.Base/Input/IInputManager.cs b/src/Avalonia.Base/Input/IInputManager.cs index 658226a519c..fc18799e7a5 100644 --- a/src/Avalonia.Base/Input/IInputManager.cs +++ b/src/Avalonia.Base/Input/IInputManager.cs @@ -8,7 +8,7 @@ namespace Avalonia.Input /// Receives input from the windowing subsystem and dispatches it to interested parties /// for processing. /// - [NotClientImplementable] + [NotClientImplementable, PrivateApi] public interface IInputManager { /// diff --git a/src/Avalonia.Base/Input/IKeyboardNavigationHandler.cs b/src/Avalonia.Base/Input/IKeyboardNavigationHandler.cs index 3bcd6d62069..6ab0031f317 100644 --- a/src/Avalonia.Base/Input/IKeyboardNavigationHandler.cs +++ b/src/Avalonia.Base/Input/IKeyboardNavigationHandler.cs @@ -15,6 +15,7 @@ public interface IKeyboardNavigationHandler /// /// This method can only be called once, typically by the owner itself on creation. /// + [PrivateApi] void SetOwner(IInputRoot owner); /// diff --git a/src/Avalonia.Base/Input/InputManager.cs b/src/Avalonia.Base/Input/InputManager.cs index e87665fd540..c9b1751b2a6 100644 --- a/src/Avalonia.Base/Input/InputManager.cs +++ b/src/Avalonia.Base/Input/InputManager.cs @@ -8,7 +8,7 @@ namespace Avalonia.Input /// Receives input from the windowing subsystem and dispatches it to interested parties /// for processing. /// - public class InputManager : IInputManager + internal class InputManager : IInputManager { private readonly LightweightSubject _preProcess = new(); private readonly LightweightSubject _process = new(); diff --git a/src/Avalonia.Base/Input/KeyboardNavigationHandler.cs b/src/Avalonia.Base/Input/KeyboardNavigationHandler.cs index 7a83501ce44..d979acbdf43 100644 --- a/src/Avalonia.Base/Input/KeyboardNavigationHandler.cs +++ b/src/Avalonia.Base/Input/KeyboardNavigationHandler.cs @@ -10,7 +10,7 @@ namespace Avalonia.Input /// Handles keyboard navigation for a window. /// [Unstable] - public class KeyboardNavigationHandler : IKeyboardNavigationHandler + public sealed class KeyboardNavigationHandler : IKeyboardNavigationHandler { /// /// The window to which the handler belongs. @@ -24,6 +24,7 @@ public class KeyboardNavigationHandler : IKeyboardNavigationHandler /// /// This method can only be called once, typically by the owner itself on creation. /// + [PrivateApi] public void SetOwner(IInputRoot owner) { if (_owner != null) @@ -102,7 +103,7 @@ public void Move( /// /// The event sender. /// The event args. - protected virtual void OnKeyDown(object? sender, KeyEventArgs e) + void OnKeyDown(object? sender, KeyEventArgs e) { if (e.Key == Key.Tab) { diff --git a/src/Avalonia.Base/Input/Raw/RawDragEvent.cs b/src/Avalonia.Base/Input/Raw/RawDragEvent.cs index c903aad6843..8ade3d8af5e 100644 --- a/src/Avalonia.Base/Input/Raw/RawDragEvent.cs +++ b/src/Avalonia.Base/Input/Raw/RawDragEvent.cs @@ -1,7 +1,9 @@ using System; +using Avalonia.Metadata; namespace Avalonia.Input.Raw { + [PrivateApi] public class RawDragEvent : RawInputEventArgs { public Point Location { get; set; } diff --git a/src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs index cf4d37b6dab..fa1953de50e 100644 --- a/src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawInputEventArgs.cs @@ -1,4 +1,5 @@ using System; +using Avalonia.Metadata; namespace Avalonia.Input.Raw { @@ -11,6 +12,7 @@ namespace Avalonia.Input.Raw /// pre-processing they are consumed by the relevant and turned into /// standard Avalonia events. /// + [PrivateApi] public class RawInputEventArgs : EventArgs { /// diff --git a/src/Avalonia.Base/Input/Raw/RawKeyEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawKeyEventArgs.cs index 6ed073d006d..b80d09e420c 100644 --- a/src/Avalonia.Base/Input/Raw/RawKeyEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawKeyEventArgs.cs @@ -1,3 +1,5 @@ +using Avalonia.Metadata; + namespace Avalonia.Input.Raw { public enum RawKeyEventType @@ -6,6 +8,7 @@ public enum RawKeyEventType KeyUp } + [PrivateApi] public class RawKeyEventArgs : RawInputEventArgs { public RawKeyEventArgs( diff --git a/src/Avalonia.Base/Input/Raw/RawMouseWheelEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawMouseWheelEventArgs.cs index a7522759807..e370ca37087 100644 --- a/src/Avalonia.Base/Input/Raw/RawMouseWheelEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawMouseWheelEventArgs.cs @@ -1,6 +1,9 @@ +using Avalonia.Metadata; + namespace Avalonia.Input.Raw { + [PrivateApi] public class RawMouseWheelEventArgs : RawPointerEventArgs { public RawMouseWheelEventArgs( diff --git a/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs index ebedc9e6e81..595f4c0c661 100644 --- a/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawPointerEventArgs.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Avalonia.Metadata; namespace Avalonia.Input.Raw { @@ -31,6 +32,7 @@ public enum RawPointerEventType /// /// A raw mouse event. /// + [PrivateApi] public class RawPointerEventArgs : RawInputEventArgs { private RawPointerPoint _point; @@ -124,6 +126,7 @@ public Point Position internal IInputElement? InputHitTestResult { get; set; } } + [PrivateApi] public record struct RawPointerPoint { /// diff --git a/src/Avalonia.Base/Input/Raw/RawPointerGestureEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawPointerGestureEventArgs.cs index 5a6dbda9a7e..379ca65ea85 100644 --- a/src/Avalonia.Base/Input/Raw/RawPointerGestureEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawPointerGestureEventArgs.cs @@ -1,5 +1,8 @@ +using Avalonia.Metadata; + namespace Avalonia.Input.Raw { + [PrivateApi] public class RawPointerGestureEventArgs : RawPointerEventArgs { public RawPointerGestureEventArgs( diff --git a/src/Avalonia.Base/Input/Raw/RawSizeEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawSizeEventArgs.cs index b6a364eab90..a0eb5934eb4 100644 --- a/src/Avalonia.Base/Input/Raw/RawSizeEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawSizeEventArgs.cs @@ -1,7 +1,9 @@ using System; +using Avalonia.Metadata; namespace Avalonia.Input.Raw { + [PrivateApi] public class RawSizeEventArgs : EventArgs { public RawSizeEventArgs(Size size) diff --git a/src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs index cd1cf29bcfb..3ecbf24bdd0 100644 --- a/src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawTextInputEventArgs.cs @@ -1,5 +1,8 @@ +using Avalonia.Metadata; + namespace Avalonia.Input.Raw { + [PrivateApi] public class RawTextInputEventArgs : RawInputEventArgs { public RawTextInputEventArgs( diff --git a/src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs b/src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs index 3e842e6e3ff..7adab89d2e0 100644 --- a/src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs +++ b/src/Avalonia.Base/Input/Raw/RawTouchEventArgs.cs @@ -1,7 +1,9 @@ using System; +using Avalonia.Metadata; namespace Avalonia.Input.Raw { + [PrivateApi] public class RawTouchEventArgs : RawPointerEventArgs { public RawTouchEventArgs(IInputDevice device, ulong timestamp, IInputRoot root, diff --git a/src/Avalonia.Base/Media/Brush.cs b/src/Avalonia.Base/Media/Brush.cs index 3c888d13cf1..986e3221e6a 100644 --- a/src/Avalonia.Base/Media/Brush.cs +++ b/src/Avalonia.Base/Media/Brush.cs @@ -118,7 +118,7 @@ void ICompositionRenderResource.AddRefOnCompositor(Compositor c) OnReferencedFromCompositor(c); } - protected virtual void OnReferencedFromCompositor(Compositor c) + private protected virtual void OnReferencedFromCompositor(Compositor c) { if (Transform is ICompositionRenderResource resource) resource.AddRefOnCompositor(c); diff --git a/src/Avalonia.Base/Media/DrawingBrush.cs b/src/Avalonia.Base/Media/DrawingBrush.cs index f324c025364..b710351b989 100644 --- a/src/Avalonia.Base/Media/DrawingBrush.cs +++ b/src/Avalonia.Base/Media/DrawingBrush.cs @@ -60,7 +60,7 @@ public Drawing? Drawing private InlineDictionary _renderDataDictionary; - protected override void OnReferencedFromCompositor(Compositor c) + private protected override void OnReferencedFromCompositor(Compositor c) { _renderDataDictionary.Add(c, CreateServerContent(c)); base.OnReferencedFromCompositor(c); diff --git a/src/Avalonia.Base/Media/VisualBrush.cs b/src/Avalonia.Base/Media/VisualBrush.cs index 2b604d684fa..15d4f39d6c2 100644 --- a/src/Avalonia.Base/Media/VisualBrush.cs +++ b/src/Avalonia.Base/Media/VisualBrush.cs @@ -64,7 +64,7 @@ public Visual? Visual private InlineDictionary _renderDataDictionary; - protected override void OnReferencedFromCompositor(Compositor c) + private protected override void OnReferencedFromCompositor(Compositor c) { _renderDataDictionary.Add(c, CreateServerContent(c)); base.OnReferencedFromCompositor(c); diff --git a/src/Avalonia.Base/Metadata/PrivateApiAttribute.cs b/src/Avalonia.Base/Metadata/PrivateApiAttribute.cs index 70f24f815aa..8246d4a18d9 100644 --- a/src/Avalonia.Base/Metadata/PrivateApiAttribute.cs +++ b/src/Avalonia.Base/Metadata/PrivateApiAttribute.cs @@ -3,7 +3,7 @@ namespace Avalonia.Metadata; [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Constructor - | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field)] + | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Struct)] public sealed class PrivateApiAttribute : Attribute { diff --git a/src/Avalonia.Base/Platform/IModuleEnvironmentChecker.cs b/src/Avalonia.Base/Platform/IModuleEnvironmentChecker.cs deleted file mode 100644 index d8d3a19af6d..00000000000 --- a/src/Avalonia.Base/Platform/IModuleEnvironmentChecker.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Avalonia.Platform -{ - public interface IModuleEnvironmentChecker - { - bool IsCompatible { get; } - } -} \ No newline at end of file diff --git a/src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs b/src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs index 4fe4a2e6b92..71b339ec504 100644 --- a/src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs +++ b/src/Avalonia.Base/Platform/IPlatformThreadingInterface.cs @@ -8,7 +8,7 @@ namespace Avalonia.Platform /// /// Provides platform-specific services relating to threading. /// - [Unstable] + [PrivateApi] public interface IPlatformThreadingInterface { /// diff --git a/src/Avalonia.Base/Platform/IRenderTarget.cs b/src/Avalonia.Base/Platform/IRenderTarget.cs index 31ad84341d8..2b4584483ec 100644 --- a/src/Avalonia.Base/Platform/IRenderTarget.cs +++ b/src/Avalonia.Base/Platform/IRenderTarget.cs @@ -1,4 +1,5 @@ using System; +using Avalonia.Metadata; using Avalonia.Rendering; namespace Avalonia.Platform @@ -9,6 +10,7 @@ namespace Avalonia.Platform /// /// The interface used for obtaining drawing context from surfaces you can render on. /// + [PrivateApi] public interface IRenderTarget : IDisposable { /// diff --git a/src/Avalonia.Base/Platform/Interop/IDynamicLibraryLoader.cs b/src/Avalonia.Base/Platform/Interop/IDynamicLibraryLoader.cs index d9db4b71d56..56c50e340dd 100644 --- a/src/Avalonia.Base/Platform/Interop/IDynamicLibraryLoader.cs +++ b/src/Avalonia.Base/Platform/Interop/IDynamicLibraryLoader.cs @@ -3,7 +3,6 @@ namespace Avalonia.Platform.Interop { - [Unstable] public interface IDynamicLibraryLoader { IntPtr LoadLibrary(string dll); diff --git a/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs b/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs index 7a0b5b34cd7..8fef283b585 100644 --- a/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs +++ b/src/Avalonia.Base/Platform/Interop/Utf8Buffer.cs @@ -5,7 +5,7 @@ namespace Avalonia.Platform.Interop { - public class Utf8Buffer : SafeHandle + internal class Utf8Buffer : SafeHandle { private GCHandle _gcHandle; private byte[]? _data; diff --git a/src/Avalonia.Base/Rendering/DefaultRenderTimer.cs b/src/Avalonia.Base/Rendering/DefaultRenderTimer.cs index 7b0fecf6759..74c8bd107a9 100644 --- a/src/Avalonia.Base/Rendering/DefaultRenderTimer.cs +++ b/src/Avalonia.Base/Rendering/DefaultRenderTimer.cs @@ -1,4 +1,5 @@ using System; +using Avalonia.Metadata; using Avalonia.Platform; namespace Avalonia.Rendering @@ -10,6 +11,7 @@ namespace Avalonia.Rendering /// This class may be overridden by platform implementations to use a specialized timer /// implementation. /// + [PrivateApi] public class DefaultRenderTimer : IRenderTimer { private IRuntimePlatform? _runtime; diff --git a/src/Avalonia.Base/Rendering/DirtyRects.cs b/src/Avalonia.Base/Rendering/DirtyRects.cs deleted file mode 100644 index 610163191d1..00000000000 --- a/src/Avalonia.Base/Rendering/DirtyRects.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace Avalonia.Rendering -{ - /// - /// Tracks dirty rectangles. - /// - internal class DirtyRects : IEnumerable - { - private List _rects = new List(); - - /// - /// Gets a value indicating whether the collection of dirty rectangles is empty. - /// - public bool IsEmpty => _rects.Count == 0; - - /// - /// Adds a dirty rectangle, extending an existing dirty rectangle if it intersects. - /// - /// The dirt rectangle. - /// - /// We probably want to do this more intelligently because: - /// - Adding e.g. the top left quarter of a scene and the bottom left quarter of a scene - /// will cause the whole scene to be invalidated if they overlap by a single pixel - /// - Adding two adjacent rectangles that don't overlap will not cause them to be - /// coalesced - /// - It only coalesces the first intersecting rectangle found - one needs to - /// call at the end of the draw cycle to coalesce the rest. - /// - public void Add(Rect rect) - { - if (rect.Width != 0 || rect.Height != 0) - { - for (var i = 0; i < _rects.Count; ++i) - { - var r = _rects[i]; - - if (r.Intersects(rect)) - { - _rects[i] = r.Union(rect); - return; - } - } - - _rects.Add(rect); - } - } - - /// - /// Works around our flimsy dirt-rect coalescing algorithm. - /// - /// - /// See the comments in . - /// - public void Coalesce() - { - for (var i = _rects.Count - 1; i >= 0; --i) - { - var a = _rects[i]; - - for (var j = 0; j < i; ++j) - { - var b = _rects[j]; - - if (i < _rects.Count && a.Intersects(b)) - { - _rects[i] = _rects[i].Union(b); - _rects.RemoveAt(i); - } - } - } - } - - /// - /// Gets the dirty rectangles. - /// - /// A collection of dirty rectangles - public IEnumerator GetEnumerator() => _rects.GetEnumerator(); - - /// - /// Gets the dirty rectangles. - /// - /// A collection of dirty rectangles - IEnumerator IEnumerable.GetEnumerator() => _rects.GetEnumerator(); - } -} diff --git a/src/Avalonia.Base/Rendering/DirtyVisuals.cs b/src/Avalonia.Base/Rendering/DirtyVisuals.cs deleted file mode 100644 index dfadbdf6147..00000000000 --- a/src/Avalonia.Base/Rendering/DirtyVisuals.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using Avalonia.VisualTree; - -namespace Avalonia.Rendering -{ - /// - /// Stores a list of dirty visuals for an . - /// - /// - /// This class stores the dirty visuals for a scene, ordered by their distance to the root - /// visual. TODO: We probably want to put an upper limit on the number of visuals that can be - /// stored and if we reach that limit, assume all visuals are dirty. - /// - internal class DirtyVisuals : IEnumerable - { - private SortedDictionary> _inner = new SortedDictionary>(); - private Dictionary _index = new Dictionary(); - private int _enumerating; - - /// - /// Gets the number of dirty visuals. - /// - public int Count => _index.Count; - - /// - /// Adds a visual to the dirty list. - /// - /// The dirty visual. - public void Add(Visual visual) - { - if (_enumerating > 0) - { - throw new InvalidOperationException("Visual was invalidated during a render pass"); - } - - var distance = visual.CalculateDistanceFromAncestor((Visual?)visual.GetVisualRoot()); - - if (_index.TryGetValue(visual, out var existingDistance)) - { - if (distance == existingDistance) - { - return; - } - - _inner[existingDistance].Remove(visual); - _index.Remove(visual); - } - - if (!_inner.TryGetValue(distance, out var list)) - { - list = new List(); - _inner.Add(distance, list); - } - - list.Add(visual); - _index.Add(visual, distance); - } - - /// - /// Clears the list. - /// - public void Clear() - { - if (_enumerating > 0) - { - throw new InvalidOperationException("Cannot clear while enumerating"); - } - - _inner.Clear(); - _index.Clear(); - } - - /// - /// Gets the dirty visuals, in ascending order of distance to their root. - /// - /// A collection of visuals. - public IEnumerator GetEnumerator() - { - _enumerating++; - try - { - foreach (var i in _inner) - { - foreach (var j in i.Value) - { - yield return j; - } - } - } - finally - { - _enumerating--; - } - } - - /// - /// Gets the dirty visuals, in ascending order of distance to their root. - /// - /// A collection of visuals. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } -} diff --git a/src/Avalonia.Base/Rendering/DisplayDirtyRect.cs b/src/Avalonia.Base/Rendering/DisplayDirtyRect.cs deleted file mode 100644 index 7a89e5b3cca..00000000000 --- a/src/Avalonia.Base/Rendering/DisplayDirtyRect.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace Avalonia.Rendering -{ - /// - /// Holds the state for a dirty rect rendered when is set. - /// - internal class DisplayDirtyRect - { - public static readonly TimeSpan TimeToLive = TimeSpan.FromMilliseconds(250); - - /// - /// Initializes a new instance of the class. - /// - /// The dirt rect. - public DisplayDirtyRect(Rect rect) - { - Rect = rect; - ResetLifetime(); - } - - /// - /// Gets the bounds of the dirty rectangle. - /// - public Rect Rect { get; } - - /// - /// Gets the time at which the rectangle was made dirty. - /// - public DateTimeOffset Born { get; private set; } - - /// - /// Gets the time at which the rectangle should no longer be displayed. - /// - public DateTimeOffset Dies { get; private set; } - - /// - /// Gets the opacity at which to display the dirty rectangle. - /// - public double Opacity => (Dies - DateTimeOffset.UtcNow).TotalMilliseconds / TimeToLive.TotalMilliseconds; - - /// - /// Resets the rectangle's lifetime. - /// - public void ResetLifetime() - { - Born = DateTimeOffset.UtcNow; - Dies = Born + TimeToLive; - } - } -} diff --git a/src/Avalonia.Base/Rendering/DisplayDirtyRects.cs b/src/Avalonia.Base/Rendering/DisplayDirtyRects.cs deleted file mode 100644 index 2ffc1b4118d..00000000000 --- a/src/Avalonia.Base/Rendering/DisplayDirtyRects.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Avalonia.Rendering -{ - /// - /// Holds a collection of objects and manages their aging. - /// - internal class DisplayDirtyRects : IEnumerable - { - private List _inner = new List(); - - /// - /// Adds new new dirty rect to the collection. - /// - /// - public void Add(Rect rect) - { - foreach (var r in _inner) - { - if (r.Rect == rect) - { - r.ResetLifetime(); - return; - } - } - - _inner.Add(new DisplayDirtyRect(rect)); - } - - /// - /// Removes dirty rects one they are no longer active. - /// - public void Tick() - { - var now = DateTimeOffset.UtcNow; - - for (var i = _inner.Count - 1; i >= 0; --i) - { - var r = _inner[i]; - - if (now > r.Dies) - { - _inner.RemoveAt(i); - } - } - } - - /// - /// Gets the dirty rects. - /// - /// A collection of objects. - public IEnumerator GetEnumerator() => _inner.GetEnumerator(); - - /// - /// Gets the dirty rects. - /// - /// A collection of objects. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - } -} diff --git a/src/Avalonia.Base/Rendering/IDeferredRendererLock.cs b/src/Avalonia.Base/Rendering/IDeferredRendererLock.cs deleted file mode 100644 index 1c6bd691581..00000000000 --- a/src/Avalonia.Base/Rendering/IDeferredRendererLock.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using Avalonia.Metadata; - -namespace Avalonia.Rendering -{ - [Unstable] - public interface IDeferredRendererLock - { - IDisposable? TryLock(); - } -} diff --git a/src/Avalonia.Base/Rendering/IRenderTimer.cs b/src/Avalonia.Base/Rendering/IRenderTimer.cs index 14fcffd6a94..396e84d492a 100644 --- a/src/Avalonia.Base/Rendering/IRenderTimer.cs +++ b/src/Avalonia.Base/Rendering/IRenderTimer.cs @@ -6,7 +6,7 @@ namespace Avalonia.Rendering /// /// Defines the interface implemented by an application render timer. /// - [NotClientImplementable] + [PrivateApi] public interface IRenderTimer { /// diff --git a/src/Avalonia.Base/Rendering/IVisualBrushInitialize.cs b/src/Avalonia.Base/Rendering/IVisualBrushInitialize.cs index b5ab8ed0bde..227e6c1f1f9 100644 --- a/src/Avalonia.Base/Rendering/IVisualBrushInitialize.cs +++ b/src/Avalonia.Base/Rendering/IVisualBrushInitialize.cs @@ -8,7 +8,7 @@ namespace Avalonia.Rendering /// . /// [Unstable] - public interface IVisualBrushInitialize + internal interface IVisualBrushInitialize { /// /// Ensures that the control is ready to use as the visual in a visual brush. diff --git a/src/Avalonia.Base/Rendering/ManagedDeferredRendererLock.cs b/src/Avalonia.Base/Rendering/ManagedDeferredRendererLock.cs deleted file mode 100644 index 0397a32bfda..00000000000 --- a/src/Avalonia.Base/Rendering/ManagedDeferredRendererLock.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Threading; -using Avalonia.Utilities; - -namespace Avalonia.Rendering -{ - internal class ManagedDeferredRendererLock : DisposableLock, IDeferredRendererLock - { - - } -} diff --git a/src/Avalonia.Base/Rendering/SceneInvalidatedEventArgs.cs b/src/Avalonia.Base/Rendering/SceneInvalidatedEventArgs.cs index cac4d1693a9..fcccd9c7529 100644 --- a/src/Avalonia.Base/Rendering/SceneInvalidatedEventArgs.cs +++ b/src/Avalonia.Base/Rendering/SceneInvalidatedEventArgs.cs @@ -5,7 +5,7 @@ namespace Avalonia.Rendering /// /// Provides data for the event. /// - public class SceneInvalidatedEventArgs : EventArgs + internal class SceneInvalidatedEventArgs : EventArgs { /// /// Initializes a new instance of the class. diff --git a/src/Avalonia.Base/Rendering/SleepLoopRenderTimer.cs b/src/Avalonia.Base/Rendering/SleepLoopRenderTimer.cs index cd43a3ef209..3ad4ea94d0c 100644 --- a/src/Avalonia.Base/Rendering/SleepLoopRenderTimer.cs +++ b/src/Avalonia.Base/Rendering/SleepLoopRenderTimer.cs @@ -1,9 +1,11 @@ using System; using System.Diagnostics; using System.Threading; +using Avalonia.Metadata; namespace Avalonia.Rendering { + [PrivateApi] public class SleepLoopRenderTimer : IRenderTimer { private Action? _tick; diff --git a/src/Avalonia.Base/Rendering/UiThreadRenderTimer.cs b/src/Avalonia.Base/Rendering/UiThreadRenderTimer.cs index c50f8870a0e..06dc34c10aa 100644 --- a/src/Avalonia.Base/Rendering/UiThreadRenderTimer.cs +++ b/src/Avalonia.Base/Rendering/UiThreadRenderTimer.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using Avalonia.Metadata; using Avalonia.Reactive; using Avalonia.Threading; @@ -8,6 +9,7 @@ namespace Avalonia.Rendering /// /// Render timer that ticks on UI thread. Useful for debugging or bootstrapping on new platforms /// + [PrivateApi] public class UiThreadRenderTimer : DefaultRenderTimer { /// diff --git a/src/Avalonia.Base/VisualTree/IVisualWithRoundRectClip.cs b/src/Avalonia.Base/VisualTree/IVisualWithRoundRectClip.cs index 0079515a630..d85f50b591b 100644 --- a/src/Avalonia.Base/VisualTree/IVisualWithRoundRectClip.cs +++ b/src/Avalonia.Base/VisualTree/IVisualWithRoundRectClip.cs @@ -3,14 +3,11 @@ namespace Avalonia.VisualTree { - [Obsolete("Internal API, will be removed in future versions, you've been warned"), EditorBrowsable(EditorBrowsableState.Never)] - public interface IVisualWithRoundRectClip + internal interface IVisualWithRoundRectClip { /// /// Gets a value indicating the corner radius of control's clip bounds /// - [Obsolete("Internal API, will be removed in future versions, you've been warned"), EditorBrowsable(EditorBrowsableState.Never)] CornerRadius ClipToBoundsRadius { get; } - } } diff --git a/src/Avalonia.Controls/Application.cs b/src/Avalonia.Controls/Application.cs index f266aebcb4c..b98ad123f10 100644 --- a/src/Avalonia.Controls/Application.cs +++ b/src/Avalonia.Controls/Application.cs @@ -118,25 +118,13 @@ public static Application? Current /// public DataTemplates DataTemplates => _dataTemplates ?? (_dataTemplates = new DataTemplates()); - /// - /// Gets the application's focus manager. - /// - /// - /// The application's focus manager. - /// - public IFocusManager? FocusManager - { - get; - private set; - } - /// /// Gets the application's input manager. /// /// /// The application's input manager. /// - public InputManager? InputManager + internal InputManager? InputManager { get; private set; @@ -238,7 +226,7 @@ void IStyleHost.StylesRemoved(IReadOnlyList styles) public virtual void RegisterServices() { AvaloniaSynchronizationContext.InstallIfNeeded(); - FocusManager = new FocusManager(); + var focusManager = new FocusManager(); InputManager = new InputManager(); var settings = AvaloniaLocator.Current.GetRequiredService(); @@ -250,7 +238,7 @@ public virtual void RegisterServices() .Bind().ToConstant(this) .Bind().ToConstant(this) .Bind().ToConstant(this) - .Bind().ToConstant(FocusManager) + .Bind().ToConstant(focusManager) .Bind().ToConstant(InputManager) .Bind().ToTransient() .Bind().ToConstant(DragDropDevice.Instance); diff --git a/src/Avalonia.Controls/Platform/INativeApplicationCommands.cs b/src/Avalonia.Controls/Platform/INativeApplicationCommands.cs index 6720b8aa2c7..d837e4155e9 100644 --- a/src/Avalonia.Controls/Platform/INativeApplicationCommands.cs +++ b/src/Avalonia.Controls/Platform/INativeApplicationCommands.cs @@ -3,7 +3,7 @@ namespace Avalonia.Controls.Platform /// /// Native Menu Default Application Commands /// - public interface INativeApplicationCommands + internal interface INativeApplicationCommands { void HideApp(); void ShowAll(); diff --git a/src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs b/src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs index 6ad07b1b139..068ee39e842 100644 --- a/src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs +++ b/src/Avalonia.Controls/Platform/IPlatformNativeSurfaceHandle.cs @@ -4,7 +4,7 @@ namespace Avalonia.Platform { [Unstable] - public interface IPlatformNativeSurfaceHandle : IPlatformHandle + public interface INativePlatformHandleSurface : IPlatformHandle { PixelSize Size { get; } double Scaling { get; } diff --git a/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs b/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs index 9a60725c7e6..f1a5159069d 100644 --- a/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs +++ b/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositioner.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Linq; using System.Transactions; +using Avalonia.Metadata; namespace Avalonia.Controls.Primitives.PopupPositioning { + [PrivateApi] public interface IManagedPopupPositionerPopup { IReadOnlyList Screens { get; } @@ -13,6 +15,7 @@ public interface IManagedPopupPositionerPopup void MoveAndResize(Point devicePoint, Size virtualSize); } + [PrivateApi] public class ManagedPopupPositionerScreenInfo { public Rect Bounds { get; } @@ -29,6 +32,7 @@ public ManagedPopupPositionerScreenInfo(Rect bounds, Rect workingArea) /// An implementation for platforms on which a popup can be /// arbitrarily positioned. /// + [PrivateApi] public class ManagedPopupPositioner : IPopupPositioner { private readonly IManagedPopupPositionerPopup _popup; diff --git a/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositionerPopupImplHelper.cs b/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositionerPopupImplHelper.cs index 51a21323d9e..41a2a98fd35 100644 --- a/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositionerPopupImplHelper.cs +++ b/src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositionerPopupImplHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Avalonia.Metadata; using Avalonia.Platform; namespace Avalonia.Controls.Primitives.PopupPositioning @@ -8,6 +9,7 @@ namespace Avalonia.Controls.Primitives.PopupPositioning /// /// This class is used to simplify integration of IPopupImpl implementations with popup positioner /// + [PrivateApi] public class ManagedPopupPositionerPopupImplHelper : IManagedPopupPositionerPopup { private readonly IWindowBaseImpl _parent; diff --git a/src/Avalonia.Diagnostics/Diagnostics/Controls/Application.cs b/src/Avalonia.Diagnostics/Diagnostics/Controls/Application.cs index 0791815120d..06dbb7d50e4 100644 --- a/src/Avalonia.Diagnostics/Diagnostics/Controls/Application.cs +++ b/src/Avalonia.Diagnostics/Diagnostics/Controls/Application.cs @@ -59,15 +59,6 @@ public Application(ClassicDesktopStyleApplicationLifetimeTopLevelGroup group, Av public Avalonia.Controls.Templates.DataTemplates DataTemplates => _application.DataTemplates; - /// - /// Gets the application's focus manager. - /// - /// - /// The application's focus manager. - /// - public Input.IFocusManager? FocusManager => - _application.FocusManager; - /// /// Gets the application's input manager. /// diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index 9776fded040..be2d7548197 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -1326,7 +1326,7 @@ public void SetFrameThemeVariant(PlatformThemeVariant themeVariant) { } public bool IsEnabled => !_disabled; - public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle + public class SurfacePlatformHandle : INativePlatformHandleSurface { private readonly X11Window _owner; diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs index 070e1a95bc2..850ea6d4a6c 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmBindings.cs @@ -115,7 +115,7 @@ public DrmResources(int fd, bool connectorsForceProbe = false) } - public void Dump() + internal void Dump() { void Print(int off, string s) { diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs index 0135cb3d1fe..c91498fe053 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs @@ -49,6 +49,7 @@ public DrmOutput(DrmCard card, DrmResources resources, DrmConnector connector, D _outputOptions = options; Init(card, resources, connector, modeInfo); } + public DrmOutput(string path = null, bool connectorsForceProbe = false, DrmOutputOptions options = null) { if(options != null) diff --git a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj index 3c2d7b33220..9d4b04d2447 100644 --- a/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj +++ b/src/Windows/Avalonia.Direct2D1/Avalonia.Direct2D1.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs b/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs deleted file mode 100644 index d1233ca4e7b..00000000000 --- a/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Avalonia.Platform; - -namespace Avalonia.Direct2D1 -{ - class Direct2DChecker : IModuleEnvironmentChecker - { - //Direct2D backend doesn't work on some machines anymore - public bool IsCompatible - { - get - { - try - { - Direct2D1Platform.InitializeDirect2D(); - return true; - } - catch - { - return false; - } - } - } - } -} diff --git a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs index 2a3255bb70f..b256a9433d6 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs @@ -594,7 +594,6 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam, case WindowsMessage.WM_PAINT: { using (NonPumpingSyncContext.Use(NonPumpingWaitHelperImpl.Instance)) - using (_rendererLock.Lock()) { if (BeginPaint(_hwnd, out PAINTSTRUCT ps) != IntPtr.Zero) { @@ -616,12 +615,6 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam, case WindowsMessage.WM_SIZE: { - using (NonPumpingSyncContext.Use(NonPumpingWaitHelperImpl.Instance)) - using (_rendererLock.Lock()) - { - // Do nothing here, just block until the pending frame render is completed on the render thread - } - var size = (SizeCommand)wParam; if (Resized != null && @@ -837,11 +830,8 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam, return IntPtr.Zero; } } - - using (_rendererLock.Lock()) - { - return DefWindowProc(hWnd, msg, wParam, lParam); - } + + return DefWindowProc(hWnd, msg, wParam, lParam); } private Lazy?>? CreateLazyIntermediatePoints(POINTER_INFO info) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 201d9cd67a8..4260f90e9f2 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -71,7 +71,6 @@ internal partial class WindowImpl : IWindowImpl, EglGlPlatformSurface.IEglWindow private readonly TouchDevice _touchDevice; private readonly WindowsMouseDevice _mouseDevice; private readonly PenDevice _penDevice; - private readonly ManagedDeferredRendererLock _rendererLock; private readonly FramebufferManager _framebuffer; private readonly object? _gl; private readonly bool _wmPointerEnabled; @@ -130,7 +129,6 @@ public WindowImpl() IsResizable = true, Decorations = SystemDecorations.Full }; - _rendererLock = new ManagedDeferredRendererLock(); var glPlatform = AvaloniaLocator.Current.GetService(); @@ -1481,7 +1479,7 @@ public ResizeReasonScope(WindowImpl owner, WindowResizeReason restore) public void Dispose() => _owner._resizeReason = _restore; } - private class WindowImplPlatformHandle : IPlatformNativeSurfaceHandle + private class WindowImplPlatformHandle : INativePlatformHandleSurface { private readonly WindowImpl _owner; public WindowImplPlatformHandle(WindowImpl owner) => _owner = owner; diff --git a/tests/Avalonia.UnitTests/NullRenderer.cs b/tests/Avalonia.UnitTests/NullRenderer.cs index 1b59aa30eb2..a001ec0d6e9 100644 --- a/tests/Avalonia.UnitTests/NullRenderer.cs +++ b/tests/Avalonia.UnitTests/NullRenderer.cs @@ -12,7 +12,12 @@ public sealed class NullRenderer : IRenderer { public RendererDiagnostics Diagnostics { get; } = new(); - public event EventHandler? SceneInvalidated; + event EventHandler? IRenderer.SceneInvalidated + { + add { } + remove { } + } + public NullRenderer() {