From c06299b28410a36d22b143f6828b26444642a580 Mon Sep 17 00:00:00 2001 From: Shimon Magal Date: Thu, 5 Dec 2019 22:59:03 +0200 Subject: [PATCH] yield return moveNext --- .../IL/ControlFlow/YieldReturnDecompiler.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs index 5156a9fef..0c377228e 100644 --- a/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs +++ b/ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs @@ -131,7 +131,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow AnalyzeCurrentProperty(); ResolveIEnumerableIEnumeratorFieldMapping(); ConstructExceptionTable(); - newBody = AnalyzeMoveNext(); + newBody = AnalyzeMoveNext(function); } catch (SymbolicAnalysisFailedException) { return; } @@ -525,12 +525,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow #endregion #region Analyze MoveNext() and generate new body - BlockContainer AnalyzeMoveNext() + BlockContainer AnalyzeMoveNext(ILFunction function) { context.StepStartGroup("AnalyzeMoveNext"); MethodDefinitionHandle moveNextMethod = metadata.GetTypeDefinition(enumeratorType).GetMethods().FirstOrDefault(m => metadata.GetString(metadata.GetMethodDefinition(m).Name) == "MoveNext"); ILFunction moveNextFunction = CreateILAst(moveNextMethod, context); + function.MoveNextMethod = moveNextFunction.Method; + // Copy-propagate temporaries holding a copy of 'this'. // This is necessary because the old (pre-Roslyn) C# compiler likes to store 'this' in temporary variables. foreach (var stloc in moveNextFunction.Descendants.OfType().Where(s => s.Variable.IsSingleDefinition && s.Value.MatchLdThis()).ToList()) {