From ce55f2b5e70fbcc19d5e8c28eb854b5f26c91287 Mon Sep 17 00:00:00 2001 From: Lakshan Fernando Date: Wed, 13 Jul 2022 09:31:03 -0700 Subject: [PATCH 1/3] Annotating librries with small number of warnings to be AOT safe --- .../src/System.ComponentModel.TypeConverter.csproj | 2 ++ .../src/System/ComponentModel/EnumConverter.cs | 2 ++ src/libraries/System.Data.Common/src/System.Data.Common.csproj | 2 ++ .../System.Data.Common/src/System/Data/DataRowExtensions.cs | 2 ++ src/libraries/System.Data.Common/src/System/Data/DataTable.cs | 2 ++ .../ref/System.Reflection.DispatchProxy.cs | 1 + .../src/System.Reflection.DispatchProxy.csproj | 2 ++ .../src/System/Reflection/DispatchProxy.cs | 1 + .../src/System/Reflection/DispatchProxyGenerator.cs | 2 ++ 9 files changed, 16 insertions(+) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index bd04566e216f2..f20f701b98a33 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -3,6 +3,8 @@ $(NetCoreAppCurrent) true true + + true diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs index 81e10e504d83e..33616f85966f6 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs @@ -115,6 +115,8 @@ private static long GetEnumValue(bool isUnderlyingTypeUInt64, Enum enumVal, Cult /// /// Converts the given value object to the specified destination type. /// + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", + Justification = "Enum type is checked to be present before getting its values")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { ArgumentNullException.ThrowIfNull(destinationType); diff --git a/src/libraries/System.Data.Common/src/System.Data.Common.csproj b/src/libraries/System.Data.Common/src/System.Data.Common.csproj index 8c1413c2612d4..752292430e562 100644 --- a/src/libraries/System.Data.Common/src/System.Data.Common.csproj +++ b/src/libraries/System.Data.Common/src/System.Data.Common.csproj @@ -3,6 +3,8 @@ true $(NetCoreAppCurrent) $(NoWarn);SYSLIB0038 + + true diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs b/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs index 3ebbdc113527f..e4f75251a32c8 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs @@ -143,6 +143,8 @@ private static class UnboxT { internal static readonly Converter s_unbox = Create(); + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", + Justification = "The value type field would be available")] private static Converter Create() { if (typeof(T).IsValueType) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index eba3f6acd109b..01b50d4b55904 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -3516,6 +3516,8 @@ record = NewRecord(-1); // Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set. [MethodImpl(MethodImplOptions.NoInlining)] + [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", + Justification = "The array type would be available at runtime")] protected internal DataRow[] NewRowArray(int size) { if (IsTypedDataTable) 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 82e762d95f67f..07bf6ea97b17c 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 45608a80899da..2cf530e7282d1 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,8 @@ 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 dbfea73eebfc2..9a971cb6bc86c 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 @@ protected DispatchProxy() /// 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 c779ad0244065..2f496aada8b3c 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 @@ private static MethodInfo GetGenericMethodMethodInfo() => 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 @@ private sealed class ProxyAssembly 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; From 894fbbe7a95c23ff0ad466e68cad0afbb0b27750 Mon Sep 17 00:00:00 2001 From: Lakshan Fernando Date: Wed, 13 Jul 2022 15:35:34 -0700 Subject: [PATCH 2/3] FB --- eng/pipelines/runtime-extra-platforms-other.yml | 1 + src/libraries/System.Data.Common/src/System.Data.Common.csproj | 2 -- .../System.Data.Common/src/System/Data/DataRowExtensions.cs | 2 -- src/libraries/System.Data.Common/src/System/Data/DataTable.cs | 2 -- .../src/System.Reflection.DispatchProxy.csproj | 1 - src/libraries/tests.proj | 2 ++ 6 files changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/pipelines/runtime-extra-platforms-other.yml b/eng/pipelines/runtime-extra-platforms-other.yml index e25d3c86aa71c..16ffc6af669a3 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.Data.Common/src/System.Data.Common.csproj b/src/libraries/System.Data.Common/src/System.Data.Common.csproj index 752292430e562..8c1413c2612d4 100644 --- a/src/libraries/System.Data.Common/src/System.Data.Common.csproj +++ b/src/libraries/System.Data.Common/src/System.Data.Common.csproj @@ -3,8 +3,6 @@ true $(NetCoreAppCurrent) $(NoWarn);SYSLIB0038 - - true diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs b/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs index e4f75251a32c8..3ebbdc113527f 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRowExtensions.cs @@ -143,8 +143,6 @@ private static class UnboxT { internal static readonly Converter s_unbox = Create(); - [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", - Justification = "The value type field would be available")] private static Converter Create() { if (typeof(T).IsValueType) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 01b50d4b55904..eba3f6acd109b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -3516,8 +3516,6 @@ record = NewRecord(-1); // Prevent inlining so that reflection calls are not moved to caller that may be in a different assembly that may have a different grant set. [MethodImpl(MethodImplOptions.NoInlining)] - [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", - Justification = "The array type would be available at runtime")] protected internal DataRow[] NewRowArray(int size) { if (IsTypedDataTable) 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 2cf530e7282d1..231c1b9241d96 100644 --- a/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj +++ b/src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj @@ -2,7 +2,6 @@ true $(NetCoreAppCurrent) - true diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 340116853154c..89b44163c42b8 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -447,6 +447,8 @@ Condition="'$(TargetOS)' == 'linux'" /> + From 6233ee0a3f43ecdeaa9c57a0e26c3fb5015573c6 Mon Sep 17 00:00:00 2001 From: Lakshan Fernando Date: Thu, 14 Jul 2022 09:33:06 -0700 Subject: [PATCH 3/3] Fix RR linux arm64 failure and remove ComponentModel annotation --- .../src/System.ComponentModel.TypeConverter.csproj | 2 -- .../src/System/ComponentModel/EnumConverter.cs | 2 -- src/libraries/tests.proj | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj index f20f701b98a33..bd04566e216f2 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System.ComponentModel.TypeConverter.csproj @@ -3,8 +3,6 @@ $(NetCoreAppCurrent) true true - - true diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs index 33616f85966f6..81e10e504d83e 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/EnumConverter.cs @@ -115,8 +115,6 @@ private static long GetEnumValue(bool isUnderlyingTypeUInt64, Enum enumVal, Cult /// /// Converts the given value object to the specified destination type. /// - [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode", - Justification = "Enum type is checked to be present before getting its values")] public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType) { ArgumentNullException.ThrowIfNull(destinationType); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 89b44163c42b8..3e6dcac32688e 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -449,6 +449,8 @@ Condition="'$(TargetOS)' == 'linux'" /> +