| Author |
Message |
theperm
Joined: 02 Sep 2010 Posts: 2
|
Posted: Thu Sep 02, 2010 8:17 pm Post subject: convert delegates to lambdas |
|
|
| Can Reflector be made to disassemble delegates to Lambdas? |
|
| Back to top |
|
 |
Clive Tong
Joined: 04 Dec 2008 Posts: 281
|
Posted: Fri Sep 03, 2010 9:31 am Post subject: |
|
|
For a simple example like
| Code: |
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 lambda
| Code: |
Func<int, int> xx = x => x * 3;
|
|
|
| Back to top |
|
 |
theperm
Joined: 02 Sep 2010 Posts: 2
|
Posted: Fri Sep 03, 2010 10:54 am Post subject: |
|
|
| Thats strange, i have it set to 4.0 and all i can see are delegates. What gives? |
|
| Back to top |
|
 |
Clive Tong
Joined: 04 Dec 2008 Posts: 281
|
Posted: Fri Sep 03, 2010 1:47 pm Post subject: |
|
|
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 expression
| Code: |
static 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. |
|
| Back to top |
|
 |
Clive Tong
Joined: 04 Dec 2008 Posts: 281
|
Posted: Mon Nov 22, 2010 10:44 am Post subject: |
|
|
| This has now been fixed. The fix will be in the next EAP release. |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group