Skip to content

[TrimmableTypeMap] Revisit usage of startup hooks to initialize the type map #11196

@simonrozsival

Description

@simonrozsival

In #11181 we started using .NET Startup Hooks to intialize the global typemap, but I only now realized startup hooks don't work with Native AOT. We need to switch to some other mechanism which doens't involve Assembly.Load and other not supported APIs.

I wonder if we could (ab)use [ModuleInitializer] + force load the typemap assembly via TypeMapping. GetOrCreateExternalTypeMapping<Java.Lang.Object>() even though the result won't be captured?

But maybe even more simple solution would work. I wonder if we could have a ref assembly for the typemap which we would pass to CSC and then the generated assembly, which we generate between CSC and trimming, would have the same API surface, but it would be all generated. This way, there could be a public class with a public static method which we would call public static ITypeMapWithAliasing LoadTypeMap().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions