I looked an the MethodCallExpression
object for extension method and found that
- the
Object
property isnull
and - the
Arguments[0].NodeType
isMemberAccess
are those two parameters enough to say that this method call is an extension method?
Here's some test code (updated):
as @Rob suggested it might be just a static method and indeed there is no differce between those two calls
void Main()
{
var abc = "abc";
Bar(() => abc.Foo());
Bar(() => Baz(abc));
}
static void Bar<T>(Expression<Func<T>> expr)
{
var methodCallExpression = expr.Body as MethodCallExpression;
}
static string Baz(string s)
{
return "baz";
}
static class Ext
{
public static string Foo(this string s)
{
return "foo";
}
}