Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The difference between ICSharpCode.Decompiler.dll and ILSPY decomplie #3168

Open
murmiris opened this issue Feb 27, 2024 · 0 comments
Open
Labels
Bug Decompiler The decompiler engine itself

Comments

@murmiris
Copy link

The C# output of "Save Code" in ILSPY and the C# output I generated using ICSharpCode.Decompiler.dll are different.

C# code generated from ILSPY can successfully list all namespaces in Roslyn, while C# output generated using ICSharpCode.Decompiler.dll can access very few namespaces in Roslyn.

At the same time, while the C# code generated from ILSPY can be displayed with correct colouring in Visual Studio, part of the C# code generated in ICSharpCode.Decompiler.dll can be coloured correctly, the other part is displayed as if it were text.

When the code generated from both systems is compared with winmerge, it can be seen that although the majority of the code is the same, there are parts that are different.

I am doing this on a Windows 10 machine.

Versions used:
ILSPY :
ILSpy version 8.2.0.7535
.NET version 6.0.26-servicing.23605.8+dc45e96840243b203b13e61952230e225d2aac52

ICSharpCode.Decompiler.dll :
File Version: 8.2.0.7535-95108c96
Product Version: 8.2.0.7535-95108c96

The code block that I generated the C# code using ICSharpCode.Decompiler.dll is as follows :

PEFile peFile = new PEFile(dll);

var resolver = new UniversalAssemblyResolver(dll, true, peFile.DetectTargetFrameworkId(), null, System.Reflection.PortableExecutable.PEStreamOptions.Default, System.Reflection.Metadata.MetadataReaderOptions.ApplyWindowsRuntimeProjections);

var decompilerSettings = new DecompilerSettings()
{
ParameterNullCheck = true,
QueryExpressions = true,
SeparateLocalVariableDeclarations = true
};

var decompiler = new CSharpDecompiler(peFile, resolver, decompilerSettings);

var csharpcode = decompiler.DecompileWholeModuleAsString();

@murmiris murmiris added Bug Decompiler The decompiler engine itself labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

No branches or pull requests

1 participant