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 1b195c09d36ee9..c8e3623fff1d22 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs @@ -71,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 } } @@ -83,6 +83,9 @@ internal bool TryResolveTypeNameAndMark(string typeName, in DiagnosticContext di TypeDesc foundType = System.Reflection.TypeNameParser.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context, referencedModules); if (foundType == null) { + if (needsAssemblyName) + diagnosticContext.AddDiagnostic(DiagnosticId.TypeWasNotFoundInAssemblyNorBaseLibrary, typeName); + type = default; return false; } 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");