Fix ref assembly generator making nested types public (#13513)
This commit is contained in:
committed by
GitHub
parent
020cf9ff21
commit
c40b627403
@@ -1003,6 +1003,72 @@
|
||||
<Left>baseline/designer/Avalonia.Designer.HostApp.dll</Left>
|
||||
<Right>target/designer/Avalonia.Designer.HostApp.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.AvaloniaLocator.RegistrationHelper`1</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.AvaloniaLocator.ResolverDisposable</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.Input.FocusManager.<GetFocusScopeAncestors>d__18</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.Layout.LayoutManager.<>c</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.Layout.LayoutManager.ArrangeResult</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.Layout.LayoutManager.EffectiveViewportChangedListener</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.Rendering.DefaultRenderTimer.<>c__DisplayClass13_0</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.Rendering.UiThreadRenderTimer.<>c__DisplayClass3_0</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.Controls.Primitives.PopupPositioning.ManagedPopupPositioner.<>c__DisplayClass5_0</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Controls.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Controls.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Controls.Primitives.PopupPositioning.ManagedPopupPositionerPopupImplHelper.<>c</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Controls.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Controls.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0001</DiagnosticId>
|
||||
<Target>T:Avalonia.Controls.Primitives.PopupPositioning.ManagedPopupPositionerPopupImplHelper.MoveResizeDelegate</Target>
|
||||
<Left>baseline/netstandard2.0/Avalonia.Controls.dll</Left>
|
||||
<Right>target/netstandard2.0/Avalonia.Controls.dll</Right>
|
||||
</Suppression>
|
||||
<Suppression>
|
||||
<DiagnosticId>CP0006</DiagnosticId>
|
||||
<Target>P:Avalonia.Rendering.Composition.ICompositionGpuImportedObject.ImportCompleted</Target>
|
||||
|
||||
@@ -70,9 +70,6 @@ public class RefAssemblyGenerator
|
||||
|
||||
static void ProcessType(TypeDefinition type, MethodReference obsoleteCtor)
|
||||
{
|
||||
foreach (var nested in type.NestedTypes)
|
||||
ProcessType(nested, obsoleteCtor);
|
||||
|
||||
var hideMembers = (type.IsInterface && type.Name.EndsWith("Impl"))
|
||||
|| HasPrivateApi(type.CustomAttributes);
|
||||
|
||||
@@ -97,7 +94,7 @@ public class RefAssemblyGenerator
|
||||
|
||||
foreach (var m in type.Methods)
|
||||
{
|
||||
if (hideMembers || HasPrivateApi(m.CustomAttributes))
|
||||
if (!m.IsPrivate && (hideMembers || HasPrivateApi(m.CustomAttributes)))
|
||||
{
|
||||
HideMethod(m);
|
||||
}
|
||||
@@ -108,30 +105,27 @@ public class RefAssemblyGenerator
|
||||
{
|
||||
if (HasPrivateApi(p.CustomAttributes))
|
||||
{
|
||||
if (p.SetMethod != null)
|
||||
HideMethod(p.SetMethod);
|
||||
if (p.GetMethod != null)
|
||||
HideMethod(p.GetMethod);
|
||||
if (p.SetMethod is { IsPrivate: false } setMethod)
|
||||
HideMethod(setMethod);
|
||||
if (p.GetMethod is { IsPrivate: false } getMethod)
|
||||
HideMethod(getMethod);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var f in type.Fields)
|
||||
{
|
||||
if (hideMembers || HasPrivateApi(f.CustomAttributes))
|
||||
if (!f.IsPrivate && (hideMembers || HasPrivateApi(f.CustomAttributes)))
|
||||
{
|
||||
var dflags = FieldAttributes.Public | FieldAttributes.Family | FieldAttributes.FamORAssem |
|
||||
FieldAttributes.FamANDAssem | FieldAttributes.Assembly;
|
||||
f.Attributes = ((f.Attributes | dflags) ^ dflags) | FieldAttributes.Assembly;
|
||||
f.IsAssembly = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var cl in type.NestedTypes)
|
||||
{
|
||||
ProcessType(cl, obsoleteCtor);
|
||||
if (hideMembers)
|
||||
if (hideMembers && cl.IsNestedPublic)
|
||||
{
|
||||
var dflags = TypeAttributes.Public;
|
||||
cl.Attributes = ((cl.Attributes | dflags) ^ dflags) | TypeAttributes.NotPublic;
|
||||
cl.IsNestedAssembly = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +137,7 @@ public class RefAssemblyGenerator
|
||||
|
||||
static void HideMethod(MethodDefinition m)
|
||||
{
|
||||
var dflags = MethodAttributes.Public | MethodAttributes.Family | MethodAttributes.FamORAssem |
|
||||
MethodAttributes.FamANDAssem | MethodAttributes.Assembly;
|
||||
m.Attributes = ((m.Attributes | dflags) ^ dflags) | MethodAttributes.Assembly;
|
||||
m.IsAssembly = true;
|
||||
}
|
||||
|
||||
static void MarkAsUnstable(IMemberDefinition def, MethodReference obsoleteCtor, ICustomAttribute? unstableAttribute)
|
||||
|
||||
Reference in New Issue
Block a user