Browse Source

Moving the disassembler into the ICSharpCode.Decompiler library.

pull/1/head
Daniel Grunwald 14 years ago
parent
commit
d569ba5395
  1. 68
      ICSharpCode.Decompiler/CecilExtensions.cs
  2. 5
      ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs
  3. 11
      ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs
  4. 14
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
  5. 6
      ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs
  6. 6
      ICSharpCode.Decompiler/FlowAnalysis/SsaInstruction.cs
  7. 8
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  8. 56
      ICSharpCode.Decompiler/ITextOutput.cs
  9. 50
      ICSharpCode.Decompiler/PlainTextOutput.cs
  10. 1
      ILSpy/Decompiler/CSharpLanguage.cs
  11. 7
      ILSpy/Disassembler/ILLanguage.cs
  12. 44
      ILSpy/ExtensionMethods.cs
  13. 33
      ILSpy/ILSpy.csproj
  14. 2
      ILSpy/Language.cs
  15. 2
      ILSpy/TextView/SmartTextOutput.cs
  16. 8
      ILSpy/TreeNodes/AssemblyListTreeNode.cs
  17. 0
      ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs
  18. 2
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  19. 0
      ILSpy/TreeNodes/BaseTypesTreeNode.cs
  20. 1
      ILSpy/TreeNodes/EventTreeNode.cs
  21. 1
      ILSpy/TreeNodes/FieldTreeNode.cs
  22. 1
      ILSpy/TreeNodes/ILSpyTreeNode.cs
  23. 1
      ILSpy/TreeNodes/MethodTreeNode.cs
  24. 0
      ILSpy/TreeNodes/ModuleReferenceTreeNode.cs
  25. 1
      ILSpy/TreeNodes/NamespaceTreeNode.cs
  26. 1
      ILSpy/TreeNodes/PropertyTreeNode.cs
  27. 0
      ILSpy/TreeNodes/ReferenceFolderTreeNode.cs
  28. 0
      ILSpy/TreeNodes/ResourceListTreeNode.cs
  29. 1
      ILSpy/TreeNodes/TypeTreeNode.cs

68
ICSharpCode.Decompiler/CecilExtensions.cs

@ -17,8 +17,10 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
@ -124,62 +126,32 @@ namespace ICSharpCode.Decompiler
} }
#endregion #endregion
public static void WriteTo(this Instruction instruction, TextWriter writer)
{
writer.Write(OffsetToString(instruction.Offset));
writer.Write(": ");
writer.Write(instruction.OpCode.Name);
if(null != instruction.Operand) {
writer.Write(' ');
writer.Write(OperandToString(instruction.Operand));
}
}
public static void WriteTo(this ExceptionHandler exceptionHandler, TextWriter writer)
{
writer.Write("Try IL_{0:x4}-IL_{1:x4} ", exceptionHandler.TryStart.Offset, exceptionHandler.TryEnd.Offset);
writer.Write(exceptionHandler.HandlerType.ToString());
if (exceptionHandler.FilterStart != null) {
writer.Write(" IL_{0:x4}-IL_{1:x4} handler ", exceptionHandler.FilterStart.Offset, exceptionHandler.FilterEnd.Offset);
}
writer.Write(" IL_{0:x4}-IL_{1:x4} ", exceptionHandler.HandlerStart.Offset, exceptionHandler.HandlerEnd.Offset);
}
public static string OffsetToString(int offset) public static string OffsetToString(int offset)
{ {
return string.Format("IL_{0:x4}", offset); return string.Format("IL_{0:x4}", offset);
} }
public static string OperandToString(object operand) public static HashSet<MethodDefinition> GetAccessorMethods(this TypeDefinition type)
{ {
if(null == operand) throw new ArgumentNullException("operand"); HashSet<MethodDefinition> accessorMethods = new HashSet<MethodDefinition>();
foreach (var property in type.Properties) {
Instruction targetInstruction = operand as Instruction; accessorMethods.Add(property.GetMethod);
if(null != targetInstruction) { accessorMethods.Add(property.SetMethod);
return OffsetToString(targetInstruction.Offset); if (property.HasOtherMethods) {
} foreach (var m in property.OtherMethods)
accessorMethods.Add(m);
Instruction [] targetInstructions = operand as Instruction []; }
if(null != targetInstructions) {
return string.Join(", ", targetInstructions.Select(i => OffsetToString(i.Offset)));
}
VariableReference variableRef = operand as VariableReference;
if(null != variableRef) {
return variableRef.Index.ToString();
}
MethodReference methodRef = operand as MethodReference;
if(null != methodRef) {
return methodRef.ToString();
} }
foreach (EventDefinition ev in type.Events) {
string s = operand as string; accessorMethods.Add(ev.AddMethod);
if(null != s) { accessorMethods.Add(ev.RemoveMethod);
return "\"" + s + "\""; accessorMethods.Add(ev.InvokeMethod);
if (ev.HasOtherMethods) {
foreach (var m in ev.OtherMethods)
accessorMethods.Add(m);
}
} }
return accessorMethods;
return operand.ToString();
} }
} }
} }

5
ILSpy/Disassembler/DisassemblerHelpers.cs → ICSharpCode.Decompiler/Disassembler/DisassemblerHelpers.cs

@ -18,13 +18,12 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
namespace ICSharpCode.ILSpy.Disassembler namespace ICSharpCode.Decompiler.Disassembler
{ {
static class DisassemblerHelpers public static class DisassemblerHelpers
{ {
public static void WriteOffsetReference(ITextOutput writer, Instruction instruction) public static void WriteOffsetReference(ITextOutput writer, Instruction instruction)
{ {

11
ILSpy/Disassembler/MethodBodyDisassembler.cs → ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs

@ -20,16 +20,17 @@ using System;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.FlowAnalysis; using ICSharpCode.Decompiler.FlowAnalysis;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
namespace ICSharpCode.ILSpy.Disassembler namespace ICSharpCode.Decompiler.Disassembler
{ {
/// <summary> /// <summary>
/// Disassembles a method body. /// Disassembles a method body.
/// </summary> /// </summary>
public class MethodBodyDisassembler public sealed class MethodBodyDisassembler
{ {
readonly ITextOutput output; readonly ITextOutput output;
readonly bool detectControlStructure; readonly bool detectControlStructure;
@ -47,8 +48,8 @@ namespace ICSharpCode.ILSpy.Disassembler
public void Disassemble(MethodBody body) public void Disassemble(MethodBody body)
{ {
MethodDefinition method = body.Method; MethodDefinition method = body.Method;
output.WriteCommentLine("// Method begins at RVA 0x{0:x4}", method.RVA); output.WriteLine("// Method begins at RVA 0x{0:x4}", method.RVA);
output.WriteCommentLine("// Code size {0} (0x{0:x})", body.CodeSize); output.WriteLine("// Code size {0} (0x{0:x})", body.CodeSize);
output.WriteLine(".maxstack {0}", body.MaxStackSize); output.WriteLine(".maxstack {0}", body.MaxStackSize);
if (method.DeclaringType.Module.Assembly.EntryPoint == method) if (method.DeclaringType.Module.Assembly.EntryPoint == method)
output.WriteLine (".entrypoint"); output.WriteLine (".entrypoint");
@ -149,7 +150,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.Unindent(); output.Unindent();
switch (s.Type) { switch (s.Type) {
case ControlStructureType.Loop: case ControlStructureType.Loop:
output.WriteCommentLine("// end loop"); output.WriteLine("// end loop");
break; break;
case ControlStructureType.Try: case ControlStructureType.Try:
output.WriteLine("} // end .try"); output.WriteLine("} // end .try");

14
ILSpy/Disassembler/ReflectionDisassembler.cs → ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -23,12 +23,12 @@ using System.Threading;
using Mono.Cecil; using Mono.Cecil;
using Mono.Collections.Generic; using Mono.Collections.Generic;
namespace ICSharpCode.ILSpy.Disassembler namespace ICSharpCode.Decompiler.Disassembler
{ {
/// <summary> /// <summary>
/// Disassembles type and member definitions. /// Disassembles type and member definitions.
/// </summary> /// </summary>
public class ReflectionDisassembler public sealed class ReflectionDisassembler
{ {
ITextOutput output; ITextOutput output;
CancellationToken cancellationToken; CancellationToken cancellationToken;
@ -345,7 +345,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.WriteLine(); output.WriteLine();
} }
if (type.HasNestedTypes) { if (type.HasNestedTypes) {
output.WriteCommentLine("// Nested Types"); output.WriteLine("// Nested Types");
foreach (var nestedType in type.NestedTypes) { foreach (var nestedType in type.NestedTypes) {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
DisassembleType(nestedType); DisassembleType(nestedType);
@ -354,7 +354,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.WriteLine(); output.WriteLine();
} }
if (type.HasFields) { if (type.HasFields) {
output.WriteCommentLine("// Fields"); output.WriteLine("// Fields");
foreach (var field in type.Fields) { foreach (var field in type.Fields) {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
DisassembleField(field); DisassembleField(field);
@ -362,7 +362,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.WriteLine(); output.WriteLine();
} }
if (type.HasProperties) { if (type.HasProperties) {
output.WriteCommentLine("// Properties"); output.WriteLine("// Properties");
foreach (var prop in type.Properties) { foreach (var prop in type.Properties) {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
DisassembleProperty(prop); DisassembleProperty(prop);
@ -370,7 +370,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.WriteLine(); output.WriteLine();
} }
if (type.HasEvents) { if (type.HasEvents) {
output.WriteCommentLine("// Events"); output.WriteLine("// Events");
foreach (var ev in type.Events) { foreach (var ev in type.Events) {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
DisassembleEvent(ev); DisassembleEvent(ev);
@ -379,7 +379,7 @@ namespace ICSharpCode.ILSpy.Disassembler
output.WriteLine(); output.WriteLine();
} }
if (type.HasMethods) { if (type.HasMethods) {
output.WriteCommentLine("// Methods"); output.WriteLine("// Methods");
var accessorMethods = type.GetAccessorMethods(); var accessorMethods = type.GetAccessorMethods();
foreach (var m in type.Methods) { foreach (var m in type.Methods) {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();

6
ICSharpCode.Decompiler/FlowAnalysis/ControlFlowNode.cs

@ -22,7 +22,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ICSharpCode.Decompiler.Disassembler;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
namespace ICSharpCode.Decompiler.FlowAnalysis namespace ICSharpCode.Decompiler.FlowAnalysis
@ -239,7 +239,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
case ControlFlowNodeType.CatchHandler: case ControlFlowNodeType.CatchHandler:
case ControlFlowNodeType.FinallyOrFaultHandler: case ControlFlowNodeType.FinallyOrFaultHandler:
writer.Write("Block #{0}: {1}: ", BlockIndex, NodeType); writer.Write("Block #{0}: {1}: ", BlockIndex, NodeType);
ExceptionHandler.WriteTo(writer); Disassembler.DisassemblerHelpers.WriteTo(ExceptionHandler, new PlainTextOutput(writer));
break; break;
default: default:
writer.Write("Block #{0}: {1}", BlockIndex, NodeType); writer.Write("Block #{0}: {1}", BlockIndex, NodeType);
@ -255,7 +255,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
} }
foreach (Instruction inst in this.Instructions) { foreach (Instruction inst in this.Instructions) {
writer.WriteLine(); writer.WriteLine();
inst.WriteTo(writer); Disassembler.DisassemblerHelpers.WriteTo(inst, new PlainTextOutput(writer));
} }
return writer.ToString(); return writer.ToString();
} }

6
ICSharpCode.Decompiler/FlowAnalysis/SsaInstruction.cs

@ -19,7 +19,7 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using ICSharpCode.Decompiler.Disassembler;
using Mono.Cecil; using Mono.Cecil;
using Mono.Cecil.Cil; using Mono.Cecil.Cil;
@ -143,7 +143,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
public void WriteTo(TextWriter writer) public void WriteTo(TextWriter writer)
{ {
foreach (Instruction prefix in this.Prefixes) { foreach (Instruction prefix in this.Prefixes) {
prefix.WriteTo(writer); Disassembler.DisassemblerHelpers.WriteTo(prefix, new PlainTextOutput(writer));
writer.WriteLine(); writer.WriteLine();
} }
if (Instruction != null && Instruction.Offset >= 0) { if (Instruction != null && Instruction.Offset >= 0) {
@ -166,7 +166,7 @@ namespace ICSharpCode.Decompiler.FlowAnalysis
writer.Write(Instruction.OpCode.Name); writer.Write(Instruction.OpCode.Name);
if(null != Instruction.Operand) { if(null != Instruction.Operand) {
writer.Write(' '); writer.Write(' ');
writer.Write(CecilExtensions.OperandToString(Instruction.Operand)); Disassembler.DisassemblerHelpers.WriteOperand(new PlainTextOutput(writer), Instruction.Operand);
writer.Write(' '); writer.Write(' ');
} }
} }

8
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -50,6 +50,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CecilExtensions.cs" /> <Compile Include="CecilExtensions.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
<Compile Include="Disassembler\MethodBodyDisassembler.cs" />
<Compile Include="Disassembler\ReflectionDisassembler.cs" />
<Compile Include="FlowAnalysis\ControlFlowEdge.cs" /> <Compile Include="FlowAnalysis\ControlFlowEdge.cs" />
<Compile Include="FlowAnalysis\ControlFlowGraph.cs" /> <Compile Include="FlowAnalysis\ControlFlowGraph.cs" />
<Compile Include="FlowAnalysis\ControlFlowGraphBuilder.cs" /> <Compile Include="FlowAnalysis\ControlFlowGraphBuilder.cs" />
@ -65,6 +68,8 @@
<Compile Include="FlowAnalysis\SsaVariable.cs" /> <Compile Include="FlowAnalysis\SsaVariable.cs" />
<Compile Include="FlowAnalysis\TransformToSsa.cs" /> <Compile Include="FlowAnalysis\TransformToSsa.cs" />
<Compile Include="GraphVizGraph.cs" /> <Compile Include="GraphVizGraph.cs" />
<Compile Include="ITextOutput.cs" />
<Compile Include="PlainTextOutput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Properties\AssemblyInfo.template.cs" /> <None Include="Properties\AssemblyInfo.template.cs" />
</ItemGroup> </ItemGroup>
@ -74,6 +79,9 @@
<Name>Mono.Cecil</Name> <Name>Mono.Cecil</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Disassembler" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug" /> <MSBuild Projects="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug" />

56
ICSharpCode.Decompiler/ITextOutput.cs

@ -0,0 +1,56 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Text;
namespace ICSharpCode.Decompiler
{
public interface ITextOutput
{
void Indent();
void Unindent();
void Write(char ch);
void Write(string text);
void WriteLine();
void WriteDefinition(string text, object definition);
void WriteReference(string text, object reference);
void MarkFoldStart(string collapsedText = "...", bool defaultCollapsed = false);
void MarkFoldEnd();
}
public static class TextOutputExtensions
{
public static void Write(this ITextOutput output, string format, params object[] args)
{
output.Write(string.Format(format, args));
}
public static void WriteLine(this ITextOutput output, string text)
{
output.Write(text);
output.WriteLine();
}
public static void WriteLine(this ITextOutput output, string format, params object[] args)
{
output.WriteLine(string.Format(format, args));
}
}
}

50
ILSpy/ITextOutput.cs → ICSharpCode.Decompiler/PlainTextOutput.cs

@ -17,34 +17,32 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.IO;
using System.Text; using System.Text;
namespace ICSharpCode.ILSpy namespace ICSharpCode.Decompiler
{ {
public interface ITextOutput public sealed class PlainTextOutput : ITextOutput
{ {
void Indent(); readonly TextWriter writer;
void Unindent();
void Write(char ch);
void Write(string text);
void WriteCommentLine(string comment);
void WriteLine();
void WriteDefinition(string text, object definition);
void WriteReference(string text, object reference);
void MarkFoldStart(string collapsedText = "...", bool defaultCollapsed = false);
void MarkFoldEnd();
}
public class PlainTextOutput : ITextOutput
{
readonly StringBuilder b = new StringBuilder();
int indent; int indent;
bool needsIndent; bool needsIndent;
public PlainTextOutput(TextWriter writer)
{
if (writer == null)
throw new ArgumentNullException("writer");
this.writer = writer;
}
public PlainTextOutput()
{
this.writer = new StringWriter();
}
public override string ToString() public override string ToString()
{ {
return b.ToString(); return writer.ToString();
} }
public void Indent() public void Indent()
@ -62,7 +60,7 @@ namespace ICSharpCode.ILSpy
if (needsIndent) { if (needsIndent) {
needsIndent = false; needsIndent = false;
for (int i = 0; i < indent; i++) { for (int i = 0; i < indent; i++) {
b.Append('\t'); writer.Write('\t');
} }
} }
} }
@ -70,24 +68,18 @@ namespace ICSharpCode.ILSpy
public void Write(char ch) public void Write(char ch)
{ {
WriteIndent(); WriteIndent();
b.Append(ch); writer.Write(ch);
} }
public void Write(string text) public void Write(string text)
{ {
WriteIndent(); WriteIndent();
b.Append(text); writer.Write(text);
}
public void WriteCommentLine(string comment)
{
Write(comment);
WriteLine();
} }
public void WriteLine() public void WriteLine()
{ {
b.AppendLine(); writer.WriteLine();
needsIndent = true; needsIndent = true;
} }

1
ILSpy/Decompiler/CSharpLanguage.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy.Decompiler namespace ICSharpCode.ILSpy.Decompiler

7
ILSpy/Disassembler/ILLanguage.cs

@ -19,6 +19,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy.Disassembler namespace ICSharpCode.ILSpy.Disassembler
@ -72,8 +75,8 @@ namespace ICSharpCode.ILSpy.Disassembler
public override void DecompileAssembly(AssemblyDefinition assembly, string fileName, ITextOutput output, DecompilationOptions options) public override void DecompileAssembly(AssemblyDefinition assembly, string fileName, ITextOutput output, DecompilationOptions options)
{ {
output.WriteCommentLine("// " + fileName); output.WriteLine("// " + fileName);
output.WriteCommentLine(""); output.WriteLine();
new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).WriteAssemblyHeader(assembly); new ReflectionDisassembler(output, detectControlStructure, options.CancellationToken).WriteAssemblyHeader(assembly);
} }

44
ILSpy/ExtensionMethods.cs

@ -35,50 +35,6 @@ namespace ICSharpCode.ILSpy
list.Add(item); list.Add(item);
} }
public static void Write(this ITextOutput output, string format, params object[] args)
{
output.Write(string.Format(format, args));
}
public static void WriteLine(this ITextOutput output, string text)
{
output.Write(text);
output.WriteLine();
}
public static void WriteLine(this ITextOutput output, string format, params object[] args)
{
output.WriteLine(string.Format(format, args));
}
public static void WriteCommentLine(this ITextOutput output, string format, params object[] args)
{
output.WriteCommentLine(string.Format(format, args));
}
public static HashSet<MethodDefinition> GetAccessorMethods(this TypeDefinition type)
{
HashSet<MethodDefinition> accessorMethods = new HashSet<MethodDefinition>();
foreach (var property in type.Properties) {
accessorMethods.Add(property.GetMethod);
accessorMethods.Add(property.SetMethod);
if (property.HasOtherMethods) {
foreach (var m in property.OtherMethods)
accessorMethods.Add(m);
}
}
foreach (EventDefinition ev in type.Events) {
accessorMethods.Add(ev.AddMethod);
accessorMethods.Add(ev.RemoveMethod);
accessorMethods.Add(ev.InvokeMethod);
if (ev.HasOtherMethods) {
foreach (var m in ev.OtherMethods)
accessorMethods.Add(m);
}
}
return accessorMethods;
}
/// <summary> /// <summary>
/// Sets the value of a dependency property on <paramref name="targetObject"/> using a markup extension. /// Sets the value of a dependency property on <paramref name="targetObject"/> using a markup extension.
/// </summary> /// </summary>

33
ILSpy/ILSpy.csproj

@ -81,31 +81,17 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="AssemblyList.cs" /> <Compile Include="AssemblyList.cs" />
<Compile Include="AssemblyListTreeNode.cs" />
<Compile Include="AssemblyReferenceTreeNode.cs" />
<Compile Include="AssemblyTreeNode.cs" />
<Compile Include="BaseTypesTreeNode.cs" />
<Compile Include="CueBannerService.cs" /> <Compile Include="CueBannerService.cs" />
<Compile Include="DecompilationOptions.cs" /> <Compile Include="DecompilationOptions.cs" />
<Compile Include="Decompiler\CSharpLanguage.cs" /> <Compile Include="Decompiler\CSharpLanguage.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
<Compile Include="Disassembler\ILLanguage.cs" /> <Compile Include="Disassembler\ILLanguage.cs" />
<Compile Include="Disassembler\MethodBodyDisassembler.cs" />
<Compile Include="Disassembler\ReflectionDisassembler.cs" />
<Compile Include="EventTreeNode.cs" />
<Compile Include="ExtensionMethods.cs" /> <Compile Include="ExtensionMethods.cs" />
<Compile Include="FieldTreeNode.cs" />
<Compile Include="FilterSettings.cs" /> <Compile Include="FilterSettings.cs" />
<Compile Include="Fusion.cs" /> <Compile Include="Fusion.cs" />
<Compile Include="GacInterop.cs" /> <Compile Include="GacInterop.cs" />
<Compile Include="ILSpyTreeNode.cs" />
<Compile Include="ITextOutput.cs" />
<Compile Include="Language.cs" /> <Compile Include="Language.cs" />
<Compile Include="Images\Images.cs" /> <Compile Include="Images\Images.cs" />
<Compile Include="MethodTreeNode.cs" />
<Compile Include="ModuleReferenceTreeNode.cs" />
<Compile Include="Mono.Cecil.Rocks\MethodBodyRocks.cs" /> <Compile Include="Mono.Cecil.Rocks\MethodBodyRocks.cs" />
<Compile Include="NamespaceTreeNode.cs" />
<Compile Include="OpenFromGacDialog.xaml.cs"> <Compile Include="OpenFromGacDialog.xaml.cs">
<DependentUpon>OpenFromGacDialog.xaml</DependentUpon> <DependentUpon>OpenFromGacDialog.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
@ -117,16 +103,26 @@
<SubType>Code</SubType> <SubType>Code</SubType>
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="PropertyTreeNode.cs" />
<Compile Include="ReferenceFolderTreeNode.cs" />
<Compile Include="ResourceListTreeNode.cs" />
<Compile Include="SortableGridViewColumn.cs" /> <Compile Include="SortableGridViewColumn.cs" />
<Compile Include="TextView\CaretHighlightAdorner.cs" /> <Compile Include="TextView\CaretHighlightAdorner.cs" />
<Compile Include="TextView\DecompilerTextView.cs" /> <Compile Include="TextView\DecompilerTextView.cs" />
<Compile Include="TextView\ReferenceElementGenerator.cs" /> <Compile Include="TextView\ReferenceElementGenerator.cs" />
<Compile Include="TextView\SmartTextOutput.cs" /> <Compile Include="TextView\SmartTextOutput.cs" />
<Compile Include="TreeNodes\AssemblyListTreeNode.cs" />
<Compile Include="TreeNodes\AssemblyReferenceTreeNode.cs" />
<Compile Include="TreeNodes\AssemblyTreeNode.cs" />
<Compile Include="TreeNodes\BaseTypesTreeNode.cs" />
<Compile Include="TreeNodes\EventTreeNode.cs" />
<Compile Include="TreeNodes\FieldTreeNode.cs" />
<Compile Include="TreeNodes\ILSpyTreeNode.cs" />
<Compile Include="TreeNodes\MethodTreeNode.cs" />
<Compile Include="TreeNodes\ModuleReferenceTreeNode.cs" />
<Compile Include="TreeNodes\NamespaceTreeNode.cs" />
<Compile Include="TreeNodes\PropertyTreeNode.cs" />
<Compile Include="TreeNodes\ReferenceFolderTreeNode.cs" />
<Compile Include="TreeNodes\ResourceListTreeNode.cs" />
<Compile Include="TreeNodes\TypeTreeNode.cs" />
<Compile Include="TreeTraversal.cs" /> <Compile Include="TreeTraversal.cs" />
<Compile Include="TypeTreeNode.cs" />
<EmbeddedResource Include="TextView\ILAsm-Mode.xshd" /> <EmbeddedResource Include="TextView\ILAsm-Mode.xshd" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -201,6 +197,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="TreeNodes" />
<Folder Include="TextView" /> <Folder Include="TextView" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />

2
ILSpy/Language.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

2
ILSpy/TextView/SmartTextOutput.cs

@ -19,8 +19,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Folding; using ICSharpCode.AvalonEdit.Folding;
using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy.TextView namespace ICSharpCode.ILSpy.TextView
{ {

8
ILSpy/AssemblyListTreeNode.cs → ILSpy/TreeNodes/AssemblyListTreeNode.cs

@ -17,22 +17,16 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading;
using System.Windows; using System.Windows;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
/// <summary> /// <summary>
/// Represents a list of assemblies. /// Represents a list of assemblies.
/// This is used as (invisible) root node of the tree view.
/// </summary> /// </summary>
sealed class AssemblyListTreeNode : ILSpyTreeNode<AssemblyTreeNode> sealed class AssemblyListTreeNode : ILSpyTreeNode<AssemblyTreeNode>
{ {

0
ILSpy/AssemblyReferenceTreeNode.cs → ILSpy/TreeNodes/AssemblyReferenceTreeNode.cs

2
ILSpy/AssemblyTreeNode.cs → ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -24,6 +24,8 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using ICSharpCode.Decompiler;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
using Mono.Cecil; using Mono.Cecil;

0
ILSpy/BaseTypesTreeNode.cs → ILSpy/TreeNodes/BaseTypesTreeNode.cs

1
ILSpy/EventTreeNode.cs → ILSpy/TreeNodes/EventTreeNode.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

1
ILSpy/FieldTreeNode.cs → ILSpy/TreeNodes/FieldTreeNode.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

1
ILSpy/ILSpyTreeNode.cs → ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -21,6 +21,7 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using ICSharpCode.Decompiler;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

1
ILSpy/MethodTreeNode.cs → ILSpy/TreeNodes/MethodTreeNode.cs

@ -18,6 +18,7 @@
using System; using System;
using System.Text; using System.Text;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

0
ILSpy/ModuleReferenceTreeNode.cs → ILSpy/TreeNodes/ModuleReferenceTreeNode.cs

1
ILSpy/NamespaceTreeNode.cs → ILSpy/TreeNodes/NamespaceTreeNode.cs

@ -18,6 +18,7 @@
using System; using System;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {

1
ILSpy/PropertyTreeNode.cs → ILSpy/TreeNodes/PropertyTreeNode.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

0
ILSpy/ReferenceFolderTreeNode.cs → ILSpy/TreeNodes/ReferenceFolderTreeNode.cs

0
ILSpy/ResourceListTreeNode.cs → ILSpy/TreeNodes/ResourceListTreeNode.cs

1
ILSpy/TypeTreeNode.cs → ILSpy/TreeNodes/TypeTreeNode.cs

@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows.Media; using System.Windows.Media;
using ICSharpCode.Decompiler;
using Mono.Cecil; using Mono.Cecil;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
Loading…
Cancel
Save