Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adjust async-streams decompiler for dotnet/roslyn#39436
  • Loading branch information
dgrunwald committed Nov 10, 2019
1 parent 7326a69 commit 1b505b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Expand Up @@ -42,8 +42,8 @@
<ItemGroup>
<PackageReference Include="DiffLib" Version="2017.7.26.1241" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0-beta3-final" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.4.0-beta3-final" />
<PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta1-63314-01" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
Expand Down
25 changes: 19 additions & 6 deletions ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
Expand Up @@ -625,9 +625,8 @@ void CheckSetResultAndExitBlock(BlockContainer blockContainer)
}
// stobj System.Int32(ldflda [Field ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async+<SimpleBoolTaskMethod>d__7.<>1__state](ldloc this), ldc.i4 -2)
// call SetResult(ldflda [Field ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async+<SimpleBoolTaskMethod>d__7.<>t__builder](ldloc this), ldloc result)
// [optional] call Complete(ldflda <>t__builder(ldloc this))
// leave IL_0000
if (setResultAndExitBlock.Instructions.Count != 3)
throw new SymbolicAnalysisFailedException();
if (!MatchStateAssignment(setResultAndExitBlock.Instructions[0], out finalState))
throw new SymbolicAnalysisFailedException();
finalStateKnown = true;
Expand Down Expand Up @@ -657,7 +656,13 @@ void CheckSetResultAndExitBlock(BlockContainer blockContainer)
throw new SymbolicAnalysisFailedException();
break;
}
if (!setResultAndExitBlock.Instructions[2].MatchLeave(blockContainer))
int pos = 2;
if (MatchCall(setResultAndExitBlock.Instructions[pos], "Complete", out args)) {
if (!(args.Count == 1 && IsBuilderFieldOnThis(args[0])))
throw new SymbolicAnalysisFailedException();
pos++;
}
if (!setResultAndExitBlock.Instructions[pos].MatchLeave(blockContainer))
throw new SymbolicAnalysisFailedException();
}

Expand All @@ -668,6 +673,7 @@ void ValidateCatchBlock()
// stloc exception(ldloc E_143)
// stfld <>1__state(ldloc this, ldc.i4 -2)
// call SetException(ldfld <>t__builder(ldloc this), ldloc exception)
// [optional] call Complete(ldfld <>t__builder(ldloc this))
// leave IL_0000
// }
// }
Expand All @@ -682,8 +688,6 @@ void ValidateCatchBlock()
if (catchBlock == null)
throw new SymbolicAnalysisFailedException();
catchHandlerOffset = catchBlock.StartILOffset;
if (catchBlock.Instructions.Count != 4)
throw new SymbolicAnalysisFailedException();
// stloc exception(ldloc E_143)
if (!(catchBlock.Instructions[0] is StLoc stloc))
throw new SymbolicAnalysisFailedException();
Expand All @@ -708,8 +712,17 @@ void ValidateCatchBlock()
throw new SymbolicAnalysisFailedException();
if (!args[1].MatchLdLoc(stloc.Variable))
throw new SymbolicAnalysisFailedException();

int pos = 3;
// [optional] call Complete(ldfld <>t__builder(ldloc this))
if (MatchCall(catchBlock.Instructions[pos], "Complete", out args)) {
if (!(args.Count == 1 && IsBuilderFieldOnThis(args[0])))
throw new SymbolicAnalysisFailedException();
pos++;
}

// leave IL_0000
if (!catchBlock.Instructions[3].MatchLeave((BlockContainer)moveNextFunction.Body))
if (!catchBlock.Instructions[pos].MatchLeave((BlockContainer)moveNextFunction.Body))
throw new SymbolicAnalysisFailedException();
}

Expand Down
4 changes: 2 additions & 2 deletions ILSpy.Tests/ILSpy.Tests.csproj
Expand Up @@ -42,8 +42,8 @@

<ItemGroup>
<PackageReference Include="DiffLib" Version="2017.7.26.1241" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0-beta3-final" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.4.0-beta3-final" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
Expand Down

0 comments on commit 1b505b8

Please sign in to comment.