Since .NET 4.5 (2012), some new extension methods show up, from System.Reflection.RuntimeReflectionExtensions
class. However, the new methods do not seem to give us anything new. An example:
static void Main()
{
var prop1 = typeof(string).GetProperty("Length");
var prop2 = typeof(string).GetRuntimeProperty("Length"); // extension, needs: using System.Reflection;
Console.WriteLine(prop1 == prop2);
Action a = Main;
var meth1 = a.Method;
var meth2 = a.GetMethodInfo(); // extension, needs: using System.Reflection;
Console.WriteLine(meth1 == meth2);
}
This writes True
twice.
(The ==
operator is overloaded here, but even checking for reference equality with (object)prop1 == (object)prop2
and (object)meth1 == (object)meth2
gives True
).
So what is the purpose of these new publicly visible methods? Clearly I must be overlooking or misunderstanding something.