Can Reflector be made to disassemble delegates to Lambdas?
Comments
4 comments
-
For a simple example like
Func<int, int> xx = delegate(int x) { return x*3; };
if the View/Options/Disassembler/Optimization is set to .NET 2.0, you see the code as a delegate, but if you set it to .NET 3
.5 you see it as a lambdaFunc<int, int> xx = x => x * 3;
-
Thats strange, i have it set to 4.0 and all i can see are delegates. What gives?
-
You're found a bug, which affects assemblies compiled against the .NET 4 platform.
The code that decompiles a delegate as a lambda expression, has a guard which checks that the assembly containing the type references System.Query or System.Core.
Hence the following decompiles to a lambda expressionstatic void Main(string[] args) { Type foo = typeof (System.Linq.Enumerable); Func<int, int> xx = delegate(int x) { return x * 3; }; }
but commenting out the typeof line causes Reflector to always decompile to a delegate (as the assembly no longers references out of the assemblies mentioned above).
I've logged this as RP-760. -
This has now been fixed. The fix will be in the next EAP release.
Add comment
Please sign in to leave a comment.