Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Template type loader interface dispatch dependency tracking #4860

Closed
MichalStrehovsky opened this issue Nov 2, 2017 · 0 comments
Closed
Labels
Milestone

Comments

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Nov 2, 2017

This will throw a MissingMetadataException because we never generated native layout for the IFoo<__Canon> interface, but the dispatch cell in Gen<__Canon>.DoFrob refers to it. We get away with this bug because normally something that implements this interface gets allocated with newobj. Not here.

I had some fix in mind, but I got pulled into other projects and don't have time to investigate size on disk impact. The fix is to make sure NativeLayoutInterfaceDispatchGenericDictionarySlotNode depends on the template for the interface type. We might want to pull that into the TemplateConstructableTypes helper?

This is the underlying issue for why the set of RD.XML workarounds from @sergiy-k in #4444 need to refer to specific instances of Microsoft.Extensions.Options.OptionsFactory[[shtik.ShtikOptions,shtik]] instead of just letting the type loader create the types at runtime.

interface IFoo<T>
{
    void Frob();
}

class Gen<T>
{
    public void DoFrob(IFoo<T> o)
    {
        if (o != null)
            o.Frob();
    }
}


internal class Program
{
    private static void Main(string[] args)
    {
        new Gen<object>().DoFrob(null);
        typeof(Gen<>).MakeGenericType(new[] { typeof(string) });
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant