Skip to content

Commit f22cc0b

Browse files
authored
Merge pull request #102 from psaxton/issue101/rollback-9d451fb
Revert "Fix debug information by just using the debug scopes from original method".
2 parents 9c98e0f + 1c43627 commit f22cc0b

3 files changed

Lines changed: 17 additions & 59 deletions

File tree

src/MethodBoundaryAspect.Fody.UnitTests.TestProgram.NetFramework/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ private static void Main()
1212
Debugger.Launch();
1313
Debugger.Break();
1414

15-
var t0 = new WrongDebugVariableNames();
16-
t0.Call();
17-
1815
var t1 = new LogTest();
1916
t1.DoIt(7);
2017

src/MethodBoundaryAspect.Fody.UnitTests.TestProgram.NetFramework/WrongDebugVariableNames.cs

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/MethodBoundaryAspect.Fody/MethodWeaver.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private static MethodDefinition CloneMethod(MethodDefinition method)
9898
};
9999

100100
foreach (var parameter in method.Parameters)
101-
clonedMethod.Parameters.Add(parameter);
101+
clonedMethod.Parameters.Add(parameter);
102102

103103
foreach (var variable in method.Body.Variables)
104104
clonedMethod.Body.Variables.Add(variable);
@@ -162,7 +162,22 @@ private static MethodDefinition CloneMethod(MethodDefinition method)
162162
}
163163
}
164164

165-
clonedMethod.DebugInformation.Scope = method.DebugInformation.Scope;
165+
if (method.DebugInformation.HasSequencePoints)
166+
{
167+
foreach (var sequencePoint in method.DebugInformation.SequencePoints)
168+
clonedMethod.DebugInformation.SequencePoints.Add(sequencePoint);
169+
}
170+
171+
clonedMethod.DebugInformation.Scope = new ScopeDebugInformation(method.Body.Instructions.First(), method.Body.Instructions.Last());
172+
173+
if (method.DebugInformation?.Scope?.Variables != null)
174+
{
175+
foreach (var variableDebugInformation in method.DebugInformation.Scope.Variables)
176+
{
177+
clonedMethod.DebugInformation.Scope.Variables.Add(variableDebugInformation);
178+
}
179+
}
180+
166181
return clonedMethod;
167182
}
168183

0 commit comments

Comments
 (0)