Skip to content

Better reflection type name parser for the AOT compiler #72833

@MichalStrehovsky

Description

@MichalStrehovsky

We should refactor the type name parser used by the reflection stack to be reusable from the compiler. IL Linker already uses that parser, but we don't want another fork - we want a way to compile the exact same file, potentially with ifdefs if needed for both runtime reflection stack and the compiler.

// 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 (!ILCompiler.DependencyAnalysis.ReflectionMethodBodyScanner.ResolveType(typeName, callingModule, diagnosticContext.Origin.MemberDefinition!.Context, out TypeDesc foundType, out ModuleDesc referenceModule))
{
type = default;
return false;
}

Success criteria:

Type? t = Type.GetType("System.Collections.Generic.List`1[[System.DayOfWeek, System.Runtime]], System.Collections");
Console.WriteLine(t != null);

Should print non-null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions