Reputation: 828
My team is in the midst of upgrading an application from targeting .NET 4.0 to 4.6.2. Yes, late to the party(ies), but better late than never.
In our application, there is an extension method that returns the MethodInfo of the returned method from an expression. In other words, if we have:
public class Foo
{
public void DoSomething() { }
}
and then had an expression
Expression<Func<Foo, Action>> = f => f.DoSomething;
then our extension method would return the MethodInfo of the method DoSomething()
The code worked great in .NET 4.0, but doesn't work in .NET 4.6.2. I've since changed the code to work, but my question is does anyone know where in the release notes from .NET 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1 and 4.6.2 would this be documented? I've read and searched through them multiple times without anything.
These are the release notes I've been looking through:
When you compare the local variables when debugging, you can see how the method bodies of the expressions differ between .NET 4.0 and 4.6.2:
I'm aware that .NET introduced a method that does this; I'm interested in where the change is documented as opposed to the solution (which I already have).
Thanks in advance for our help!
Upvotes: 1
Views: 554
Reputation: 113332
The MethodInfo.CreateDelegate()
method that the compiler is using instead of Delegate.CreateDelegate()
was introduced with .NET 4.5
The documented behaviour of the the C# expression
Expression<Func<Foo, Action>> e = f => f.DoSomething;
is that it will create an expression representing a Func<Foo, Action>
that if compiled and invoked will take a Foo
and return an Action
that calls .DoSomething()
on that Foo
. This behaviour has not changed. As there was no change to the documented behaviour, there's quite likely no documentation of the change. (Such changes are documented if they're known to cause issues, but not always).
Upvotes: 4