Home > Back-end >  ILSpy decompile a delegate
ILSpy decompile a delegate

Time:12-18

ILSpy can decompile assemblies. Can it decompile a delegate? I would imagine a CSharpDecompiler constructor overload accepting a Func or an Action as an argument instead of a "string fileName". Is it technically feasible, are there any future plans to support this? Any suggested work-arounds?

Example of what I had in mind....

Action<int> myAction = i =>
{
    // body to be decompiled
};
var decompiler = new CSharpDecompiler(myAction, new DecompilerSettings());
decompiler.DecompileAsString();

CodePudding user response:

An official ILSpy member has answered in the project's discussion section:

"It's not possible, because the decompiler requires a full PE image containing IL code and .NET metadata tables"

https://github.com/icsharpcode/ILSpy/discussions/2581

  • Related