dnSpy - How to fix BackingField in getter and setter methods

You may meet BackingFields in dnSpy but you don’t know what it is and how to fix?
BackingFields are generated by compiler because they use auto Properties like this

public string Type { get; set; }

I think because some devs are lazy... I don’t know lol

This is how it looks like when editing getter. BackingField is red

And when you compile, you get the following errors

But it’s easy to fix, edit getter add a new field and return it with your field and compile. In this case, I add public bool isGlobal for IsGlobal

Edit setter, edit to (Type) = value; and compile

Now you can mod it like adding if-else statement for mod menu


Popular Posts

VMOS Pro Global/CN Custom ROMs - Android 5.1.1 and 7.1.2, Root + Xposed

VMOS 1.0.49 MOD APK | Video ads bypassed | Pre-rooted ROM