From c81f81827f99dc4dcb7ef54b2acb3673300daf8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Zgodzi=C5=84ski?= Date: Wed, 6 Apr 2011 22:22:38 +0200 Subject: [PATCH] Implemented printing of .overrides and interfaces directives in IL. --- .../Disassembler/MethodBodyDisassembler.cs | 3 +++ .../Disassembler/ReflectionDisassembler.cs | 16 ++++++++++++++++ .../Tests/ICSharpCode.Decompiler.Tests.csproj | 1 + .../Tests/Types/S_TypeDeclarations.cs | 17 +++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 ICSharpCode.Decompiler/Tests/Types/S_TypeDeclarations.cs diff --git a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs index 55ff87df0..32161a3f8 100644 --- a/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs +++ b/ICSharpCode.Decompiler/Disassembler/MethodBodyDisassembler.cs @@ -49,6 +49,9 @@ namespace ICSharpCode.Decompiler.Disassembler { MethodDefinition method = body.Method; output.WriteLine("// Method begins at RVA 0x{0:x4}", method.RVA); + if (method.HasOverrides) + foreach (var methodOverride in method.Overrides) + output.WriteLine(".override {0}::{1}", methodOverride.DeclaringType.FullName, methodOverride.Name); output.WriteLine("// Code size {0} (0x{0:x})", body.CodeSize); output.WriteLine(".maxstack {0}", body.MaxStackSize); if (method.DeclaringType.Module.Assembly.EntryPoint == method) diff --git a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs index fb0d9d1e2..db4699562 100644 --- a/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs +++ b/ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs @@ -333,6 +333,22 @@ namespace ICSharpCode.Decompiler.Disassembler output.WriteLine(); output.Unindent(); } + if (type.HasInterfaces) { + output.Indent(); + for (int index = 0; index < type.Interfaces.Count; index++) { + if (index > 0) + output.WriteLine(","); + if (index == 0) + output.Write("implements "); + else + output.Write(" "); + if (type.Interfaces[index].Namespace != null) + output.Write("{0}.", type.Interfaces[index].Namespace); + output.Write(type.Interfaces[index].Name); + } + output.WriteLine(); + output.Unindent(); + } output.WriteLine("{"); output.Indent(); diff --git a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj index 91567fe5c..d2ccdaff4 100644 --- a/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj +++ b/ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj @@ -56,6 +56,7 @@ + diff --git a/ICSharpCode.Decompiler/Tests/Types/S_TypeDeclarations.cs b/ICSharpCode.Decompiler/Tests/Types/S_TypeDeclarations.cs new file mode 100644 index 000000000..99bf4279e --- /dev/null +++ b/ICSharpCode.Decompiler/Tests/Types/S_TypeDeclarations.cs @@ -0,0 +1,17 @@ +using System; + +namespace ClassMultiInterface +{ + public interface IA + { + } + public interface IA2 : IA + { + } + public interface IB + { + } + public class C : IA2, IB + { + } +}