Skip to content

Commit

Permalink
Merge pull request #102 from psaxton/issue101/rollback-9d451fb
Browse files Browse the repository at this point in the history
Revert "Fix debug information by just using the debug scopes from original method".
  • Loading branch information
Ralf1108 authored Nov 7, 2022
2 parents 9c98e0f + 1c43627 commit f22cc0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ private static void Main()
Debugger.Launch();
Debugger.Break();

var t0 = new WrongDebugVariableNames();
t0.Call();

var t1 = new LogTest();
t1.DoIt(7);

Expand Down

This file was deleted.

19 changes: 17 additions & 2 deletions src/MethodBoundaryAspect.Fody/MethodWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static MethodDefinition CloneMethod(MethodDefinition method)
};

foreach (var parameter in method.Parameters)
clonedMethod.Parameters.Add(parameter);
clonedMethod.Parameters.Add(parameter);

foreach (var variable in method.Body.Variables)
clonedMethod.Body.Variables.Add(variable);
Expand Down Expand Up @@ -162,7 +162,22 @@ private static MethodDefinition CloneMethod(MethodDefinition method)
}
}

clonedMethod.DebugInformation.Scope = method.DebugInformation.Scope;
if (method.DebugInformation.HasSequencePoints)
{
foreach (var sequencePoint in method.DebugInformation.SequencePoints)
clonedMethod.DebugInformation.SequencePoints.Add(sequencePoint);
}

clonedMethod.DebugInformation.Scope = new ScopeDebugInformation(method.Body.Instructions.First(), method.Body.Instructions.Last());

if (method.DebugInformation?.Scope?.Variables != null)
{
foreach (var variableDebugInformation in method.DebugInformation.Scope.Variables)
{
clonedMethod.DebugInformation.Scope.Variables.Add(variableDebugInformation);
}
}

return clonedMethod;
}

Expand Down

0 comments on commit f22cc0b

Please sign in to comment.