Browse Source

Prevent SequencePointBuilder from combining sequence points of lambda expressions.

pull/923/head
Siegfried Pammer 8 years ago
parent
commit
84592fcc6f
  1. 8
      ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs
  2. 3
      ILSpy/Languages/CSharpILMixedLanguage.cs

8
ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs

@ -120,6 +120,12 @@ namespace ICSharpCode.Decompiler.CSharp @@ -120,6 +120,12 @@ namespace ICSharpCode.Decompiler.CSharp
}
}
public override void VisitLambdaExpression(LambdaExpression lambdaExpression)
{
AddToSequencePoint(lambdaExpression);
VisitAsSequencePoint(lambdaExpression.Body);
}
/// <summary>
/// Start a new C# statement = new sequence point.
/// </summary>
@ -160,7 +166,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -160,7 +166,7 @@ namespace ICSharpCode.Decompiler.CSharp
void AddToSequencePoint(ILInstruction inst)
{
if (!mappedInstructions.Add(inst)) {
if (!mappedInstructions.Add(inst) || inst is ILFunction) {
// inst was already used by a nested sequence point within this sequence point
return;
}

3
ILSpy/Languages/CSharpILMixedLanguage.cs

@ -69,7 +69,8 @@ namespace ICSharpCode.ILSpy @@ -69,7 +69,8 @@ namespace ICSharpCode.ILSpy
CSharpDecompiler decompiler = CreateDecompiler(method.Module, options);
var st = decompiler.Decompile(method);
WriteCode(csharpOutput, options.DecompilerSettings, st, decompiler.TypeSystem);
this.sequencePoints = decompiler.CreateSequencePoints(st).FirstOrDefault(kvp => kvp.Key.CecilMethod == method).Value ?? (IList<Decompiler.IL.SequencePoint>)EmptyList<Decompiler.IL.SequencePoint>.Instance;
var mapping = decompiler.CreateSequencePoints(st).FirstOrDefault(kvp => kvp.Key.CecilMethod == method);
this.sequencePoints = mapping.Value ?? (IList<Decompiler.IL.SequencePoint>)EmptyList<Decompiler.IL.SequencePoint>.Instance;
this.codeLines = csharpOutput.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None);
base.Disassemble(body);
} finally {

Loading…
Cancel
Save