Browse Source

Fix tests on Windows with legacy csc.

There's an additional local variable when decompiling the non-optimized code; and explicitly putting that variable
into the test case just makes it fail due to yet another additional variable.
pull/4021/head
Daniel Grunwald 4 weeks ago
parent
commit
59d8ae904b
  1. 63
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs
  2. 9
      ICSharpCode.Decompiler/IL/Instructions/Branch.cs
  3. 15
      ICSharpCode.Decompiler/IL/Instructions/Leave.cs

63
ICSharpCode.Decompiler.Tests/TestCases/Pretty/AsyncAwaitPatterns.cs

@ -81,70 +81,52 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait @@ -81,70 +81,52 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait
Console.WriteLine(await Get());
}
#if ROSLYN2 || OPT
public async Task BinaryOperator()
{
#if ROSLYN2 || OPT
Console.WriteLine(await Get() + await Get());
#else
int value = await Get() + await Get();
Console.WriteLine(value);
#endif
}
#endif
#if ROSLYN2 || OPT
public async Task UnaryOperator()
{
#if ROSLYN2 || OPT
Console.WriteLine(-(await Get()));
#else
int value = -(await Get());
Console.WriteLine(value);
#endif
}
#endif
#if ROSLYN2 || OPT
public async Task MemberAccessOnResult()
{
#if ROSLYN2 || OPT
Console.WriteLine((await GetString()).Length);
#else
int length = (await GetString()).Length;
Console.WriteLine(length);
#endif
}
#endif
#if ROSLYN2 || OPT
public async Task IndexerOnResult()
{
#if ROSLYN2 || OPT
Console.WriteLine((await GetString())[0]);
#else
char value = (await GetString())[0];
Console.WriteLine(value);
#endif
}
#endif
#if ROSLYN2 || OPT
public async Task CoalesceOnResult()
{
#if ROSLYN2 || OPT
Console.WriteLine((await GetString()) ?? "null");
#else
string value = (await GetString()) ?? "null";
Console.WriteLine(value);
#endif
}
#endif
public async Task ThrowAwaitedException()
{
throw await GetException();
}
#if ROSLYN2 || OPT
public async Task Checked()
{
#if ROSLYN2 || OPT
Console.WriteLine(checked(await Get() + 1));
#else
int value = checked(await Get() + 1);
Console.WriteLine(value);
#endif
}
#endif
#if CS60
public async Task TryFinally()
@ -253,15 +235,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait @@ -253,15 +235,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait
}
#endif
#if ROSLYN2 || OPT
public async Task AwaitInGenericMethod<T>(Task<T> task)
{
#if ROSLYN2 || OPT
Console.WriteLine(await task);
#else
object value = await task;
Console.WriteLine(value);
#endif
}
#endif
}
public static class AwaiterExtensions
@ -510,25 +489,19 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait @@ -510,25 +489,19 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.AsyncAwait
}
#endif
#if ROSLYN2
public async Task ExtensionAwaiterOverTaskArray(Task<int>[] tasks)
{
#if ROSLYN2 || OPT
Console.WriteLine((await tasks)[0]);
#else
int value = (await tasks)[0];
Console.WriteLine(value);
#endif
}
#endif
#if ROSLYN2
public async Task ExtensionAwaiterOverTaskList(List<Task<int>> tasks)
{
#if ROSLYN2 || OPT
Console.WriteLine((await tasks)[0]);
#else
int value = (await tasks)[0];
Console.WriteLine(value);
#endif
}
#endif
public async Task GenericAwaitableType(GenericAwaitable<string> awaitable)
{

9
ICSharpCode.Decompiler/IL/Instructions/Branch.cs

@ -27,6 +27,7 @@ namespace ICSharpCode.Decompiler.IL @@ -27,6 +27,7 @@ namespace ICSharpCode.Decompiler.IL
/// </summary>
/// <remarks>
/// When jumping to the entrypoint of the current block container, the branch represents a <c>continue</c> statement.
/// Will implicitly execute finally blocks when jumping out of a try-block.
/// </remarks>
partial class Branch : SimpleInstruction, IBranchOrLeaveInstruction
{
@ -129,6 +130,14 @@ namespace ICSharpCode.Decompiler.IL @@ -129,6 +130,14 @@ namespace ICSharpCode.Decompiler.IL
interface IBranchOrLeaveInstruction
{
/// <summary>
/// The block container that directly contains the jump target.
/// </summary>
BlockContainer TargetContainer { get; }
/// <summary>
/// Gets whether this branch executes at least one finally block before reaching the jump target.
/// </summary>
bool TriggersFinallyBlock { get; }
}
}

15
ICSharpCode.Decompiler/IL/Instructions/Leave.cs

@ -22,14 +22,14 @@ using System.Diagnostics; @@ -22,14 +22,14 @@ using System.Diagnostics;
namespace ICSharpCode.Decompiler.IL
{
/// <summary>
/// Unconditional branch. <c>goto target;</c>
/// Unconditional branch to end of block container.
/// Return is represented using IsLeavingFunction and an (optional) return value.
/// The block container evaluates to the value produced by the argument of the leave instruction.
/// </summary>
/// <remarks>
/// When jumping to the entrypoint of the current block container, the branch represents a <c>continue</c> statement.
///
/// Phase-1 execution of a branch is a no-op.
/// Phase-2 execution removes PopCount elements from the evaluation stack
/// and jumps to the target block.
/// While <c>Branch</c> jumps to the start of a block, <c>Leave</c> jumps to the end of a BlockContainer.
/// <c>Leave</c> often represents <c>break;</c> or <c>return;</c>.
/// Will implicitly execute finally blocks when jumping out of a try-block.
/// </remarks>
partial class Leave : ILInstruction, IBranchOrLeaveInstruction
{
@ -87,8 +87,7 @@ namespace ICSharpCode.Decompiler.IL @@ -87,8 +87,7 @@ namespace ICSharpCode.Decompiler.IL
/// Gets whether the leave instruction is directly leaving the whole ILFunction.
/// (TargetContainer == main container of the function).
///
/// This is only valid for functions returning void (representing value-less "return;"),
/// and for iterators (representing "yield break;").
/// Indicates the leave instruction represents a <c>return</c> statement.
///
/// Note: returns false for leave instructions that indirectly leave the function
/// (e.g. leaving a try block, and the try-finally construct is immediately followed

Loading…
Cancel
Save