Skip to content

Commit 87aa786

Browse files
authored
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
1 parent a379a42 commit 87aa786

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed

eng/pipelines/runtime-extra-platforms-other.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
- windows_x64
8686
- windows_arm64
8787
- Linux_x64
88+
- Linux_arm64
8889
jobParameters:
8990
testGroup: innerloop
9091
isSingleFile: true

src/libraries/System.Reflection.DispatchProxy/ref/System.Reflection.DispatchProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace System.Reflection
99
public abstract partial class DispatchProxy
1010
{
1111
protected DispatchProxy() { }
12+
[System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute("Creating a proxy instance requires generating code at runtime")]
1213
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; }
1314
protected abstract object? Invoke(System.Reflection.MethodInfo? targetMethod, object?[]? args);
1415
}

src/libraries/System.Reflection.DispatchProxy/src/System.Reflection.DispatchProxy.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
5+
<EnableAOTAnalyzer>true</EnableAOTAnalyzer>
56
</PropertyGroup>
67
<ItemGroup>
78
<Compile Include="System\Reflection\DispatchProxy.cs" />

src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected DispatchProxy()
3333
/// <returns>An object instance that implements <typeparamref name="T"/>.</returns>
3434
/// <exception cref="System.ArgumentException"><typeparamref name="T"/> is a class,
3535
/// or <typeparamref name="TProxy"/> is sealed or does not have a parameterless constructor</exception>
36+
[RequiresDynamicCode("Creating a proxy instance requires generating code at runtime")]
3637
public static T Create<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TProxy>()
3738
where TProxy : DispatchProxy
3839
{

src/libraries/System.Reflection.DispatchProxy/src/System/Reflection/DispatchProxyGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ private static MethodInfo GetGenericMethodMethodInfo() =>
5959
typeof(MethodInfo).GetMethod("MakeGenericMethod", new Type[] { typeof(Type[]) })!;
6060

6161
// Returns a new instance of a proxy the derives from 'baseType' and implements 'interfaceType'
62+
[RequiresDynamicCode("Defining a dynamic assembly requires generating code at runtime")]
6263
internal static object CreateProxyInstance(
6364
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type baseType,
6465
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type interfaceType)
@@ -113,6 +114,7 @@ private sealed class ProxyAssembly
113114
private readonly HashSet<string> _ignoresAccessAssemblyNames = new HashSet<string>();
114115
private ConstructorInfo? _ignoresAccessChecksToAttributeConstructor;
115116

117+
[RequiresDynamicCode("Defining a dynamic assembly requires generating code at runtime")]
116118
public ProxyAssembly(AssemblyLoadContext alc)
117119
{
118120
string name;

src/libraries/tests.proj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@
444444
Condition="'$(TargetOS)' == 'linux'" />
445445
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Threading.Tasks.Dataflow\tests\System.Threading.Tasks.Dataflow.Tests.csproj"
446446
Condition="'$(TargetOS)' == 'linux'" />
447+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Numerics.Vectors\tests\System.Numerics.Vectors.Tests.csproj"
448+
Condition="'$(TargetOS)' == 'linux'" />
449+
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Linq.Expressions\tests\System.Linq.Expressions.Tests.csproj"
450+
Condition="'$(TargetOS)' == 'linux' and '$(TargetArchitecture)' == 'arm64'" />
447451
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Net.NameResolution\tests\FunctionalTests\System.Net.NameResolution.Functional.Tests.csproj"
448452
Condition="'$(TargetOS)' == 'windows'"/>
449453

0 commit comments

Comments
 (0)