.net Reflector decompiled C# code won't compile

后端 未结 1 1369
情歌与酒
情歌与酒 2020-12-12 05:24

I tried to decompile a C# console application and compile it again in Visual C# 2010, but there are many errors in the code. Here is an example:

 public stat         


        
相关标签:
1条回答
  • 2020-12-12 05:55

    There is no straight way to overcome this limitation. Compiler created IL from your source code and this IL may not contain information regarding your initial source code. For example when you write

    public string Property { get; set; }
    

    Compiler creates backing field (for example <Property >k__BackingField ) and names it using special symbols, that you can't use to name your field in the source code. You gave the example above, where reflector tried to deduce what compiler meant.

    I've used dotPeek (free decompiler by JetBrains) and it understand autoproperties, so you would see correct code in your example. But again - there might be cases, where dotPeek won't be able to get the initial source code.

    0 讨论(0)
提交回复
热议问题