ILSpy
ILSpy copied to clipboard
lambda parameter name conflicts with name from outer scope
Try to decompile the following exe file Hearthbuddy-20190802-002.zip
// Triton.Common.TypeLoader<T>.Class236
internal IEnumerable<Type> method_1(Assembly assembly_0)
{
return from type_0 in assembly_0.GetTypes()
where !type_0.IsAbstract && (type_0.IsSubclassOf(typeof(T)) || type_0.GetInterfaces().Any((Type type_0) => type_0 == typeof(T)))
select type_0;
}
By the way, I am using ILSpy_binaries_6.0.0.5559-preview2.
The DnSpy decompile the above code as
internal IEnumerable<Type> method_1(Assembly assembly_0)
{
return assembly_0.GetTypes().Where(new Func<Type, bool>(TypeLoader<T>.Class236.<>9.method_2));
}
// Token: 0x0600161C RID: 5660 RVA: 0x000D06D0 File Offset: 0x000CE8D0
internal bool method_2(Type type_0)
{
if (type_0.IsAbstract)
{
return false;
}
if (!type_0.IsSubclassOf(typeof(T)))
{
return type_0.GetInterfaces().Any(new Func<Type, bool>(TypeLoader<T>.Class236.<>9.method_3));
}
return true;
}
internal bool method_3(Type type_0)
{
return type_0 == typeof(T);
}
See also #1572
Note that C# 8 started allowing shadowing of lambda parameters. So if we start renaming parameters to avoid this issue, we should restrict that to C# <= 7.3.