ref struct IntRefWrapper {
public ref int MyRef;
}
static IntRefWrapper DoSomethingBad() {
var x = 123;
var refWrapper = new IntRefWrapper { MyRef = ref x };
return refWrapper; // Won't compile-- compiler knows we're leaking a reference to 'x'.
}