Browse Source

Add the OnDecompileFinished for method, property, event, field, assembly, namespace - this will be used when decompile a single method/property/event will be possible.

pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
4d05fdbb01
  1. 6
      ILSpy/CSharpLanguage.cs
  2. 15
      ILSpy/ILLanguage.cs
  3. 11
      ILSpy/TextView/DecompilerTextView.cs
  4. 1
      ILSpy/TreeNodes/MethodTreeNode.cs
  5. 1
      ILSpy/TreeNodes/PropertyTreeNode.cs

6
ILSpy/CSharpLanguage.cs

@ -92,6 +92,7 @@ namespace ICSharpCode.ILSpy @@ -92,6 +92,7 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddMethod(method);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = codeDomBuilder.CodeMappings, LocalVariables = codeDomBuilder.LocalVariables });
}
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options)
@ -101,6 +102,7 @@ namespace ICSharpCode.ILSpy @@ -101,6 +102,7 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddProperty(property);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = codeDomBuilder.CodeMappings, LocalVariables = codeDomBuilder.LocalVariables });
}
public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options)
@ -110,6 +112,7 @@ namespace ICSharpCode.ILSpy @@ -110,6 +112,7 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddField(field);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
OnDecompilationFinished(null);
}
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options)
@ -119,6 +122,7 @@ namespace ICSharpCode.ILSpy @@ -119,6 +122,7 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddEvent(ev);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = codeDomBuilder.CodeMappings, LocalVariables = codeDomBuilder.LocalVariables });
}
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options)
@ -127,7 +131,6 @@ namespace ICSharpCode.ILSpy @@ -127,7 +131,6 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.AddType(type);
codeDomBuilder.RunTransformations(transformAbortCondition);
codeDomBuilder.GenerateCode(output);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = codeDomBuilder.CodeMappings, LocalVariables = codeDomBuilder.LocalVariables });
}
@ -148,6 +151,7 @@ namespace ICSharpCode.ILSpy @@ -148,6 +151,7 @@ namespace ICSharpCode.ILSpy
codeDomBuilder.GenerateCode(output);
}
}
OnDecompilationFinished(null);
}
#region WriteProjectFile

15
ILSpy/ILLanguage.cs

@ -53,22 +53,29 @@ namespace ICSharpCode.ILSpy @@ -53,22 +53,29 @@ namespace ICSharpCode.ILSpy
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
{
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleMethod(method);
var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
dis.DisassembleMethod(method);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = dis.CodeMappings });
}
public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options)
{
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleField(field);
OnDecompilationFinished(null);
}
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options)
{
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleProperty(property);
var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
dis.DisassembleProperty(property);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = dis.CodeMappings });
}
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options)
{
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleEvent(ev);
var dis = new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken);
dis.DisassembleEvent(ev);
OnDecompilationFinished(new DecompileEventArgs { CodeMappings = dis.CodeMappings });
}
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options)
@ -82,6 +89,7 @@ namespace ICSharpCode.ILSpy @@ -82,6 +89,7 @@ namespace ICSharpCode.ILSpy
public override void DecompileNamespace(string nameSpace, IEnumerable<TypeDefinition> types, ITextOutput output, DecompilationOptions options)
{
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).DisassembleNamespace(nameSpace, types);
OnDecompilationFinished(null);
}
public override void DecompileAssembly(AssemblyDefinition assembly, string fileName, ITextOutput output, DecompilationOptions options)
@ -90,6 +98,7 @@ namespace ICSharpCode.ILSpy @@ -90,6 +98,7 @@ namespace ICSharpCode.ILSpy
output.WriteLine();
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).WriteAssemblyHeader(assembly);
OnDecompilationFinished(null);
}
public override string TypeToString(TypeReference t, bool includeNamespace, ICustomAttributeProvider attributeProvider)

11
ILSpy/TextView/DecompilerTextView.cs

@ -449,17 +449,26 @@ namespace ICSharpCode.ILSpy.TextView @@ -449,17 +449,26 @@ namespace ICSharpCode.ILSpy.TextView
static void DecompileNodes(DecompilationContext context, ITextOutput textOutput)
{
var nodes = context.TreeNodes;
context.Language.DecompileFinished += Language_DecompileFinished;
for (int i = 0; i < nodes.Length; i++) {
if (i > 0)
textOutput.WriteLine();
context.Language.DecompileFinished += (s, e) => { DebugData.CodeMappings = e.CodeMappings; DebugData.LocalVariables = e.LocalVariables; };
if (nodes[i] is IMemberTreeNode) {
DebugData.CurrentMemberReference = (nodes[i] as IMemberTreeNode).Member;
}
context.Options.CancellationToken.ThrowIfCancellationRequested();
nodes[i].Decompile(context.Language, textOutput, context.Options);
}
context.Language.DecompileFinished -= Language_DecompileFinished;
}
static void Language_DecompileFinished(object sender, DecompileEventArgs e)
{
if (e != null) {
DebugData.CodeMappings = e.CodeMappings;
DebugData.LocalVariables = e.LocalVariables;
}
}
#endregion

1
ILSpy/TreeNodes/MethodTreeNode.cs

@ -124,7 +124,6 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -124,7 +124,6 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
DebugData.CurrentMemberReference = method;
language.DecompileMethod(method, output, options);
}

1
ILSpy/TreeNodes/PropertyTreeNode.cs

@ -147,7 +147,6 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -147,7 +147,6 @@ namespace ICSharpCode.ILSpy.TreeNodes
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
DebugData.CurrentMemberReference = property;
language.DecompileProperty(property, output, options);
}

Loading…
Cancel
Save