|
|
@ -115,7 +115,7 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
|
|
|
|
|
|
|
|
internal static bool IsAnonymousMethod(DecompilerContext context, MethodDefinition method) |
|
|
|
internal static bool IsAnonymousMethod(DecompilerContext context, MethodDefinition method) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (method == null || !method.Name.StartsWith("<", StringComparison.Ordinal)) |
|
|
|
if (method == null || !(method.Name.StartsWith("<", StringComparison.Ordinal) || method.Name.Contains("$"))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!(method.IsCompilerGenerated() || IsPotentialClosure(context, method.DeclaringType))) |
|
|
|
if (!(method.IsCompilerGenerated() || IsPotentialClosure(context, method.DeclaringType))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -388,10 +388,13 @@ namespace ICSharpCode.Decompiler.Ast.Transforms |
|
|
|
continue; // skip static fields
|
|
|
|
continue; // skip static fields
|
|
|
|
if (dict.ContainsKey(field)) // skip field if it already was handled as parameter
|
|
|
|
if (dict.ContainsKey(field)) // skip field if it already was handled as parameter
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
EnsureVariableNameIsAvailable(blockStatement, field.Name); |
|
|
|
string capturedVariableName = field.Name; |
|
|
|
currentlyUsedVariableNames.Add(field.Name); |
|
|
|
if (capturedVariableName.StartsWith("$VB$Local_", StringComparison.Ordinal) && capturedVariableName.Length > 10) |
|
|
|
variablesToDeclare.Add(Tuple.Create(AstBuilder.ConvertType(field.FieldType, field), field.Name)); |
|
|
|
capturedVariableName = capturedVariableName.Substring(10); |
|
|
|
dict[field] = new IdentifierExpression(field.Name); |
|
|
|
EnsureVariableNameIsAvailable(blockStatement, capturedVariableName); |
|
|
|
|
|
|
|
currentlyUsedVariableNames.Add(capturedVariableName); |
|
|
|
|
|
|
|
variablesToDeclare.Add(Tuple.Create(AstBuilder.ConvertType(field.FieldType, field), capturedVariableName)); |
|
|
|
|
|
|
|
dict[field] = new IdentifierExpression(capturedVariableName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Now figure out where the closure was accessed and use the simpler replacement expression there:
|
|
|
|
// Now figure out where the closure was accessed and use the simpler replacement expression there:
|
|
|
|