diff --git a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
index a3f85c9a4..ec65a8371 100644
--- a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
+++ b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
@@ -27,7 +27,7 @@ namespace ICSharpCode.Decompiler.Disassembler
///
/// Disassembles a method body.
///
- public sealed class MethodBodyDisassembler
+ public class MethodBodyDisassembler
{
readonly ITextOutput output;
readonly bool detectControlStructure;
@@ -42,7 +42,7 @@ namespace ICSharpCode.Decompiler.Disassembler
this.cancellationToken = cancellationToken;
}
- public void Disassemble(MethodBody body/*, MemberMapping methodMapping*/)
+ public void Disassemble(MethodBody body)
{
// start writing IL code
MethodDefinition method = body.Method;
@@ -61,20 +61,7 @@ namespace ICSharpCode.Decompiler.Disassembler
WriteStructureBody(new ILStructure(body), branchTargets, ref inst, method.Body.CodeSize);
} else {
foreach (var inst in method.Body.Instructions) {
- //var startLocation = output.Location;
- inst.WriteTo(output);
-
- /*
- if (debugSymbols != null) {
- // add IL code mappings - used in debugger
- debugSymbols.SequencePoints.Add(
- new SequencePoint() {
- StartLocation = output.Location,
- EndLocation = output.Location,
- ILRanges = new ILRange[] { new ILRange(inst.Offset, inst.Next == null ? method.Body.CodeSize : inst.Next.Offset) }
- });
- }*/
-
+ WriteInstruction(output, inst);
output.WriteLine();
}
WriteExceptionHandlers(body);
@@ -191,19 +178,7 @@ namespace ICSharpCode.Decompiler.Disassembler
if (!isFirstInstructionInStructure && (prevInstructionWasBranch || branchTargets.Contains(offset))) {
output.WriteLine(); // put an empty line after branches, and in front of branch targets
}
- //var startLocation = output.Location;
- inst.WriteTo(output);
-
- /*// add IL code mappings - used in debugger
- if (debugSymbols != null) {
- debugSymbols.SequencePoints.Add(
- new SequencePoint() {
- StartLocation = startLocation,
- EndLocation = output.Location,
- ILRanges = new ILRange[] { new ILRange(inst.Offset, inst.Next == null ? codeSize : inst.Next.Offset) }
- });
- }*/
-
+ WriteInstruction(output, inst);
output.WriteLine();
prevInstructionWasBranch = inst.OpCode.FlowControl == FlowControl.Branch
@@ -237,5 +212,10 @@ namespace ICSharpCode.Decompiler.Disassembler
throw new NotSupportedException();
}
}
+
+ protected virtual void WriteInstruction(ITextOutput output, Instruction instruction)
+ {
+ instruction.WriteTo(output);
+ }
}
}
diff --git a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
index 7707f7791..6137fc0d5 100644
--- a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
+++ b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
@@ -36,12 +36,17 @@ namespace ICSharpCode.Decompiler.Disassembler
MemberReference currentMember;
public ReflectionDisassembler(ITextOutput output, bool detectControlStructure, CancellationToken cancellationToken)
+ : this(output, new MethodBodyDisassembler(output, detectControlStructure, cancellationToken), cancellationToken)
+ {
+ }
+
+ public ReflectionDisassembler(ITextOutput output, MethodBodyDisassembler methodBodyDisassembler, CancellationToken cancellationToken)
{
if (output == null)
throw new ArgumentNullException(nameof(output));
this.output = output;
this.cancellationToken = cancellationToken;
- this.methodBodyDisassembler = new MethodBodyDisassembler(output, detectControlStructure, cancellationToken);
+ this.methodBodyDisassembler = methodBodyDisassembler;
}
#region Disassemble Method
diff --git a/ICSharpCode.Decompiler/IL/SequencePoint.cs b/ICSharpCode.Decompiler/IL/SequencePoint.cs
index 568953c35..ec2ac3d45 100644
--- a/ICSharpCode.Decompiler/IL/SequencePoint.cs
+++ b/ICSharpCode.Decompiler/IL/SequencePoint.cs
@@ -7,8 +7,8 @@ namespace ICSharpCode.Decompiler.IL
///
/// A sequence point produced by the decompiler.
///
- public struct SequencePoint
- {
+ public struct SequencePoint
+ {
///
/// IL offset.
///