From 87aa786b3997a23501912abd4654e4fd9958230c Mon Sep 17 00:00:00 2001 From: Lakshan Fernando Date: Fri, 15 Jul 2022 04:01:25 -0700 Subject: [PATCH] Annotating libraries with small number of warnings to be AOT safe (#72108) * Annotating librries with small number of warnings to be AOT safe * FB * Fix RR linux arm64 failure and remove ComponentModel annotation --- eng/pipelines/runtime-extra-platforms-other.yml | 1 + .../ref/System.Reflection.DispatchProxy.cs | 1 + .../src/System.Reflection.DispatchProxy.csproj | 1 + .../src/System/Reflection/DispatchProxy.cs | 1 + .../src/System/Reflection/DispatchProxyGenerator.cs | 2 ++ src/libraries/tests.proj | 4 ++++ 6 files changed, 10 insertions(+) diff --git a/eng/pipelines/runtime-extra-platforms-other.yml b/eng/pipelines/runtime-extra-platforms-other.yml index e25d3c8..16ffc6a 100644 --- a/eng/pipelines/runtime-extra-platforms-other.yml +++ b/eng/pipelines/runtime-extra-platforms-other.yml @@ -85,6 +85,7 @@ jobs: - windows_x64 - windows_arm64 - Linux_x64 + - Linux_arm64 jobParameters: testGroup: innerloop isSingleFile: true diff --git a/src/libraries/System.Reflection.DispatchProxy/ref/System.Reflection.DispatchProxy.cs b/src/libraries/System.Reflection.DispatchProxy/ref/System.Reflection.DispatchProxy.cs index 82e762d..07bf6ea 100644 --- a/src/libraries/System.Reflection.DispatchProxy/ref/System.Reflection.DispatchProxy.cs +++ b/src/libraries/System.Reflection.DispatchProxy/ref/System.Reflection.DispatchProxy.cs @@ -9,6 +9,7 @@ namespace System.Reflection public abstract partial class DispatchProxy { protected DispatchProxy() { } + [System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Creating a proxy instance requires generating code at runtime")] public static T Create<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All)] T, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TProxy>() where TProxy : System.Reflection.DispatchProxy { throw null; } protected abstract object? Invoke(System.Reflection.MethodInfo? targetMethod, object?[]? args); } diff --git a/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj b/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj index 45608a8..231c1b9 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj +++ b/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj @@ -2,6 +2,7 @@ true $(NetCoreAppCurrent) + true diff --git a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs index dbfea73..9a971cb 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs +++ b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs @@ -33,6 +33,7 @@ namespace System.Reflection /// An object instance that implements . /// is a class, /// or is sealed or does not have a parameterless constructor + [RequiresDynamicCode("Creating a proxy instance requires generating code at runtime")] public static T Create<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TProxy>() where TProxy : DispatchProxy { diff --git a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs index c779ad0..2f496aa 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs +++ b/src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs @@ -59,6 +59,7 @@ namespace System.Reflection typeof(MethodInfo).GetMethod("MakeGenericMethod", new Type[] { typeof(Type[]) })!; // Returns a new instance of a proxy the derives from 'baseType' and implements 'interfaceType' + [RequiresDynamicCode("Defining a dynamic assembly requires generating code at runtime")] internal static object CreateProxyInstance( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type baseType, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType) @@ -113,6 +114,7 @@ namespace System.Reflection private readonly HashSet _ignoresAccessAssemblyNames = new HashSet(); private ConstructorInfo? _ignoresAccessChecksToAttributeConstructor; + [RequiresDynamicCode("Defining a dynamic assembly requires generating code at runtime")] public ProxyAssembly(AssemblyLoadContext alc) { string name; diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index bc5fe0d..98c38d1 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -444,6 +444,10 @@ Condition="'$(TargetOS)' == 'linux'" /> + + -- 2.7.4