Browse Source

Adjust AsyncAwaitDecompiler to Roslyn 3.9.0.

pull/2423/head
Daniel Grunwald 4 years ago
parent
commit
407ec6be5b
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/FunctionPointers.cs
  2. 29
      ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
  3. 2
      packages.props

9
ICSharpCode.Decompiler.Tests/TestCases/Pretty/FunctionPointers.cs

@ -107,11 +107,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
public unsafe delegate*<in byte, ref char, out float, ref readonly int> F1;
public unsafe delegate*<ref char, out float, ref int> F2;
// TODO: re-enable test after https://github.com/dotnet/roslyn/issues/47487 is fixed
//public unsafe int CallF1(byte b, char c, out float f)
//{
// return F1(1, ref c, out f);
//}
public unsafe int CallF1(byte b, char c, out float f)
{
return F1(in b, ref c, out f);
}
public unsafe void CallF2(byte b, char c, out float f)
{

29
ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs

@ -815,9 +815,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
void CheckSetResultAndExit(BlockContainer blockContainer, Block block, ref int pos)
{
// [optional] call Complete(ldflda <>t__builder(ldloc this)) (Roslyn >=3.9)
// call SetResult(ldflda <>t__builder(ldloc this), ldloc result)
// [optional] call Complete(ldflda <>t__builder(ldloc this))
// leave IL_0000
MatchCompleteCall(block, ref pos);
if (!MatchCall(block.Instructions[pos], "SetResult", out var args))
throw new SymbolicAnalysisFailedException();
if (!IsBuilderOrPromiseFieldOnThis(args[0]))
@ -846,12 +848,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
break;
}
pos++;
if (MatchCall(block.Instructions[pos], "Complete", out args))
{
if (!(args.Count == 1 && IsBuilderFieldOnThis(args[0])))
throw new SymbolicAnalysisFailedException();
pos++;
}
MatchCompleteCall(block, ref pos);
if (!block.Instructions[pos].MatchLeave(blockContainer))
throw new SymbolicAnalysisFailedException();
}
@ -913,6 +910,9 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
}
}
MatchHoistedLocalCleanup(catchBlock, ref pos);
// [optional] call Complete(ldfld <>t__builder(ldloc this))
MatchCompleteCall(catchBlock, ref pos);
// call SetException(ldfld <>t__builder(ldloc this), ldloc exception)
if (!MatchCall(catchBlock.Instructions[pos], "SetException", out var args))
throw new SymbolicAnalysisFailedException();
@ -925,12 +925,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
pos++;
// [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++;
}
MatchCompleteCall(catchBlock, ref pos);
// leave IL_0000
if (!catchBlock.Instructions[pos].MatchLeave((BlockContainer)moveNextFunction.Body))
@ -940,6 +935,16 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
throw new SymbolicAnalysisFailedException();
}
private void MatchCompleteCall(Block block, ref int pos)
{
if (MatchCall(block.Instructions[pos], "Complete", out var args))
{
if (!(args.Count == 1 && IsBuilderFieldOnThis(args[0])))
throw new SymbolicAnalysisFailedException();
pos++;
}
}
bool IsBuilderFieldOnThis(ILInstruction inst)
{
IField field;

2
packages.props

@ -10,7 +10,7 @@
<SystemCompilerServicesUnsafeVersion>5.0.0</SystemCompilerServicesUnsafeVersion>
<SystemCompositionVersion>5.0.1</SystemCompositionVersion>
<ILAsmVersion>5.0.0</ILAsmVersion> <!-- Microsoft.NETCore.ILAsm -->
<RoslynVersion>3.8.0</RoslynVersion> <!-- Microsoft.CodeAnalysis.* -->
<RoslynVersion>3.9.0</RoslynVersion> <!-- Microsoft.CodeAnalysis.* -->
<MonoCecilVersion>0.11.3</MonoCecilVersion>
<AvalonEditVersion>6.1.1</AvalonEditVersion>
<NUnitVersion>3.12.0</NUnitVersion>

Loading…
Cancel
Save