From 2169d44c81a39c518d68fd8d1224f1fa4d22a5b8 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 14 Oct 2017 20:00:44 +0200 Subject: [PATCH] Implement sequence points for using statement. --- ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs | 9 +++++++++ ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs index a4528113f..3486542ee 100644 --- a/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/SequencePointBuilder.cs @@ -126,6 +126,15 @@ namespace ICSharpCode.Decompiler.CSharp VisitAsSequencePoint(lambdaExpression.Body); } + public override void VisitUsingStatement(UsingStatement usingStatement) + { + StartSequencePoint(usingStatement); + usingStatement.ResourceAcquisition.AcceptVisitor(this); + VisitAsSequencePoint(usingStatement.EmbeddedStatement); + AddToSequencePoint(usingStatement); + EndSequencePoint(usingStatement.StartLocation, usingStatement.RParToken.EndLocation); + } + /// /// Start a new C# statement = new sequence point. /// diff --git a/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs b/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs index 1c64d2983..3d6cd1639 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/UsingTransform.cs @@ -87,7 +87,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms context.Step("UsingTransform", tryFinally); storeInst.Variable.Kind = VariableKind.UsingLocal; block.Instructions.RemoveAt(i); - block.Instructions[i - 1] = new UsingInstruction(storeInst.Variable, storeInst.Value, tryFinally.TryBlock); + block.Instructions[i - 1] = new UsingInstruction(storeInst.Variable, storeInst.Value, tryFinally.TryBlock) { ILRange = storeInst.ILRange }; return true; }