Description
Note
Related to dotnet/csharplang#356, but just for ILC support to restrict scope.
As part of the sidecar .dll for CsWinRT 3.0 (see tracking issue), we'll be generating a lookup table for all IDIC implementations for the application domain. This has to be in the sidecar .dll because it allows us to have a single entry point from which to gather all IDIC implementations across all referenced assemblies, as well as all generic IDIC implementations, which necessarily have to be generated as part of the sidecar .dll, to properly support all the other AOT optimizations we're planning to have (eg. vtable folding).
We'll be emitting something similar to this (made up names for now):
public static class DynamicInterfaceCastableLookup
{
public static Type? GetInterfaceImplementation(Type type)
{
if (type == typeof(IFoo)) return typeof(IFooImpl);
if (type == typeof(IBar)) return typeof(IBarImpl);
if (type == typeof(IBaz)) return typeof(IBazImpl);
// ...
return null;
}
}
We expect this to end up having several hundred types (if not thousands), since it includes:
- All IDIC interfaces across all referenced projections (including the Windows SDK projections)
- All constructed IDIC interfaces for discovered generic instantiations
In order for this to be practical, we'd need some guarantees from ILC:
- All key-value pairs in this lookup method should be fully trimmable
- ILC should be able to pre-initialize this into a fast lookup in the FOH
Note that because this is in the sidecar .dll, we can generate any IL pattern we need.
So it's completely fine for us to emit code with whatever pattern required to make ILC's life simpler.
@MichalStrehovsky mentioned the first point (trimmability) should already be there. So this issue is to track pre-initialization.
Is there a way to special case some pattern we can rely on in our sidecar .dll, to enable pre-initialization?
Metadata
Metadata
Assignees
Type
Projects
Status