If I have a method whose parameters is an Expression<Func<...>> then Reflector is not decompiling the resultant expression tree back into the original lambda statement. Are expression decompiling not supported ?
Example. I have code that invokes FirstOrDefaultAsync on an Entity Framework IDbSet<> using the following extension method
EntityFramework v6, System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Original Source
public override async Task<ApplicationUser> FindAsync(UserLoginInfo login)
{
if (login == null)
{
throw new ArgumentNullException("login");
}
var provider = login.LoginProvider;
var key = login.ProviderKey;
var userLogin = await this.UserLogins.FirstOrDefaultAsync(l => l.LoginProvider == provider && l.ProviderKey == key && l.CompanyCode == this.companyContext.CompanyCode).WithCurrentCulture();
if (userLogin != null)
{
var userId = userLogin.UserId;
return await GetUserAggregateAsync(u => u.Id.Equals(userId)).WithCurrentCulture();
}
return null;
}
Decompiled
public async override Task<ApplicationUser> FindAsync(UserLoginInfo login)
{
ParameterExpression expression;
<>c__DisplayClass8_0 asyncVariable0;
if (login == null)
{
throw new ArgumentNullException("login");
}
string provider = login.LoginProvider;
string key = login.ProviderKey;
ParameterExpression[] expressionArray1 = new ParameterExpression[] { expression };
IdentityUserLoginWithCompanyCode asyncVariable1 = await this.UserLogins.FirstOrDefaultAsync<IdentityUserLoginWithCompanyCode>(Expression.Lambda<Func<IdentityUserLoginWithCompanyCode, bool>>(Expression.AndAlso(Expression.AndAlso(Expression.Equal(Expression.Property(expression = Expression.Parameter(typeof(IdentityUserLoginWithCompanyCode), "l"), (MethodInfo) methodof(IdentityUserLogin<string>.get_LoginProvider, IdentityUserLogin<string>)), Expression.Field(Expression.Constant(asyncVariable0, typeof(<>c__DisplayClass8_0)), fieldof(<>c__DisplayClass8_0.provider))), Expression.Equal(Expression.Property(expression, (MethodInfo) methodof(IdentityUserLogin<string>.get_ProviderKey, IdentityUserLogin<string>)), Expression.Field(Expression.Constant(asyncVariable0, typeof(<>c__DisplayClass8_0)), fieldof(<>c__DisplayClass8_0.key)))), Expression.Equal(Expression.Property(expression, (MethodInfo) methodof(IdentityUserLoginWithCompanyCode.get_CompanyCode)), Expression.Property(Expression.Field(Expression.Constant(this, typeof(ApplicationUserStore)), fieldof(ApplicationUserStore.companyContext)), (MethodInfo) methodof(ICompanyContext.get_CompanyCode)))), expressionArray1)).WithCurrentCulture<IdentityUserLoginWithCompanyCode>();
IdentityUserLoginWithCompanyCode userLogin = asyncVariable1;
asyncVariable1 = null;
if (userLogin > null)
{
<>c__DisplayClass8_1 asyncVariable2;
string userId = userLogin.UserId;
Expression[] arguments = new Expression[] { Expression.Field(Expression.Constant(asyncVariable2, typeof(<>c__DisplayClass8_1)), fieldof(<>c__DisplayClass8_1.userId)) };
ParameterExpression[] parameters = new ParameterExpression[] { expression };
return await this.GetUserAggregateAsync(Expression.Lambda<Func<ApplicationUser, bool>>(Expression.Call(Expression.Property(expression = Expression.Parameter(typeof(ApplicationUser), "u"), (MethodInfo) methodof(IdentityUser<string, IdentityUserLoginWithCompanyCode, IdentityUserRole, IdentityUserClaimWithIssuer>.get_Id, IdentityUser<string, IdentityUserLoginWithCompanyCode, IdentityUserRole, IdentityUserClaimWithIssuer>)), (MethodInfo) methodof(string.Equals), arguments), parameters)).WithCurrentCulture<ApplicationUser>();
}
return null;
}
If you look at the decompiled code you will also see a strange null check
if (userLogin > null)
Example. I have code that invokes FirstOrDefaultAsync on an Entity Framework IDbSet<> using the following extension method
EntityFramework v6, System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync
public static Task<TSource> FirstOrDefaultAsync<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
Original Source
Decompiled
If you look at the decompiled code you will also see a strange null check