I have a program which no longer has support and does not have source code available. So I decompiled it in order to make fixes, because the fixes required are substantial I decided to use dnSpy to export the decompiled code as a project, however there are some errors. in particular I see variable names that look like <>f__switch$map1
where the can be any number in place of 1. I tried replacing them all with a more reasonable name and removing the <> but it doesn't appear to actually be declared anywhere? how can I fix these compiler errors in the output of dnSpy.
Asked
Active
Viewed 2,046 times
0

david warford
- 43
- 5
-
1They're compiler generated names, deliberately invalid C# identifiers. You should find the pattern of where the identifier is used and match it up with coding patterns the require compiler generated code - e.g. anonymous types, async/iterator methods, etc. – Damien_The_Unbeliever Jun 30 '21 at 06:34
-
On DnSpy settings -> Decompiler, the first few settings starting "Decompile..." should be checked – Charlieface Jun 30 '21 at 11:10
-
@Charlieface That doesn't seem to fix the problem. I tried both unchecked and checked and reopening and closing the assembly and dnspy. – david warford Jun 30 '21 at 23:52
-
@Damien_The_Unbeliever Is their any further reading on this? I'm having a hard time trying to figure out how i would even begin to match these up. – david warford Jun 30 '21 at 23:53
1 Answers
0
So, in my case I was simply able to rename everything and then define it elsewhere, this worked and the program was able to compile.

david warford
- 43
- 5