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 - FREE Custom ROMs without VIP | GMS, ROOT, Xposed | Android 4.4.4, 5.1.1, 7.1.2, 9.0 ROMs

How to activate VMOS Assistant to run VMOS on Android 12 and above