Browse Source

Added [PrivateApi]

pull/11062/head
Nikita Tsukanov 3 years ago
parent
commit
30064443b1
  1. 16
      nukebuild/RefAssemblyGenerator.cs
  2. 9
      src/Avalonia.Base/Metadata/PrivateApiAttribute.cs
  3. 2
      src/Avalonia.Base/Platform/ICursorFactory.cs
  4. 4
      src/Avalonia.Base/Platform/IPlatformRenderInterface.cs
  5. 2
      src/Avalonia.Controls/Platform/IPlatformIconLoader.cs
  6. 2
      src/Avalonia.Controls/Platform/IWindowingPlatform.cs

16
nukebuild/RefAssemblyGenerator.cs

@ -39,10 +39,13 @@ public class RefAssemblyGenerator
ProcessType(nested, obsoleteCtor); ProcessType(nested, obsoleteCtor);
if (type.IsInterface) if (type.IsInterface)
{ {
var hideMethods = type.Name.EndsWith("Impl"); var hideMethods = type.Name.EndsWith("Impl")
|| (type.HasCustomAttributes && type.CustomAttributes.Any(a =>
a.AttributeType.FullName == "Avalonia.Metadata.PrivateApiAttribute"));
var injectMethod = hideMethods var injectMethod = hideMethods
|| type.CustomAttributes.Any(a => || type.CustomAttributes.Any(a =>
a.AttributeType.FullName.EndsWith("NotClientImplementableAttribute")); a.AttributeType.FullName == "Avalonia.Metadata.NotClientImplementableAttribute");
if (hideMethods) if (hideMethods)
{ {
@ -65,7 +68,7 @@ public class RefAssemblyGenerator
} }
var forceUnstable = type.CustomAttributes.Any(a => var forceUnstable = type.CustomAttributes.Any(a =>
a.AttributeType.FullName.EndsWith("UnstableAttribute")); a.AttributeType.FullName == "Avalonia.Metadata.UnstableAttribute");
foreach (var m in type.Methods) foreach (var m in type.Methods)
MarkAsUnstable(m, obsoleteCtor, forceUnstable); MarkAsUnstable(m, obsoleteCtor, forceUnstable);
@ -81,11 +84,10 @@ public class RefAssemblyGenerator
{ {
if (!force if (!force
|| def.HasCustomAttributes == false || def.HasCustomAttributes == false
|| !def.CustomAttributes.Any(a => || def.CustomAttributes.All(a => a.AttributeType.FullName != "Avalonia.Metadata.UnstableAttribute"))
a.AttributeType.FullName.EndsWith("UnstableAttribute")))
return; return;
if (def.CustomAttributes.Any(a => a.TypeFullName.EndsWith("ObsoleteAttribute"))) if (def.CustomAttributes.Any(a => a.TypeFullName == "System.ObsoleteAttribute"))
return; return;
def.CustomAttributes.Add(new CustomAttribute(obsoleteCtor, new CAArgument[] def.CustomAttributes.Add(new CustomAttribute(obsoleteCtor, new CAArgument[]

9
src/Avalonia.Base/Metadata/PrivateApiAttribute.cs

@ -0,0 +1,9 @@
using System;
namespace Avalonia.Metadata;
[AttributeUsage(AttributeTargets.Interface)]
public sealed class PrivateApiAttribute : Attribute
{
}

2
src/Avalonia.Base/Platform/ICursorFactory.cs

@ -1,9 +1,11 @@
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Metadata;
#nullable enable #nullable enable
namespace Avalonia.Platform namespace Avalonia.Platform
{ {
[PrivateApi]
public interface ICursorFactory public interface ICursorFactory
{ {
ICursorImpl GetCursor(StandardCursorType cursorType); ICursorImpl GetCursor(StandardCursorType cursorType);

4
src/Avalonia.Base/Platform/IPlatformRenderInterface.cs

@ -11,7 +11,7 @@ namespace Avalonia.Platform
/// <summary> /// <summary>
/// Defines the main platform-specific interface for the rendering subsystem. /// Defines the main platform-specific interface for the rendering subsystem.
/// </summary> /// </summary>
[Unstable] [Unstable, PrivateApi]
public interface IPlatformRenderInterface public interface IPlatformRenderInterface
{ {
/// <summary> /// <summary>
@ -201,7 +201,7 @@ namespace Avalonia.Platform
bool IsSupportedBitmapPixelFormat(PixelFormat format); bool IsSupportedBitmapPixelFormat(PixelFormat format);
} }
[Unstable] [Unstable, PrivateApi]
public interface IPlatformRenderInterfaceContext : IOptionalFeatureProvider, IDisposable public interface IPlatformRenderInterfaceContext : IOptionalFeatureProvider, IDisposable
{ {
/// <summary> /// <summary>

2
src/Avalonia.Controls/Platform/IPlatformIconLoader.cs

@ -3,7 +3,7 @@ using Avalonia.Metadata;
namespace Avalonia.Platform namespace Avalonia.Platform
{ {
[Unstable] [Unstable, PrivateApi]
public interface IPlatformIconLoader public interface IPlatformIconLoader
{ {
IWindowIconImpl LoadIcon(string fileName); IWindowIconImpl LoadIcon(string fileName);

2
src/Avalonia.Controls/Platform/IWindowingPlatform.cs

@ -2,7 +2,7 @@ using Avalonia.Metadata;
namespace Avalonia.Platform namespace Avalonia.Platform
{ {
[Unstable] [Unstable, PrivateApi]
public interface IWindowingPlatform public interface IWindowingPlatform
{ {
IWindowImpl CreateWindow(); IWindowImpl CreateWindow();

Loading…
Cancel
Save