Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11.2.x Private/PublicAPI adjustments #16733

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/Avalonia.Skia.nupkg.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
Expand All @@ -7,4 +7,4 @@
<Left>baseline/netstandard2.0/Avalonia.Skia.dll</Left>
<Right>target/netstandard2.0/Avalonia.Skia.dll</Right>
</Suppression>
</Suppressions>
</Suppressions>
32 changes: 28 additions & 4 deletions api/Avalonia.nupkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Diagnostics.AppliedStyle</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Diagnostics.AppliedStyle.get_HasActivator</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Avalonia.Diagnostics.StyleDiagnostics</Target>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Diagnostics.AppliedStyle.get_IsActive</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Diagnostics.AppliedStyle.get_Style</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
Expand All @@ -19,6 +25,18 @@
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Diagnostics.StyleDiagnostics.#ctor(System.Collections.Generic.IReadOnlyList{Avalonia.Diagnostics.AppliedStyle})</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Avalonia.Diagnostics.StyleDiagnostics.get_AppliedStyles</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>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})</Target>
Expand Down Expand Up @@ -55,6 +73,12 @@
<Left>baseline/netstandard2.0/Avalonia.Controls.dll</Left>
<Right>target/netstandard2.0/Avalonia.Controls.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0009</DiagnosticId>
<Target>T:Avalonia.Diagnostics.StyleDiagnostics</Target>
<Left>baseline/netstandard2.0/Avalonia.Base.dll</Left>
<Right>target/netstandard2.0/Avalonia.Base.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0009</DiagnosticId>
<Target>T:Avalonia.Controls.Screens</Target>
Expand Down
3 changes: 2 additions & 1 deletion src/Avalonia.Base/Diagnostics/IValueFrameDiagnostic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace Avalonia.Diagnostics;

[PrivateApi]
public record ValueEntryDiagnostic(AvaloniaProperty Property, object? Value);

[Unstable]
[PrivateApi]
[NotClientImplementable]
public interface IValueFrameDiagnostic
{
Expand Down
37 changes: 37 additions & 0 deletions src/Avalonia.Base/Diagnostics/StyleDiagnostics.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Currently applied styles.
/// </summary>
public IReadOnlyList<AppliedStyle> AppliedStyles { get; }

public StyleDiagnostics(IReadOnlyList<AppliedStyle> 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;
}
4 changes: 4 additions & 0 deletions src/Avalonia.Base/Diagnostics/StyleValueFrameDiagnostic.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Avalonia.Data;
using Avalonia.Metadata;
using Avalonia.PropertyStore;
using Avalonia.Styling;

Expand Down Expand Up @@ -60,4 +61,7 @@ private string GetFullSelector(Style? style)

return string.Concat(selectors);
}

[Unstable("Compatibility with 11.x")]
public AppliedStyle AsAppliedStyle() => new AppliedStyle(_styleInstance);
}
19 changes: 18 additions & 1 deletion src/Avalonia.Base/Diagnostics/StyledElementExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
namespace Avalonia.Diagnostics;
using System;
using System.Linq;
using Avalonia.Metadata;
using Avalonia.Styling;

namespace Avalonia.Diagnostics;

/// <summary>
/// Defines diagnostic extensions on <see cref="StyledElement"/>s.
/// </summary>
[PrivateApi]
public static class StyledElementExtensions
{
/// <summary>
Expand All @@ -13,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<StyleValueFrameDiagnostic>()
.Select(f => f.AsAppliedStyle())
.ToArray());
}
}

2 changes: 2 additions & 0 deletions src/Avalonia.Base/Diagnostics/ValueStoreDiagnostic.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Collections.Generic;
using Avalonia.Metadata;
using Avalonia.Styling;

namespace Avalonia.Diagnostics;

[PrivateApi]
public class ValueStoreDiagnostic
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Avalonia.Media.Fonts.Tables
/// Exception font loading can throw if it encounters invalid data during font loading.
/// </summary>
/// <seealso cref="Exception" />
public class InvalidFontTableException : Exception
internal class InvalidFontTableException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidFontTableException"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Media/Fonts/Tables/KnownNameIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Avalonia.Media.Fonts.Tables
/// Provides enumeration of common name ids
/// <see href="https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids"/>
/// </summary>
public enum KnownNameIds : ushort
internal enum KnownNameIds : ushort
{
/// <summary>
/// The copyright notice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
/// <seealso cref="Exception" />
public class MissingFontTableException : Exception
internal class MissingFontTableException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="MissingFontTableException"/> class.
Expand Down
2 changes: 1 addition & 1 deletion src/Browser/Avalonia.Browser/Rendering/RenderWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Avalonia.Browser.Rendering;

public partial class RenderWorker
internal partial class RenderWorker
{
[DllImport("*")]
private static extern int pthread_self();
Expand Down
Loading