Browse Source

PDBGen: Fix exception in case an ILFunction gets defined in C# twice: This may happen if a compiler-generated function gets transformed into a lambda expression, but its method definition is not removed from the syntax tree.

pull/2333/head
Siegfried Pammer 4 years ago
parent
commit
5a8b488e99
  1. 11
      ICSharpCode.Decompiler/DebugInfo/PortablePdbWriter.cs

11
ICSharpCode.Decompiler/DebugInfo/PortablePdbWriter.cs

@ -216,11 +216,22 @@ namespace ICSharpCode.Decompiler.DebugInfo @@ -216,11 +216,22 @@ namespace ICSharpCode.Decompiler.DebugInfo
methodBody = null;
localSignatureRowId = 0;
}
// Check if sequence points were already processed - ILFunction gets defined in C# twice:
// This may happen if a compiler-generated function gets transformed into a lambda expression,
// but its method definition is not removed from the syntax tree.
if (!sequencePointBlobs.ContainsKey(method))
{
if (sequencePoints?.Count > 0)
sequencePointBlobs.Add(method, (document, EncodeSequencePoints(metadata, localSignatureRowId, sequencePoints)));
else
sequencePointBlobs.Add(method, (default, default));
}
else
{
Debug.Assert(false, "Duplicate sequence point definition detected: " + MetadataTokens.GetToken(method).ToString("X8"));
}
}
}
static BlobBuilder BuildStateMachineHoistedLocalScopes(ILFunction function)

Loading…
Cancel
Save