icsharpcode/ILSpy

Export C# code containing IL that can be re-assembled with InlineIL.Fody (https://github.com/ltrzesniewski/InlineIL.Fody)

Closed this issue · 4 comments

The first step to making a bytematching decomp... the second step is to gradually replace the IL code with C# code decompiled by hand so that the recompiled IL matches the original IL, just like how you make a matching decomp of a game by gradually replacing assembly code with C/C++ code.

While I'm sure this would be fun to code, I think it would be a lot of work, so I suppose the core team wouldn't be eager to add something so specific (but maybe I'm wrong).

Here are a couple issues I see with making something round-trippable and compilable, off the top of my head:

  • Symbol names which are illegal in C#, such as <PrivateImplementationDetails> - currently ILSpy exports this as _003CPrivateImplementationDetails_003E in C#
  • catch when (XXX) - InlineIL can't represent the XXX expression as IL code
  • Stuff such as .data directives, which ILSpy today marks as not supported in C#

Those are a few examples which make round-tripping difficult, and I'm sure there would be other surprises.

We did discuss this superficially - it is on the far, far edge feature-wise (after all, we are decompiling from IL to C#) and it kind of borders on what obfuscators do to IL code... where we also do not reverse the patterns (you'd have to apply a deobfuscator first).

I think most C# games don't obfuscate their code to ease modding.

This is something we do not intend to build, closing.