简体   繁体   中英

ILSpy - How to modify the decompiled code to look like the Github source code?

My goal is to decompile a C# libarabry and compare it to the source code of the same library in Github. I would like to research whether the given source code (after decompiling) is equal to the source code in Github.

I've used ILSpy to try to achieve this goal. I've download and decomplied the libarary "FluentScheduler" (v 5.5.1) - Nuget link: https://www.nuget.org/packages/FluentScheduler/

And I compared the given source code (in my case, I took MonthUnit.cs file) to the same one on Github (same version as well).

Github link:

I noticed the code is pretty similar, but not exactly, for example:

我们可以看到ILSpy生成的源代码和Github上的源代码的区别

Is there any way to play with ILSpy conf to remove unnecessary parenthesis? one-liners? make it similar to the Github source code with an exact match? If not, should I use another tool that will decompile the file and result in the same result as Github?

Thanks a lot!

Is there any way to play with ILSpy conf to remove unnecessary parenthesis? one-liners? make it similar to the Github source code with an exact match?

No, there is not. Things that are not neccessary (for example white space formatting or things that did not need to be in the final assembly like redundant statements) will not be there when you decompile it.

What you could do is use the same formatter that aggressively enforces a specific style (doesn't really matter which) on both the source code and the decompiled result. That should bring you closer. But it will likely not be 100% perfect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM