From a997ea2068a13f836a6fa0c2703c73491630cbf0 Mon Sep 17 00:00:00 2001 From: LordJZ Date: Thu, 28 Aug 2014 11:49:42 +0400 Subject: [PATCH] Fixed decompiling empty async methods. Fixes #417 #446 #479 --- ICSharpCode.Decompiler/ILAst/StateRange.cs | 3 +++ ICSharpCode.Decompiler/Tests/Async.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/ICSharpCode.Decompiler/ILAst/StateRange.cs b/ICSharpCode.Decompiler/ILAst/StateRange.cs index 3a3dfc2f3..e41b800cb 100644 --- a/ICSharpCode.Decompiler/ILAst/StateRange.cs +++ b/ICSharpCode.Decompiler/ILAst/StateRange.cs @@ -212,6 +212,9 @@ namespace ICSharpCode.Decompiler.ILAst case ILCode.Br: case ILCode.Leave: ranges[(ILLabel)expr.Operand].UnionWith(nodeRange); + if (i == bodyLength - 1) + // no states + goto default; break; case ILCode.Brtrue: { diff --git a/ICSharpCode.Decompiler/Tests/Async.cs b/ICSharpCode.Decompiler/Tests/Async.cs index 7629dd5e6..b414b21b6 100644 --- a/ICSharpCode.Decompiler/Tests/Async.cs +++ b/ICSharpCode.Decompiler/Tests/Async.cs @@ -25,6 +25,10 @@ using System.Threading.Tasks; public class Async { + public async void EmptyAsyncMethod() + { + } + public async void SimpleVoidMethod() { Console.WriteLine("Before");