From 8b1dce4aef62669da296319ea952a8f21e7c514b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 30 Mar 2018 16:40:40 +0200 Subject: [PATCH] Fix build of TestPlugin --- TestPlugin/CustomLanguage.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/TestPlugin/CustomLanguage.cs b/TestPlugin/CustomLanguage.cs index e47c30449..d0c428013 100644 --- a/TestPlugin/CustomLanguage.cs +++ b/TestPlugin/CustomLanguage.cs @@ -2,9 +2,10 @@ // This code is distributed under MIT X11 license (for details please see \doc\license.txt) using System.ComponentModel.Composition; +using System.Reflection.Metadata; using System.Windows.Controls; using ICSharpCode.Decompiler; -using ICSharpCode.Decompiler.Dom; +using ICSharpCode.Decompiler.Metadata; using ICSharpCode.ILSpy; namespace TestPlugin @@ -27,14 +28,15 @@ namespace TestPlugin return ".txt"; } } - + // There are several methods available to override; in this sample, we deal with methods only - - public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) + public override void DecompileMethod(ICSharpCode.Decompiler.Metadata.MethodDefinition method, ITextOutput output, DecompilationOptions options) { -#if false - if (method.Body != null) { - output.WriteLine("Size of method: {0} bytes", method.Body.CodeSize); + var metadata = method.Module.GetMetadataReader(); + var methodDef = metadata.GetMethodDefinition(method.Handle); + if (methodDef.HasBody()) { + var methodBody = method.Module.Reader.GetMethodBody(methodDef.RelativeVirtualAddress); + output.WriteLine("Size of method: {0} bytes", methodBody.GetCodeSize()); ISmartTextOutput smartOutput = output as ISmartTextOutput; if (smartOutput != null) { @@ -55,7 +57,6 @@ namespace TestPlugin syntaxTree.AcceptVisitor(visitor); */ } -#endif } } }