From ec2861ebdcc1a8e90b86fe83ce9a1e4fb325ba2a Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 19 Aug 2024 15:56:55 -0700 Subject: [PATCH 1/4] Mark RenderWorker as internal --- src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs b/src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs index 6fe8d2ee733..96cc2ca1a6e 100644 --- a/src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs +++ b/src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs @@ -10,7 +10,7 @@ namespace Avalonia.Browser.Rendering; -public partial class RenderWorker +internal partial class RenderWorker { [DllImport("*")] private static extern int pthread_self(); From 8f16287f2f394e0da920079376b4e5dce209339e Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 19 Aug 2024 15:57:09 -0700 Subject: [PATCH 2/4] Add remaining Fonts.Tables types as internal --- .../Media/Fonts/Tables/InvalidFontTableException.cs | 2 +- src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs | 2 +- .../Media/Fonts/Tables/MissingFontTableException.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/Media/Fonts/Tables/InvalidFontTableException.cs b/src/Avalonia.Base/Media/Fonts/Tables/InvalidFontTableException.cs index d8be26a848c..435e5e46e30 100644 --- a/src/Avalonia.Base/Media/Fonts/Tables/InvalidFontTableException.cs +++ b/src/Avalonia.Base/Media/Fonts/Tables/InvalidFontTableException.cs @@ -10,7 +10,7 @@ namespace Avalonia.Media.Fonts.Tables /// Exception font loading can throw if it encounters invalid data during font loading. /// /// - public class InvalidFontTableException : Exception + internal class InvalidFontTableException : Exception { /// /// Initializes a new instance of the class. diff --git a/src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs b/src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs index 82e69266000..6212e68bffb 100644 --- a/src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs +++ b/src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs @@ -8,7 +8,7 @@ namespace Avalonia.Media.Fonts.Tables /// Provides enumeration of common name ids /// /// - public enum KnownNameIds : ushort + internal enum KnownNameIds : ushort { /// /// The copyright notice diff --git a/src/Avalonia.Base/Media/Fonts/Tables/MissingFontTableException.cs b/src/Avalonia.Base/Media/Fonts/Tables/MissingFontTableException.cs index 890414fc594..29b480cfd04 100644 --- a/src/Avalonia.Base/Media/Fonts/Tables/MissingFontTableException.cs +++ b/src/Avalonia.Base/Media/Fonts/Tables/MissingFontTableException.cs @@ -10,7 +10,7 @@ namespace Avalonia.Media.Fonts.Tables /// Exception font loading can throw if it finds a required table is missing during font loading. /// /// - public class MissingFontTableException : Exception + internal class MissingFontTableException : Exception { /// /// Initializes a new instance of the class. From d6a68361e2528a4ef0644b179abee9eddcf9d906 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 19 Aug 2024 15:58:11 -0700 Subject: [PATCH 3/4] Mark new diagnostic APIs as a PrivateAPI --- src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs | 3 ++- src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs | 5 ++++- src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs b/src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs index df48efe04e6..1c1ff4fd2f2 100644 --- a/src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs +++ b/src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs @@ -4,9 +4,10 @@ namespace Avalonia.Diagnostics; +[PrivateApi] public record ValueEntryDiagnostic(AvaloniaProperty Property, object? Value); -[Unstable] +[PrivateApi] [NotClientImplementable] public interface IValueFrameDiagnostic { diff --git a/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs b/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs index 32bbe782187..d6ed3373841 100644 --- a/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs +++ b/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs @@ -1,8 +1,11 @@ -namespace Avalonia.Diagnostics; +using Avalonia.Metadata; + +namespace Avalonia.Diagnostics; /// /// Defines diagnostic extensions on s. /// +[PrivateApi] public static class StyledElementExtensions { /// diff --git a/src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs b/src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs index e4880cdc766..c9a3374bcc5 100644 --- a/src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs +++ b/src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; +using Avalonia.Metadata; using Avalonia.Styling; namespace Avalonia.Diagnostics; +[PrivateApi] public class ValueStoreDiagnostic { /// From cff3a4c49a1c5beddc2e3d146566b4f30fca93ba Mon Sep 17 00:00:00 2001 From: Max Katz Date: Mon, 19 Aug 2024 16:14:58 -0700 Subject: [PATCH 4/4] Restore old GetStyleDiagnostics APIs, but mark them with [PrivateApi], avoiding breaking changes --- api/Avalonia.Skia.nupkg.xml | 4 +- api/Avalonia.nupkg.xml | 32 ++++++++++++++-- .../Diagnostics/StyleDiagnostics.cs | 37 +++++++++++++++++++ .../Diagnostics/StyleValueFrameDiagnostic.cs | 4 ++ .../Diagnostics/StyledElementExtensions.cs | 14 +++++++ 5 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs diff --git a/api/Avalonia.Skia.nupkg.xml b/api/Avalonia.Skia.nupkg.xml index 7abbc47cea5..ed29e880a43 100644 --- a/api/Avalonia.Skia.nupkg.xml +++ b/api/Avalonia.Skia.nupkg.xml @@ -1,4 +1,4 @@ - + @@ -7,4 +7,4 @@ baseline/netstandard2.0/Avalonia.Skia.dll target/netstandard2.0/Avalonia.Skia.dll - + \ No newline at end of file diff --git a/api/Avalonia.nupkg.xml b/api/Avalonia.nupkg.xml index 13b9724778f..f9306abc56a 100644 --- a/api/Avalonia.nupkg.xml +++ b/api/Avalonia.nupkg.xml @@ -2,14 +2,20 @@ - CP0001 - T:Avalonia.Diagnostics.AppliedStyle + CP0002 + M:Avalonia.Diagnostics.AppliedStyle.get_HasActivator baseline/netstandard2.0/Avalonia.Base.dll target/netstandard2.0/Avalonia.Base.dll - CP0001 - T:Avalonia.Diagnostics.StyleDiagnostics + CP0002 + M:Avalonia.Diagnostics.AppliedStyle.get_IsActive + baseline/netstandard2.0/Avalonia.Base.dll + target/netstandard2.0/Avalonia.Base.dll + + + CP0002 + M:Avalonia.Diagnostics.AppliedStyle.get_Style baseline/netstandard2.0/Avalonia.Base.dll target/netstandard2.0/Avalonia.Base.dll @@ -19,6 +25,18 @@ baseline/netstandard2.0/Avalonia.Base.dll target/netstandard2.0/Avalonia.Base.dll + + CP0002 + M:Avalonia.Diagnostics.StyleDiagnostics.#ctor(System.Collections.Generic.IReadOnlyList{Avalonia.Diagnostics.AppliedStyle}) + baseline/netstandard2.0/Avalonia.Base.dll + target/netstandard2.0/Avalonia.Base.dll + + + CP0002 + M:Avalonia.Diagnostics.StyleDiagnostics.get_AppliedStyles + baseline/netstandard2.0/Avalonia.Base.dll + target/netstandard2.0/Avalonia.Base.dll + CP0002 M:Avalonia.Controls.Primitives.IPopupHost.ConfigurePosition(Avalonia.Visual,Avalonia.Controls.PlacementMode,Avalonia.Point,Avalonia.Controls.Primitives.PopupPositioning.PopupAnchor,Avalonia.Controls.Primitives.PopupPositioning.PopupGravity,Avalonia.Controls.Primitives.PopupPositioning.PopupPositionerConstraintAdjustment,System.Nullable{Avalonia.Rect}) @@ -55,6 +73,12 @@ baseline/netstandard2.0/Avalonia.Controls.dll target/netstandard2.0/Avalonia.Controls.dll + + CP0009 + T:Avalonia.Diagnostics.StyleDiagnostics + baseline/netstandard2.0/Avalonia.Base.dll + target/netstandard2.0/Avalonia.Base.dll + CP0009 T:Avalonia.Controls.Screens diff --git a/src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs b/src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs new file mode 100644 index 00000000000..3db48cd69c1 --- /dev/null +++ b/src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using Avalonia.Metadata; +using Avalonia.Styling; + +namespace Avalonia.Diagnostics; + +[PrivateApi] +[Unstable("Use StyledElementExtensions.GetValueStoreDiagnostic() instead")] +public class StyleDiagnostics +{ + /// + /// Currently applied styles. + /// + public IReadOnlyList AppliedStyles { get; } + + public StyleDiagnostics(IReadOnlyList appliedStyles) + { + AppliedStyles = appliedStyles; + } +} + +[PrivateApi] +[Unstable("Use StyledElementExtensions.GetValueStoreDiagnostic() instead")] +public sealed class AppliedStyle +{ + private readonly StyleInstance _instance; + + internal AppliedStyle(StyleInstance instance) + { + _instance = instance; + } + + public bool HasActivator => _instance.HasActivator; + public bool IsActive => _instance.IsActive(); + public StyleBase Style => (StyleBase)_instance.Source; +} diff --git a/src/Avalonia.Base/Diagnostics/StyleValueFrameDiagnostic.cs b/src/Avalonia.Base/Diagnostics/StyleValueFrameDiagnostic.cs index 03d901cee22..871ea7dfc0f 100644 --- a/src/Avalonia.Base/Diagnostics/StyleValueFrameDiagnostic.cs +++ b/src/Avalonia.Base/Diagnostics/StyleValueFrameDiagnostic.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Avalonia.Data; +using Avalonia.Metadata; using Avalonia.PropertyStore; using Avalonia.Styling; @@ -60,4 +61,7 @@ private string GetFullSelector(Style? style) return string.Concat(selectors); } + + [Unstable("Compatibility with 11.x")] + public AppliedStyle AsAppliedStyle() => new AppliedStyle(_styleInstance); } diff --git a/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs b/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs index d6ed3373841..b4d52c05483 100644 --- a/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs +++ b/src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs @@ -1,4 +1,7 @@ +using System; +using System.Linq; using Avalonia.Metadata; +using Avalonia.Styling; namespace Avalonia.Diagnostics; @@ -16,4 +19,15 @@ public static ValueStoreDiagnostic GetValueStoreDiagnostic(this StyledElement st { return styledElement.GetValueStore().GetStoreDiagnostic(); } + + [Obsolete("Use StyledElementExtensions.GetValueStoreDiagnostic instead", true)] + public static StyleDiagnostics GetStyleDiagnostics(this StyledElement styledElement) + { + var diagnostics = styledElement.GetValueStore().GetStoreDiagnostic(); + return new StyleDiagnostics(diagnostics.AppliedFrames + .OfType() + .Select(f => f.AsAppliedStyle()) + .ToArray()); + } } +