DelegateDecompiler
DelegateDecompiler copied to clipboard
Assignment expression not converted properly
class MyClass
{
public string MyProperty {get; set;}
}
Func<MyClass, string> func = v => v.MyProperty = "I wish to assign this value";
LambdaExpression decompiled = DecompileExtensions.Decompile(func);
Expected body: Binary expression (node type Assign) with Left = {v.MyProperty}, Right = Constant("I wish to assign this value")
Actual body:
Block expression containing two expressions:
- Binary expression (node type Assign) with Left = {v.MyProperty}, Right = Constant("I wish to assign this value")
- constant("I wish to assign this value")
The decompiled expression is correct, but not optimal. There is no canonical way to write Func<MyClass, string> func = v => v.MyProperty = "I wish to assign this value"; as an expression, unfortunately, because it is not permitted by the language.
I would say that this would fall into optimization.