diff --git a/eng/testing/tests.singlefile.targets b/eng/testing/tests.singlefile.targets
index 6bbbcc7834fd55..1ea8c014446c6c 100644
--- a/eng/testing/tests.singlefile.targets
+++ b/eng/testing/tests.singlefile.targets
@@ -29,7 +29,7 @@
$(CoreCLRAotSdkDir)
$(NetCoreAppCurrentTestHostSharedFrameworkPath)
$(NetCoreAppCurrentTestHostSharedFrameworkPath)
- $(NoWarn);IL1005;IL3000;IL3001;IL3002;IL3003
+ $(NoWarn);IL1005;IL2105;IL3000;IL3001;IL3002;IL3003
partial
true
true
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs
index 11fff9e657a232..c61bd273a0f6fd 100644
--- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
@@ -70,7 +71,7 @@ internal void MarkTypeSystemEntity(in MessageOrigin origin, TypeSystemEntity ent
MarkEvent(origin, @event, reason);
break;
// case InterfaceImplementation
- // Nothing to do currently as Native AOT will presere all interfaces on a preserved type
+ // Nothing to do currently as Native AOT will preserve all interfaces on a preserved type
}
}
@@ -78,19 +79,26 @@ internal bool TryResolveTypeNameAndMark(string typeName, in DiagnosticContext di
{
ModuleDesc? callingModule = ((diagnosticContext.Origin.MemberDefinition as MethodDesc)?.OwningType as MetadataType)?.Module;
- // NativeAOT doesn't have a fully capable type name resolver yet
- // Once this is implemented don't forget to wire up marking of type forwards which are used in generic parameters
- if (!DependencyAnalysis.ReflectionMethodBodyScanner.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context, out TypeDesc foundType, out ModuleDesc referenceModule))
+ List referencedModules = new();
+ TypeDesc foundType = System.Reflection.TypeNameParser.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context,
+ referencedModules, out bool typeWasNotFoundInAssemblyNorBaseLibrary);
+ if (foundType == null)
{
+ if (needsAssemblyName && typeWasNotFoundInAssemblyNorBaseLibrary)
+ diagnosticContext.AddDiagnostic(DiagnosticId.TypeWasNotFoundInAssemblyNorBaseLibrary, typeName);
+
type = default;
return false;
}
if (_enabled)
{
- // Also add module metadata in case this reference was through a type forward
- if (Factory.MetadataManager.CanGenerateMetadata(referenceModule.GetGlobalModuleType()))
- _dependencies.Add(Factory.ModuleMetadata(referenceModule), reason);
+ foreach (ModuleDesc referencedModule in referencedModules)
+ {
+ // Also add module metadata in case this reference was through a type forward
+ if (Factory.MetadataManager.CanGenerateMetadata(referencedModule.GetGlobalModuleType()))
+ _dependencies.Add(Factory.ModuleMetadata(referencedModule), reason);
+ }
MarkType(diagnosticContext.Origin, foundType, reason);
}
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs
deleted file mode 100644
index 44277568a5fec8..00000000000000
--- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionMethodBodyScanner.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using Internal.TypeSystem;
-
-using AssemblyName = System.Reflection.AssemblyName;
-using StringBuilder = System.Text.StringBuilder;
-
-namespace ILCompiler.DependencyAnalysis
-{
- internal static class ReflectionMethodBodyScanner
- {
- public static bool ResolveType(string name, ModuleDesc callingModule, TypeSystemContext context, out TypeDesc type, out ModuleDesc referenceModule)
- {
- // This can do enough resolution to resolve "Foo" or "Foo, Assembly, PublicKeyToken=...".
- // The reflection resolution rules are complicated. This is only needed for a heuristic,
- // not for correctness, so this shortcut is okay.
-
- type = null;
- int i = 0;
-
- // Consume type name part
- StringBuilder typeName = new StringBuilder();
- StringBuilder typeNamespace = new StringBuilder();
- string containingTypeName = null;
- while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '_' || name[i] == '`' || name[i] == '+'))
- {
- if (name[i] == '.')
- {
- if (typeNamespace.Length > 0)
- typeNamespace.Append('.');
- typeNamespace.Append(typeName);
- typeName.Clear();
- }
- else if (name[i] == '+')
- {
- containingTypeName = typeName.ToString();
- typeName.Clear();
- }
- else
- {
- typeName.Append(name[i]);
- }
- i++;
- }
-
- string nestedTypeName = null;
- if (containingTypeName != null)
- {
- nestedTypeName = typeName.ToString();
- typeName = new StringBuilder(containingTypeName);
- }
-
- // Consume any comma or white space
- while (i < name.Length && (name[i] == ' ' || name[i] == ','))
- {
- i++;
- }
-
- // Consume assembly name
- StringBuilder assemblyName = new StringBuilder();
- while (i < name.Length && (char.IsLetterOrDigit(name[i]) || name[i] == '.' || name[i] == '_'))
- {
- assemblyName.Append(name[i]);
- i++;
- }
-
- // If the name was assembly-qualified, resolve the assembly
- // If it wasn't qualified, we resolve in the calling assembly
-
- referenceModule = callingModule;
- if (assemblyName.Length > 0)
- {
- referenceModule = context.ResolveAssembly(new AssemblyName(assemblyName.ToString()), false);
- }
-
- if (referenceModule == null)
- return false;
-
- // Resolve type in the assembly
- MetadataType mdType = referenceModule.GetType(typeNamespace.ToString(), typeName.ToString(), throwIfNotFound: false);
- if (mdType != null && nestedTypeName != null)
- mdType = mdType.GetNestedType(nestedTypeName);
-
- // If it didn't resolve and wasn't assembly-qualified, we also try core library
- if (mdType == null && assemblyName.Length == 0)
- {
- referenceModule = context.SystemModule;
- mdType = referenceModule.GetType(typeNamespace.ToString(), typeName.ToString(), throwIfNotFound: false);
- if (mdType != null && nestedTypeName != null)
- mdType = mdType.GetNestedType(nestedTypeName);
- }
-
- type = mdType;
-
- return type != null;
- }
- }
-}
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeNameParser.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeNameParser.cs
new file mode 100644
index 00000000000000..b41b0aac06b016
--- /dev/null
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeNameParser.cs
@@ -0,0 +1,151 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+
+using Internal.TypeSystem;
+
+namespace System.Reflection
+{
+ internal unsafe ref partial struct TypeNameParser
+ {
+ private TypeSystemContext _context;
+ private ModuleDesc _callingModule;
+ private List _referencedModules;
+ private bool _typeWasNotFoundInAssemblyNorBaseLibrary;
+
+ public static TypeDesc ResolveType(string name, ModuleDesc callingModule,
+ TypeSystemContext context, List referencedModules, out bool typeWasNotFoundInAssemblyNorBaseLibrary)
+ {
+ var parser = new System.Reflection.TypeNameParser(name)
+ {
+ _context = context,
+ _callingModule = callingModule,
+ _referencedModules = referencedModules
+ };
+
+ TypeDesc result = parser.Parse()?.Value;
+
+ typeWasNotFoundInAssemblyNorBaseLibrary = parser._typeWasNotFoundInAssemblyNorBaseLibrary;
+ return result;
+ }
+
+ private sealed class Type
+ {
+ public Type(TypeDesc type) => Value = type;
+ public TypeDesc Value { get; }
+
+ public Type MakeArrayType() => new Type(Value.MakeArrayType());
+ public Type MakeArrayType(int rank) => new Type(Value.MakeArrayType(rank));
+ public Type MakePointerType() => new Type(Value.MakePointerType());
+ public Type MakeByRefType() => new Type(Value.MakeByRefType());
+
+ public Type MakeGenericType(Type[] typeArguments)
+ {
+ TypeDesc[] instantiation = new TypeDesc[typeArguments.Length];
+ for (int i = 0; i < typeArguments.Length; i++)
+ instantiation[i] = typeArguments[i].Value;
+ return new Type(((MetadataType)Value).MakeInstantiatedType(instantiation));
+ }
+ }
+
+ private static bool CheckTopLevelAssemblyQualifiedName() => true;
+
+ private Type GetType(string typeName, ReadOnlySpan nestedTypeNames, string assemblyNameIfAny)
+ {
+ ModuleDesc module;
+
+ if (assemblyNameIfAny != null)
+ {
+ module = (TryParseAssemblyName(assemblyNameIfAny) is AssemblyName an) ?
+ _context.ResolveAssembly(an, throwIfNotFound: false) : null;
+ }
+ else
+ {
+ module = _callingModule;
+ }
+
+ Type type;
+
+ if (module != null)
+ {
+ type = GetTypeCore(module, typeName, nestedTypeNames);
+ if (type != null)
+ {
+ _referencedModules?.Add(module);
+ return type;
+ }
+ }
+
+ // If it didn't resolve and wasn't assembly-qualified, we also try core library
+ if (assemblyNameIfAny == null)
+ {
+ type = GetTypeCore(_context.SystemModule, typeName, nestedTypeNames);
+ if (type != null)
+ {
+ _referencedModules?.Add(_context.SystemModule);
+ return type;
+ }
+
+ _typeWasNotFoundInAssemblyNorBaseLibrary = true;
+ }
+
+ return null;
+ }
+
+ private static AssemblyName TryParseAssemblyName(string assemblyName)
+ {
+ try
+ {
+ return new AssemblyName(assemblyName);
+ }
+ catch (FileLoadException)
+ {
+ return null;
+ }
+ catch (ArgumentException)
+ {
+ return null;
+ }
+ }
+
+ private static Type GetTypeCore(ModuleDesc module, string typeName, ReadOnlySpan nestedTypeNames)
+ {
+ string typeNamespace, name;
+
+ int separator = typeName.LastIndexOf('.');
+ if (separator <= 0)
+ {
+ typeNamespace = "";
+ name = typeName;
+ }
+ else
+ {
+ if (typeName[separator - 1] == '.')
+ separator--;
+ typeNamespace = typeName.Substring(0, separator);
+ name = typeName.Substring(separator + 1);
+ }
+
+ MetadataType type = module.GetType(typeNamespace, name, throwIfNotFound: false);
+ if (type == null)
+ return null;
+
+ for (int i = 0; i < nestedTypeNames.Length; i++)
+ {
+ type = type.GetNestedType(nestedTypeNames[i]);
+ if (type == null)
+ return null;
+ }
+
+ return new Type(type);
+ }
+
+ private static void ParseError()
+ {
+ }
+ }
+}
diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
index 56390d65ecbe33..4578500923ef8e 100644
--- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
+++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
@@ -30,6 +30,12 @@
+
+ TypeNameParser.cs
+
+
+ ValueStringBuilder.cs
+
IL\DelegateInfo.cs
@@ -406,7 +412,6 @@
-
@@ -416,6 +421,7 @@
+
diff --git a/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs b/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs
index ff5a237c3f3ae3..5fe2b8ce402382 100644
--- a/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs
+++ b/src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs
@@ -83,29 +83,22 @@ internal static partial class X509ResourceClient
// the latter can't in turn have an explicit dependency on the former.
// Get the relevant types needed.
- Type? socketsHttpHandlerType = Type.GetType("System.Net.Http.SocketsHttpHandler, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpMessageHandlerType = Type.GetType("System.Net.Http.HttpMessageHandler, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpClientType = Type.GetType("System.Net.Http.HttpClient, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpRequestMessageType = Type.GetType("System.Net.Http.HttpRequestMessage, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpResponseMessageType = Type.GetType("System.Net.Http.HttpResponseMessage, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpResponseHeadersType = Type.GetType("System.Net.Http.Headers.HttpResponseHeaders, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
- Type? httpContentType = Type.GetType("System.Net.Http.HttpContent, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", throwOnError: false);
+ Type? socketsHttpHandlerType = Type.GetType("System.Net.Http.SocketsHttpHandler, System.Net.Http", throwOnError: false);
+ Type? httpMessageHandlerType = Type.GetType("System.Net.Http.HttpMessageHandler, System.Net.Http", throwOnError: false);
+ Type? httpClientType = Type.GetType("System.Net.Http.HttpClient, System.Net.Http", throwOnError: false);
+ Type? httpRequestMessageType = Type.GetType("System.Net.Http.HttpRequestMessage, System.Net.Http", throwOnError: false);
+ Type? httpResponseMessageType = Type.GetType("System.Net.Http.HttpResponseMessage, System.Net.Http", throwOnError: false);
+ Type? httpResponseHeadersType = Type.GetType("System.Net.Http.Headers.HttpResponseHeaders, System.Net.Http", throwOnError: false);
+ Type? httpContentType = Type.GetType("System.Net.Http.HttpContent, System.Net.Http", throwOnError: false);
+ Type? taskOfHttpResponseMessageType = Type.GetType("System.Threading.Tasks.Task`1[[System.Net.Http.HttpResponseMessage, System.Net.Http]], System.Runtime", throwOnError: false);
if (socketsHttpHandlerType == null || httpMessageHandlerType == null || httpClientType == null || httpRequestMessageType == null ||
- httpResponseMessageType == null || httpResponseHeadersType == null || httpContentType == null)
+ httpResponseMessageType == null || httpResponseHeadersType == null || httpContentType == null || taskOfHttpResponseMessageType == null)
{
Debug.Fail("Unable to load required type.");
return null;
}
- // Workaround until https://github.com/dotnet/runtime/issues/72833 is fixed
- [UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
- Justification = "The type HttpResponseMessage is a reference type")]
- [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
- static Type GetTaskOfHttpResponseMessageType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type? httpResponseMessageType) => typeof(Task<>).MakeGenericType(httpResponseMessageType!);
-
- Type taskOfHttpResponseMessageType = GetTaskOfHttpResponseMessageType(httpResponseMessageType);
-
// Get the methods on those types.
ConstructorInfo? socketsHttpHandlerCtor = socketsHttpHandlerType.GetConstructor(Type.EmptyTypes);
PropertyInfo? pooledConnectionIdleTimeoutProp = socketsHttpHandlerType.GetProperty("PooledConnectionIdleTimeout");
diff --git a/src/libraries/Common/src/System/Reflection/TypeNameParser.cs b/src/libraries/Common/src/System/Reflection/TypeNameParser.cs
index 9dcdf11079d8d9..d7bb0e8fb2b0b3 100644
--- a/src/libraries/Common/src/System/Reflection/TypeNameParser.cs
+++ b/src/libraries/Common/src/System/Reflection/TypeNameParser.cs
@@ -6,6 +6,8 @@
using System.Runtime.InteropServices;
using System.Text;
+#nullable enable
+
namespace System.Reflection
{
//
@@ -622,10 +624,12 @@ private static string EscapeTypeName(string typeName, ReadOnlySpan neste
return fullName;
}
+#if SYSTEM_PRIVATE_CORELIB
private void ParseError()
{
if (_throwOnError)
throw new ArgumentException(SR.Arg_ArgumentException, $"typeName@{_errorIndex}");
}
+#endif
}
}
diff --git a/src/libraries/Common/src/System/Text/ValueStringBuilder.cs b/src/libraries/Common/src/System/Text/ValueStringBuilder.cs
index b89d7e01caf22e..966f1c8cfc5edc 100644
--- a/src/libraries/Common/src/System/Text/ValueStringBuilder.cs
+++ b/src/libraries/Common/src/System/Text/ValueStringBuilder.cs
@@ -6,6 +6,8 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+#nullable enable
+
namespace System.Text
{
internal ref partial struct ValueStringBuilder
diff --git a/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoInvokeArrayTests.cs b/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoInvokeArrayTests.cs
index f67acdae97ad55..73d0e60ea23217 100644
--- a/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoInvokeArrayTests.cs
+++ b/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoInvokeArrayTests.cs
@@ -238,10 +238,10 @@ public void Invoke_2DArrayConstructor()
[ActiveIssue("https://github.com/mono/mono/issues/15318", TestRuntimes.Mono)]
public void Invoke_LargeDimensionalArrayConstructor()
{
- Type type = Type.GetType("System.Type[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]");
+ Type type = Type.GetType($"System.Type[{new string(',', 31)}]");
ConstructorInfo[] cia = TypeExtensions.GetConstructors(type);
Assert.Equal(2, cia.Length);
- Assert.Throws(() => Type.GetType("System.Type[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]"));
+ Assert.Throws(() => Type.GetType($"System.Type[{new string(',', 42)}]"));
}
[Fact]
diff --git a/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoTests.cs b/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoTests.cs
index 5ce72bed4c7512..ae8096671cf05c 100644
--- a/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoTests.cs
+++ b/src/libraries/System.Reflection.TypeExtensions/tests/ConstructorInfo/ConstructorInfoTests.cs
@@ -82,6 +82,10 @@ public void TypeConstructorName_ReturnsExpected()
[InlineData(typeof(string), new Type[] { typeof(char), typeof(int) })]
public void Properties(Type type, Type[] typeParameters)
{
+ // Trick trimming into keeping the string ctor
+ if (string.Empty.Length > 0)
+ typeof(string).GetConstructors();
+
ConstructorInfo constructor = TypeExtensions.GetConstructor(type, typeParameters);
Assert.Equal(type, constructor.DeclaringType);
diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ApplyTypeAnnotations.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ApplyTypeAnnotations.cs
index b7fcb3d7b0f761..6969289fe004a4 100644
--- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ApplyTypeAnnotations.cs
+++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ApplyTypeAnnotations.cs
@@ -128,9 +128,7 @@ private static void RequireCombinationOnString (
{
}
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT doesn't implement full type name parser yet
- [Kept (By = Tool.Trimmer)]
+ [Kept]
class FromStringConstantWithGenericInner
{
}
@@ -143,9 +141,7 @@ class FromStringConstantWithGeneric
public T GetValue () { return default (T); }
}
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT doesn't implement full type name parser yet
- [Kept (By = Tool.Trimmer)]
+ [Kept]
class FromStringConstantWithGenericInnerInner
{
[Kept (By = Tool.Trimmer)]
@@ -156,7 +152,7 @@ public void Method ()
int unusedField;
}
- [Kept (By = Tool.Trimmer)]
+ [Kept]
class FromStringConstantWithGenericInnerOne<
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute), By = Tool.Trimmer)]
@@ -164,9 +160,7 @@ class FromStringConstantWithGenericInnerOne<
{
}
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT doesn't implement full type name parser yet
- [Kept (By = Tool.Trimmer)]
+ [Kept]
class FromStringConstantWithGenericInnerTwo
{
void UnusedMethod ()
@@ -174,22 +168,14 @@ void UnusedMethod ()
}
}
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT doesn't implement full type name parser yet
- [Kept (By = Tool.Trimmer)]
+ [Kept]
class FromStringConstantWitGenericInnerMultiDimArray
{
}
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT actually preserves this, but for a slightly wrong reason - it completely ignores the array notations
[Kept]
- [KeptMember (".ctor()", By = Tool.NativeAot)]
class FromStringConstantWithMultiDimArray
{
- // https://github.com/dotnet/runtime/issues/72833
- // NativeAOT actually preserves this, but for a slightly wrong reason - it completely ignores the array notations
- [Kept (By = Tool.NativeAot)]
public void UnusedMethod () { }
}
@@ -200,6 +186,8 @@ class FromStringConstantWithGenericTwoParameters
}
[Kept]
+ [KeptAttributeAttribute(typeof(UnconditionalSuppressMessageAttribute))]
+ [UnconditionalSuppressMessage("test", "IL3050", Justification = "The test applies DAM on System.Array, which contains CreateInstance method which has RDC on it.")]
static void TestFromStringConstantWithGeneric ()
{
RequireCombinationOnString ("Mono.Linker.Tests.Cases.DataFlow.ApplyTypeAnnotations+FromStringConstantWithGeneric`1[[Mono.Linker.Tests.Cases.DataFlow.ApplyTypeAnnotations+FromStringConstantWithGenericInner]]");
diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
index 933d0b19f3fa29..6207567c263bce 100644
--- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
+++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs
@@ -60,11 +60,10 @@ static void TestConstructors ()
RequireNothing (type);
}
- // NativeAOT doesn't implement this yet: https://github.com/dotnet/runtime/issues/72833
[ExpectedWarning ("IL2105",
"Type 'System.Invalid.TypeName' was not found in the caller assembly nor in the base library. " +
"Type name strings used for dynamically accessing a type should be assembly qualified.",
- ProducedBy = Tool.Trimmer)]
+ ProducedBy = Tool.Trimmer | Tool.NativeAot)]
static void TestUnqualifiedTypeNameWarns ()
{
RequirePublicConstructors ("System.Invalid.TypeName");
diff --git a/src/tools/illink/test/Mono.Linker.Tests/Tests/GetDisplayNameTests.cs b/src/tools/illink/test/Mono.Linker.Tests/Tests/GetDisplayNameTests.cs
index 1cdf6abf1ad9bb..7e4c40e4f35a3b 100644
--- a/src/tools/illink/test/Mono.Linker.Tests/Tests/GetDisplayNameTests.cs
+++ b/src/tools/illink/test/Mono.Linker.Tests/Tests/GetDisplayNameTests.cs
@@ -191,18 +191,18 @@ public class NestedGenericClassMultipleParameters
}
[DisplayName ("Mono.Linker.Tests.GetDisplayNameTests.MethodWithGenericTypeArgument(IList>)")]
- public static void MethodWithGenericTypeArgument (IList> p)
+ public static unsafe void MethodWithGenericTypeArgument (IList> p)
{
}
[DisplayName ("Mono.Linker.Tests.GetDisplayNameTests.MethodWithGenericTypeArguments(GetDisplayNameTests.GenericClassMultipleParameters)")]
- public static void MethodWithGenericTypeArguments (GenericClassMultipleParameters p)
+ public static unsafe void MethodWithGenericTypeArguments (GenericClassMultipleParameters p)
{
}
[DisplayName ("Mono.Linker.Tests.GetDisplayNameTests.MethodWithNestedGenericTypeArguments" +
"(GetDisplayNameTests.GenericClassMultipleParameters.NestedGenericClassMultipleParameters)")]
- public static void MethodWithNestedGenericTypeArguments (GenericClassMultipleParameters.NestedGenericClassMultipleParameters p)
+ public static unsafe void MethodWithNestedGenericTypeArguments (GenericClassMultipleParameters.NestedGenericClassMultipleParameters p)
{
}