From fa57b9769f6da136c84c3fa664bac65f6a25471a Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 28 Mar 2018 01:17:12 +0200 Subject: [PATCH] Port AsyncAwaitDecompiler.IsCompilerGeneratedMainMethod --- .../IL/ControlFlow/AsyncAwaitDecompiler.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs index fc62c570e..2980cf6c1 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs @@ -20,7 +20,6 @@ using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.IL.Transforms; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.Util; -using Mono.Cecil; using System; using System.Collections.Generic; using System.Diagnostics; @@ -45,9 +44,12 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow return false; } - public static bool IsCompilerGeneratedMainMethod(MethodDefinition method) + public static bool IsCompilerGeneratedMainMethod(Metadata.PEFile module, System.Reflection.Metadata.MethodDefinitionHandle method) { - return method == method.Module.Assembly?.EntryPoint && method.Name.Equals("
", StringComparison.Ordinal); + var metadata = module.GetMetadataReader(); + var definition = metadata.GetMethodDefinition(method); + var entrypoint = System.Reflection.Metadata.Ecma335.MetadataTokens.MethodDefinitionHandle(module.Reader.PEHeaders.CorHeader.EntryPointTokenOrRelativeVirtualAddress); + return method == entrypoint && metadata.GetString(definition.Name).Equals("
", StringComparison.Ordinal); } enum AsyncMethodType