diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 6e1cffa1d..8f905b06c 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -517,11 +517,14 @@ namespace ICSharpCode.Decompiler.CSharp var part = method; var connectedMethods = new Queue(); + var processedMethods = new HashSet(); var processedNestedTypes = new HashSet(); connectedMethods.Enqueue(part); while (connectedMethods.Count > 0) { part = connectedMethods.Dequeue(); + if (!processedMethods.Add(part)) + continue; try { ReadCodeMappingInfo(module, declaringType, info, parent, part, connectedMethods, processedNestedTypes); } catch (BadImageFormatException) { diff --git a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs index f4015a48a..4d8606751 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/DelegateConstruction.cs @@ -155,6 +155,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms var targetMethod = ((IInstructionWithMethodOperand)value.Arguments[1]).Method; if (!IsAnonymousMethod(decompilationContext.CurrentTypeDefinition, targetMethod)) return null; + if (LocalFunctionDecompiler.IsLocalFunctionMethod(targetMethod.ParentModule.PEFile, (MethodDefinitionHandle)targetMethod.MetadataToken)) + return null; target = value.Arguments[0]; if (targetMethod.MetadataToken.IsNil) return null; diff --git a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs index 2b8304815..42763bac7 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/LocalFunctionDecompiler.cs @@ -21,8 +21,9 @@ namespace ICSharpCode.Decompiler.IL.Transforms { var metadata = module.Metadata; var method = metadata.GetMethodDefinition(methodHandle); + var declaringType = method.GetDeclaringType(); - if ((method.Attributes & MethodAttributes.Assembly) == 0 || !method.IsCompilerGenerated(metadata)) + if ((method.Attributes & MethodAttributes.Assembly) == 0 || !(method.IsCompilerGenerated(metadata) || declaringType.IsCompilerGenerated(metadata))) return false; if (!ParseLocalFunctionName(metadata.GetString(method.Name), out _, out _))