Obfuscating variable names c#

As an example I would like to turn “int x” into “int y” in the build automatically. I couldn’t find much info on how to do this, I couldn’t find a free obfuscator that does this either though I would rather do it myself. I am not doing this against piracy and I know people will still figure out what the variable does but I simply don’t want them to know what I named them. I am hoping there is a relatively straightforward way I missed, if anyone could point me to the right direction it would be great. Thanks.

The way ive always done this(and afaik this is the only way to do it unless you use a custom compiler) is to write a program using the “Mono.Cecil” dll’s to load your compiled assembly(named Assembly-CSharp.dll) and then go through each variable of the assembly using a for loop and change the variables name. Then save the assembly as a new assembly and use that new assembly as your games main assembly(as in replace the original Assembly-CSharp.dll with the new one you made with your program) and then youre done!


This will take a lot of reading to figure out though so its not straightforward by any means. But just google “Mono.Cecil” and read through the programming docs and maybe even look at some tutorials.