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().
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.Loadand other not supported APIs.I wonder if we could (ab)use
[ModuleInitializer]+ force load the typemap assembly viaTypeMapping. 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().