ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

New added support for pattern-based fixed statement didn't handle GetPinnableReference in reference type.

Open yyjdelete opened this issue 4 years ago • 0 comments

It can be tested with string in netcoreapp3.0+ or an custom reference type with GetPinnableReference

    public unsafe void M(void* p) { }

    //for netcoreapp3.0+ only
    public unsafe void TestString() {
        var c = "";//don't inline this
        fixed (char* p = c)
        {
            M(p);
        }
    }

    //Or add an custom type for it
    public class TestClass
    {
        char c;
        public ref char GetPinnableReference()
        {
            return ref c;
        }
    }
    public unsafe void TestCustom() {
        var c = new TestClass();
        fixed (char* p = c)
        {
            M(p);
        }
    }

yyjdelete avatar Dec 08 '19 03:12 yyjdelete