https://github.com/stakx/delegatedecompiler
Simple .NET decompiler that turns compiled methods back into LINQ expression trees.
https://github.com/stakx/delegatedecompiler
decompilation dotnet expression-tree il intermediate-language linq
Last synced: 9 months ago
JSON representation
Simple .NET decompiler that turns compiled methods back into LINQ expression trees.
- Host: GitHub
- URL: https://github.com/stakx/delegatedecompiler
- Owner: stakx
- License: mit
- Created: 2017-07-24T20:13:02.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2017-07-25T21:00:26.000Z (over 8 years ago)
- Last Synced: 2025-04-04T18:52:05.474Z (9 months ago)
- Topics: decompilation, dotnet, expression-tree, il, intermediate-language, linq
- Language: C#
- Homepage:
- Size: 22.5 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# DelegateDecompiler #
Proof-of-concept utility library that decompiles delegates (`Action`, `Func`, etc.) into LINQ expression trees (`Expression`, `Expression>`, etc.).
### Short demonstration ###
```csharp
interface IFoo
{
IBar Bar { get; }
}
interface IBar
{
string Property { get; set; }
}
// This is the lambda we're going to decompile from IL:
int message = "Hello world.";
Action action = foo => foo.Bar.Property = message;
// Decompile it into an expression tree:
Expression expr = action.Decompile();
// Replace property accessor methods with more semantic property expressions:
expr = new SpecialNameMethodReplacer().Visit(expr);
// Evaluate captured variables to their value:
expr = new PartialEvaluator().Visit(expr);
// Show the result:
Console.WriteLine(expr); // => foo => (foo.Bar.Property = "Hello world!")
```
### Limitations ###
* Multi-statement methods are not yet supported.
* Conditionals, branches, and exception handling are not supported (and probably won't be).
* Currently, this library only targets the full .NET Framework. (Targeting .NET Standard 2.0 should be possible with only a few minor modifications. Earlier .NET Standard versions likely cannot be supported due to missing APIs.)