dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.25k stars 4.73k forks source link

Add linker test coverage for GetUninitializedObject #37739

Open MichalStrehovsky opened 4 years ago

MichalStrehovsky commented 4 years ago

The annotation for GetUninitializedObject is going to rely on the fact that linker treats all valuetypes as implicitly boxed. We need a test that starts failing if this is ever broken.

interface IFoo { int Frob(); }

struct Foo : IFoo
{
    int IFoo.Frob() => 100;
}

static int Main()
{
    var o = (IFoo)RuntimeHelpers.GetUninitializedObject(typeof(Foo));
    return o.Frob()
}
joperezr commented 4 years ago

@MichalStrehovsky this should be easy to test now with the Trimming Tests infrastructure. Let me know if you need any help with using it or writing this test.

eerhardt commented 4 years ago

This isn't needed to ship 5.0, so moving to 6.0.