Permalink
Browse files

Fix ReadCodeMappingInfo for lambdas compiled with mcs.

  • Loading branch information...
siegfriedpammer committed Aug 26, 2018
1 parent 65cf13c commit d5a2b893e9cd1725d15a271975d6de13bba642c8
Showing with 12 additions and 1 deletion.
  1. +1 −1 ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. +11 −0 ICSharpCode.Decompiler/SRMExtensions.cs
@@ -613,7 +613,7 @@ private static void ReadCodeMappingInfo(PEFile module, TypeDefinitionHandle decl
// deal with ldftn instructions, i.e., lambdas
token = MetadataTokenHelpers.EntityHandleOrNil(blob.ReadInt32());
if (!token.IsNil && token.Kind == HandleKind.MethodDefinition) {
if (((MethodDefinitionHandle)token).IsCompilerGenerated(module.Metadata))
if (((MethodDefinitionHandle)token).IsCompilerGeneratedOrIsInCompilerGeneratedClass(module.Metadata))
connectedMethods.Enqueue((MethodDefinitionHandle)token);
}
break;
@@ -291,6 +291,17 @@ public static bool IsCompilerGenerated(this MethodDefinitionHandle handle, Metad
return metadata.GetMethodDefinition(handle).IsCompilerGenerated(metadata);
}
public static bool IsCompilerGeneratedOrIsInCompilerGeneratedClass(this MethodDefinitionHandle handle, MetadataReader metadata)
{
MethodDefinition method = metadata.GetMethodDefinition(handle);
if (method.IsCompilerGenerated(metadata))
return true;
TypeDefinitionHandle declaringTypeHandle = method.GetDeclaringType();
if (!declaringTypeHandle.IsNil && declaringTypeHandle.IsCompilerGenerated(metadata))
return true;
return false;
}
public static bool IsCompilerGenerated(this MethodDefinition method, MetadataReader metadata)
{
return method.GetCustomAttributes().HasKnownAttribute(metadata, KnownAttribute.CompilerGenerated);

0 comments on commit d5a2b89

Please sign in to comment.