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

Template type loader interface dispatch dependency tracking #4860

@MichalStrehovsky

Description

@MichalStrehovsky

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) });
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions