Browse Source

rename and clean

pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
816c34d94c
  1. 4
      Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs
  2. 38
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  3. 4
      ICSharpCode.Decompiler/Ast/CSharpCodeMapping.cs
  4. 6
      ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
  5. 62
      ICSharpCode.Decompiler/CodeMappings.cs
  6. 4
      ICSharpCode.Decompiler/Disassembler/ILCodeMapping.cs
  7. 8
      ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
  8. 2
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

4
Debugger/ILSpy.Debugger/Services/Debugger/WindowsDebugger.cs

@ -48,7 +48,7 @@ namespace ILSpy.Debugger.Services
//DynamicTreeDebuggerRow currentTooltipRow; //DynamicTreeDebuggerRow currentTooltipRow;
//Expression currentTooltipExpression; //Expression currentTooltipExpression;
private ConcurrentDictionary<string, List<MethodMapping>> CodeMappingsStorage { private ConcurrentDictionary<string, List<MemberMapping>> CodeMappingsStorage {
get { get {
return CodeMappings.GetStorage(DebugData.Language); return CodeMappings.GetStorage(DebugData.Language);
} }
@ -302,7 +302,7 @@ namespace ILSpy.Debugger.Services
var mapping = val.Find(m => m.MetadataToken == token); var mapping = val.Find(m => m.MetadataToken == token);
return mapping.MethodCodeMappings.FirstOrDefault(s => s.ILInstructionOffset.From == instruction.ILInstructionOffset.From); return mapping.MemberCodeMappings.FirstOrDefault(s => s.ILInstructionOffset.From == instruction.ILInstructionOffset.From);
} }
StackFrame GetStackFrame() StackFrame GetStackFrame()

38
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -167,7 +167,7 @@ namespace ICSharpCode.Decompiler.Ast
{ {
// create CSharp code mappings - used for debugger // create CSharp code mappings - used for debugger
if (!CSharpCodeMapping.SourceCodeMappings.ContainsKey(typeDef.FullName)) { if (!CSharpCodeMapping.SourceCodeMappings.ContainsKey(typeDef.FullName)) {
CSharpCodeMapping.SourceCodeMappings.TryAdd(typeDef.FullName, new List<MethodMapping>()); CSharpCodeMapping.SourceCodeMappings.TryAdd(typeDef.FullName, new List<MemberMapping>());
} else { } else {
CSharpCodeMapping.SourceCodeMappings[typeDef.FullName].Clear(); CSharpCodeMapping.SourceCodeMappings[typeDef.FullName].Clear();
} }
@ -596,12 +596,10 @@ namespace ICSharpCode.Decompiler.Ast
MethodDeclaration CreateMethod(MethodDefinition methodDef) MethodDeclaration CreateMethod(MethodDefinition methodDef)
{ {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = methodDef.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = methodDef.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
MethodDeclaration astMethod = new MethodDeclaration(); MethodDeclaration astMethod = new MethodDeclaration();
astMethod.AddAnnotation(methodDef); astMethod.AddAnnotation(methodDef);
if (methodMapping != null)
astMethod.AddAnnotation(methodMapping);
astMethod.ReturnType = ConvertType(methodDef.ReturnType, methodDef.MethodReturnType); astMethod.ReturnType = ConvertType(methodDef.ReturnType, methodDef.MethodReturnType);
astMethod.Name = CleanName(methodDef.Name); astMethod.Name = CleanName(methodDef.Name);
astMethod.TypeParameters.AddRange(MakeTypeParameters(methodDef.GenericParameters)); astMethod.TypeParameters.AddRange(MakeTypeParameters(methodDef.GenericParameters));
@ -615,6 +613,7 @@ namespace ICSharpCode.Decompiler.Ast
astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context); astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context);
} }
ConvertAttributes(astMethod, methodDef); ConvertAttributes(astMethod, methodDef);
astMethod.WithAnnotation(methodMapping);
return astMethod; return astMethod;
} }
@ -659,12 +658,10 @@ namespace ICSharpCode.Decompiler.Ast
ConstructorDeclaration CreateConstructor(MethodDefinition methodDef) ConstructorDeclaration CreateConstructor(MethodDefinition methodDef)
{ {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = methodDef.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = methodDef.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
ConstructorDeclaration astMethod = new ConstructorDeclaration(); ConstructorDeclaration astMethod = new ConstructorDeclaration();
astMethod.AddAnnotation(methodDef); astMethod.AddAnnotation(methodDef);
if (methodMapping != null)
astMethod.AddAnnotation(methodMapping);
astMethod.Modifiers = ConvertModifiers(methodDef); astMethod.Modifiers = ConvertModifiers(methodDef);
if (methodDef.IsStatic) { if (methodDef.IsStatic) {
// don't show visibility for static ctors // don't show visibility for static ctors
@ -674,11 +671,15 @@ namespace ICSharpCode.Decompiler.Ast
astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters)); astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters));
astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context); astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context);
ConvertAttributes(astMethod, methodDef); ConvertAttributes(astMethod, methodDef);
astMethod.WithAnnotation(methodMapping);
return astMethod; return astMethod;
} }
IndexerDeclaration ConvertPropertyToIndexer(PropertyDeclaration astProp, PropertyDefinition propDef) IndexerDeclaration ConvertPropertyToIndexer(PropertyDeclaration astProp, PropertyDefinition propDef)
{ {
// Create mapping - used in debugger
MemberMapping memberMapping = propDef.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
var astIndexer = new IndexerDeclaration(); var astIndexer = new IndexerDeclaration();
astIndexer.Name = astProp.Name; astIndexer.Name = astProp.Name;
astIndexer.CopyAnnotationsFrom(astProp); astIndexer.CopyAnnotationsFrom(astProp);
@ -689,6 +690,9 @@ namespace ICSharpCode.Decompiler.Ast
astIndexer.Getter = astProp.Getter.Detach(); astIndexer.Getter = astProp.Getter.Detach();
astIndexer.Setter = astProp.Setter.Detach(); astIndexer.Setter = astProp.Setter.Detach();
astIndexer.Parameters.AddRange(MakeParameters(propDef.Parameters)); astIndexer.Parameters.AddRange(MakeParameters(propDef.Parameters));
propDef.WithAnnotation(memberMapping);
return astIndexer; return astIndexer;
} }
@ -723,7 +727,7 @@ namespace ICSharpCode.Decompiler.Ast
astProp.ReturnType = ConvertType(propDef.PropertyType, propDef); astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
if (propDef.GetMethod != null) { if (propDef.GetMethod != null) {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = propDef.GetMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = propDef.GetMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
astProp.Getter = new Accessor { astProp.Getter = new Accessor {
Body = AstMethodBodyBuilder.CreateMethodBody(propDef.GetMethod, context) Body = AstMethodBodyBuilder.CreateMethodBody(propDef.GetMethod, context)
@ -734,12 +738,11 @@ namespace ICSharpCode.Decompiler.Ast
if ((getterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask)) if ((getterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
astProp.Getter.Modifiers = getterModifiers & Modifiers.VisibilityMask; astProp.Getter.Modifiers = getterModifiers & Modifiers.VisibilityMask;
if (methodMapping != null) astProp.Getter.WithAnnotation(methodMapping);
astProp.Getter.AddAnnotation(methodMapping);
} }
if (propDef.SetMethod != null) { if (propDef.SetMethod != null) {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = propDef.SetMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = propDef.SetMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
astProp.Setter = new Accessor { astProp.Setter = new Accessor {
Body = AstMethodBodyBuilder.CreateMethodBody(propDef.SetMethod, context) Body = AstMethodBodyBuilder.CreateMethodBody(propDef.SetMethod, context)
@ -751,8 +754,7 @@ namespace ICSharpCode.Decompiler.Ast
if ((setterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask)) if ((setterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
astProp.Setter.Modifiers = setterModifiers & Modifiers.VisibilityMask; astProp.Setter.Modifiers = setterModifiers & Modifiers.VisibilityMask;
if (methodMapping != null) astProp.Setter.WithAnnotation(methodMapping);
astProp.Setter.AddAnnotation(methodMapping);
} }
ConvertCustomAttributes(astProp, propDef); ConvertCustomAttributes(astProp, propDef);
return astProp; return astProp;
@ -782,27 +784,25 @@ namespace ICSharpCode.Decompiler.Ast
astEvent.PrivateImplementationType = ConvertType(eventDef.AddMethod.Overrides.First().DeclaringType); astEvent.PrivateImplementationType = ConvertType(eventDef.AddMethod.Overrides.First().DeclaringType);
if (eventDef.AddMethod != null) { if (eventDef.AddMethod != null) {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = eventDef.AddMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = eventDef.AddMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
astEvent.AddAccessor = new Accessor { astEvent.AddAccessor = new Accessor {
Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.AddMethod, context) Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.AddMethod, context)
}.WithAnnotation(eventDef.AddMethod); }.WithAnnotation(eventDef.AddMethod);
ConvertAttributes(astEvent.AddAccessor, eventDef.AddMethod); ConvertAttributes(astEvent.AddAccessor, eventDef.AddMethod);
if (methodMapping != null) astEvent.AddAccessor.WithAnnotation(methodMapping);
astEvent.AddAccessor.AddAnnotation(methodMapping);
} }
if (eventDef.RemoveMethod != null) { if (eventDef.RemoveMethod != null) {
// Create mapping - used in debugger // Create mapping - used in debugger
MethodMapping methodMapping = eventDef.RemoveMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings); MemberMapping methodMapping = eventDef.RemoveMethod.CreateCodeMapping(CSharpCodeMapping.SourceCodeMappings);
astEvent.RemoveAccessor = new Accessor { astEvent.RemoveAccessor = new Accessor {
Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.RemoveMethod, context) Body = AstMethodBodyBuilder.CreateMethodBody(eventDef.RemoveMethod, context)
}.WithAnnotation(eventDef.RemoveMethod); }.WithAnnotation(eventDef.RemoveMethod);
ConvertAttributes(astEvent.RemoveAccessor, eventDef.RemoveMethod); ConvertAttributes(astEvent.RemoveAccessor, eventDef.RemoveMethod);
if (methodMapping != null) astEvent.RemoveAccessor.WithAnnotation(methodMapping);
astEvent.RemoveAccessor.AddAnnotation(methodMapping);
} }
return astEvent; return astEvent;
} }

4
ICSharpCode.Decompiler/Ast/CSharpCodeMapping.cs

@ -14,12 +14,12 @@ namespace ICSharpCode.Decompiler.Ast
/// </summary> /// </summary>
public static class CSharpCodeMapping public static class CSharpCodeMapping
{ {
static ConcurrentDictionary<string, List<MethodMapping>> codeMappings = new ConcurrentDictionary<string, List<MethodMapping>>(); static ConcurrentDictionary<string, List<MemberMapping>> codeMappings = new ConcurrentDictionary<string, List<MemberMapping>>();
/// <summary> /// <summary>
/// Stores the source codes mappings: CSharp &lt;-&gt; editor lines /// Stores the source codes mappings: CSharp &lt;-&gt; editor lines
/// </summary> /// </summary>
public static ConcurrentDictionary<string, List<MethodMapping>> SourceCodeMappings { public static ConcurrentDictionary<string, List<MemberMapping>> SourceCodeMappings {
get { return codeMappings; } get { return codeMappings; }
set { codeMappings = value; } set { codeMappings = value; }
} }

6
ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs

@ -129,11 +129,11 @@ namespace ICSharpCode.Decompiler.Ast
// find the ancestor that has method mapping as annotation // find the ancestor that has method mapping as annotation
if (node.Ancestors != null && node.Ancestors.Count() > 0) if (node.Ancestors != null && node.Ancestors.Count() > 0)
{ {
var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MethodMapping>() != null); var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
if (n != default(AstType)) { if (n != default(AstType)) {
MethodMapping mapping = n.Annotation<MethodMapping>(); MemberMapping mapping = n.Annotation<MemberMapping>();
foreach (var range in ranges) { foreach (var range in ranges) {
mapping.MethodCodeMappings.Add(new SourceCodeMapping { mapping.MemberCodeMappings.Add(new SourceCodeMapping {
ILInstructionOffset = range, ILInstructionOffset = range,
SourceCodeLine = output.CurrentLine SourceCodeLine = output.CurrentLine
}); });

62
ICSharpCode.Decompiler/CodeMappings.cs

@ -47,7 +47,7 @@ namespace ICSharpCode.Decompiler
/// <summary> /// <summary>
/// Stores the method information and its source code mappings. /// Stores the method information and its source code mappings.
/// </summary> /// </summary>
public sealed class MethodMapping public sealed class MemberMapping
{ {
/// <summary> /// <summary>
/// Gets or sets the type of the mapping. /// Gets or sets the type of the mapping.
@ -62,36 +62,34 @@ namespace ICSharpCode.Decompiler
/// <summary> /// <summary>
/// Gets or sets the source code mappings. /// Gets or sets the source code mappings.
/// </summary> /// </summary>
public List<SourceCodeMapping> MethodCodeMappings { get; set; } public List<SourceCodeMapping> MemberCodeMappings { get; set; }
public int[] ToArray() public int[] ToArray()
{ {
int[] result = new int[MethodCodeMappings.Count * 2]; int[] result = new int[MemberCodeMappings.Count * 2];
int i = 0; int i = 0;
foreach (var element in MethodCodeMappings) { foreach (var element in MemberCodeMappings) {
result[i] = element.ILInstructionOffset.From; result[i] = element.ILInstructionOffset.From;
result[i+1] = element.ILInstructionOffset.To; result[i+1] = element.ILInstructionOffset.To;
i+=2; i+=2;
} }
//result[MethodCodeMappings.Count] = MethodCodeMappings[MethodCodeMappings.Count - 1].ILInstructionOffset.To;
return result; return result;
} }
} }
public static class CodeMappings public static class CodeMappings
{ {
public static ConcurrentDictionary<string, List<MethodMapping>> GetStorage(DecompiledLanguages language) public static ConcurrentDictionary<string, List<MemberMapping>> GetStorage(DecompiledLanguages language)
{ {
ConcurrentDictionary<string, List<MethodMapping>> storage = null; ConcurrentDictionary<string, List<MemberMapping>> storage = null;
switch (language) { switch (language) {
case DecompiledLanguages.IL: case DecompiledLanguages.IL:
storage = ILCodeMapping.SourceCodeMappings; storage = ILCodeMapping.SourceCodeMappings;
break; break;
case DecompiledLanguages.CSharp: case DecompiledLanguages.CSharp:
storage = CSharpCodeMapping.SourceCodeMappings; storage = CSharpCodeMapping.SourceCodeMappings;
break; break;
default: default:
throw new System.Exception("Invalid value for DecompiledLanguages"); throw new System.Exception("Invalid value for DecompiledLanguages");
@ -105,25 +103,25 @@ namespace ICSharpCode.Decompiler
/// </summary> /// </summary>
/// <param name="method">Method to create the mapping for.</param> /// <param name="method">Method to create the mapping for.</param>
/// <param name="sourceCodeMappings">Source code mapping storage.</param> /// <param name="sourceCodeMappings">Source code mapping storage.</param>
public static MethodMapping CreateCodeMapping( public static MemberMapping CreateCodeMapping(
this MethodDefinition method, this MemberReference member,
ConcurrentDictionary<string, List<MethodMapping>> sourceCodeMappings) ConcurrentDictionary<string, List<MemberMapping>> codeMappings)
{ {
// create IL/CSharp code mappings - used in debugger // create IL/CSharp code mappings - used in debugger
MethodMapping currentMethodMapping = null; MemberMapping currentMemberMapping = null;
if (sourceCodeMappings.ContainsKey(method.DeclaringType.FullName)) { if (codeMappings.ContainsKey(member.DeclaringType.FullName)) {
var mapping = sourceCodeMappings[method.DeclaringType.FullName]; var mapping = codeMappings[member.DeclaringType.FullName];
if (mapping.Find(map => (int)map.MetadataToken == method.MetadataToken.ToInt32()) == null) { if (mapping.Find(map => (int)map.MetadataToken == member.MetadataToken.ToInt32()) == null) {
currentMethodMapping = new MethodMapping() { currentMemberMapping = new MemberMapping() {
MetadataToken = (uint)method.MetadataToken.ToInt32(), MetadataToken = (uint)member.MetadataToken.ToInt32(),
Type = method.DeclaringType, Type = member.DeclaringType.Resolve(),
MethodCodeMappings = new List<SourceCodeMapping>() MemberCodeMappings = new List<SourceCodeMapping>()
}; };
mapping.Add(currentMethodMapping); mapping.Add(currentMemberMapping);
} }
} }
return currentMethodMapping; return currentMemberMapping;
} }
/// <summary> /// <summary>
@ -135,7 +133,7 @@ namespace ICSharpCode.Decompiler
/// <param name="metadataToken">Metadata token.</param> /// <param name="metadataToken">Metadata token.</param>
/// <returns></returns> /// <returns></returns>
public static SourceCodeMapping GetInstructionByTypeAndLine( public static SourceCodeMapping GetInstructionByTypeAndLine(
this ConcurrentDictionary<string, List<MethodMapping>> codeMappings, this ConcurrentDictionary<string, List<MemberMapping>> codeMappings,
string typeName, string typeName,
int lineNumber, int lineNumber,
out uint metadataToken) out uint metadataToken)
@ -152,7 +150,7 @@ namespace ICSharpCode.Decompiler
var methodMappings = codeMappings[typeName]; var methodMappings = codeMappings[typeName];
foreach (var maping in methodMappings) { foreach (var maping in methodMappings) {
var map = maping.MethodCodeMappings.Find(m => m.SourceCodeLine == lineNumber); var map = maping.MemberCodeMappings.Find(m => m.SourceCodeLine == lineNumber);
if (map != null) { if (map != null) {
metadataToken = maping.MetadataToken; metadataToken = maping.MetadataToken;
return map; return map;
@ -172,7 +170,7 @@ namespace ICSharpCode.Decompiler
/// <param name="typeName">Type definition.</param> /// <param name="typeName">Type definition.</param>
/// <param name="line">Line number.</param> /// <param name="line">Line number.</param>
public static bool GetSourceCodeFromMetadataTokenAndOffset( public static bool GetSourceCodeFromMetadataTokenAndOffset(
this ConcurrentDictionary<string, List<MethodMapping>> codeMappings, this ConcurrentDictionary<string, List<MemberMapping>> codeMappings,
uint token, uint token,
int ilOffset, int ilOffset,
out TypeDefinition type, out TypeDefinition type,
@ -186,17 +184,17 @@ namespace ICSharpCode.Decompiler
if (mapping == null) if (mapping == null)
continue; continue;
var codeMapping = mapping.MethodCodeMappings.Find( var codeMapping = mapping.MemberCodeMappings.Find(
cm => cm.ILInstructionOffset.From <= ilOffset && ilOffset <= cm.ILInstructionOffset.To - 1); cm => cm.ILInstructionOffset.From <= ilOffset && ilOffset <= cm.ILInstructionOffset.To - 1);
if (codeMapping == null) { if (codeMapping == null) {
codeMapping = mapping.MethodCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset)); codeMapping = mapping.MemberCodeMappings.Find(cm => (cm.ILInstructionOffset.From >= ilOffset));
if (codeMapping == null) { if (codeMapping == null) {
codeMapping = mapping.MethodCodeMappings.LastOrDefault(); codeMapping = mapping.MemberCodeMappings.LastOrDefault();
if (codeMapping == null) if (codeMapping == null)
continue; continue;
} }
} }
type = mapping.Type; type = mapping.Type;
line = codeMapping.SourceCodeLine; line = codeMapping.SourceCodeLine;

4
ICSharpCode.Decompiler/Disassembler/ILCodeMapping.cs

@ -12,12 +12,12 @@ namespace ICSharpCode.Decompiler.Disassembler
/// </summary> /// </summary>
public static class ILCodeMapping public static class ILCodeMapping
{ {
static ConcurrentDictionary<string, List<MethodMapping>> codeMappings = new ConcurrentDictionary<string, List<MethodMapping>>(); static ConcurrentDictionary<string, List<MemberMapping>> codeMappings = new ConcurrentDictionary<string, List<MemberMapping>>();
/// <summary> /// <summary>
/// Stores the source codes mappings: IL &lt;-&gt; editor lines /// Stores the source codes mappings: IL &lt;-&gt; editor lines
/// </summary> /// </summary>
public static ConcurrentDictionary<string, List<MethodMapping>> SourceCodeMappings { public static ConcurrentDictionary<string, List<MemberMapping>> SourceCodeMappings {
get { return codeMappings; } get { return codeMappings; }
set { codeMappings = value; } set { codeMappings = value; }
} }

8
ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.Decompiler.Disassembler
public void Disassemble(MethodBody body) public void Disassemble(MethodBody body)
{ {
// create IL code mappings - used in debugger // create IL code mappings - used in debugger
MethodMapping methodMapping = body.Method.CreateCodeMapping(ILCodeMapping.SourceCodeMappings); MemberMapping methodMapping = body.Method.CreateCodeMapping(ILCodeMapping.SourceCodeMappings);
// start writing IL code // start writing IL code
MethodDefinition method = body.Method; MethodDefinition method = body.Method;
@ -84,7 +84,7 @@ namespace ICSharpCode.Decompiler.Disassembler
} else { } else {
foreach (var inst in method.Body.Instructions) { foreach (var inst in method.Body.Instructions) {
// add IL code mappings // add IL code mappings
methodMapping.MethodCodeMappings.Add( methodMapping.MemberCodeMappings.Add(
new SourceCodeMapping() { new SourceCodeMapping() {
SourceCodeLine = output.CurrentLine, SourceCodeLine = output.CurrentLine,
ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? method.Body.CodeSize : inst.Next.Offset } ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? method.Body.CodeSize : inst.Next.Offset }
@ -146,13 +146,13 @@ namespace ICSharpCode.Decompiler.Disassembler
output.Indent(); output.Indent();
} }
void WriteStructureBody(ILStructure s, ref Instruction inst, MethodMapping currentMethodMapping, int codeSize) void WriteStructureBody(ILStructure s, ref Instruction inst, MemberMapping currentMethodMapping, int codeSize)
{ {
int childIndex = 0; int childIndex = 0;
while (inst != null && inst.Offset < s.EndOffset) { while (inst != null && inst.Offset < s.EndOffset) {
// add IL code mappings - used in debugger // add IL code mappings - used in debugger
if (currentMethodMapping != null) { if (currentMethodMapping != null) {
currentMethodMapping.MethodCodeMappings.Add( currentMethodMapping.MemberCodeMappings.Add(
new SourceCodeMapping() { new SourceCodeMapping() {
SourceCodeLine = output.CurrentLine, SourceCodeLine = output.CurrentLine,
ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? codeSize : inst.Next.Offset } ILInstructionOffset = new ILRange { From = inst.Offset, To = inst.Next == null ? codeSize : inst.Next.Offset }

2
ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -314,7 +314,7 @@ namespace ICSharpCode.Decompiler.Disassembler
{ {
// create IL code mappings - used for debugger // create IL code mappings - used for debugger
if (!ILCodeMapping.SourceCodeMappings.ContainsKey(type.FullName)) { if (!ILCodeMapping.SourceCodeMappings.ContainsKey(type.FullName)) {
ILCodeMapping.SourceCodeMappings.TryAdd(type.FullName, new List<MethodMapping>()); ILCodeMapping.SourceCodeMappings.TryAdd(type.FullName, new List<MemberMapping>());
} else { } else {
ILCodeMapping.SourceCodeMappings[type.FullName].Clear(); ILCodeMapping.SourceCodeMappings[type.FullName].Clear();
} }

Loading…
Cancel
Save