ILSpy
ILSpy copied to clipboard
New added support for pattern-based fixed statement didn't handle GetPinnableReference in reference type.
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);
}
}