|
|
|
@ -21,7 +21,7 @@ using System.Runtime.InteropServices;
@@ -21,7 +21,7 @@ using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty |
|
|
|
|
{ |
|
|
|
|
public static class LiftedOperators |
|
|
|
|
public static class T00_LiftedOperators |
|
|
|
|
{ |
|
|
|
|
// C# uses 4 different patterns of IL for lifted operators: bool, other primitive types, decimal, other structs.
|
|
|
|
|
// Different patterns are used depending on whether both of the operands are nullable or only the left/right operand is nullable.
|
|
|
|
@ -53,6 +53,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -53,6 +53,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
if (x() != a) { |
|
|
|
|
Console.WriteLine(); |
|
|
|
|
} |
|
|
|
|
if (a ?? x()) { |
|
|
|
|
Console.WriteLine(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void BoolConst(bool? a) |
|
|
|
@ -72,9 +75,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -72,9 +75,12 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
if (a ?? true) { |
|
|
|
|
Console.WriteLine(); |
|
|
|
|
} |
|
|
|
|
#if !ROSLYN
|
|
|
|
|
// Roslyn 3 (VS2019) started optimizing this to "a.GetValueOrDefault()"
|
|
|
|
|
if (a ?? false) { |
|
|
|
|
Console.WriteLine(); |
|
|
|
|
} |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void BoolValueBasic(bool? a, bool? b) |
|
|
|
@ -122,7 +128,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -122,7 +128,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
Console.WriteLine(a == false); |
|
|
|
|
Console.WriteLine(a != false); |
|
|
|
|
Console.WriteLine(a ?? true); |
|
|
|
|
#if !ROSLYN
|
|
|
|
|
// Roslyn 3 (VS2019) started optimizing this to "a.GetValueOrDefault()"
|
|
|
|
|
Console.WriteLine(a ?? false); |
|
|
|
|
#endif
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void IntBasic(int? a, int? b) |
|
|
|
@ -698,120 +707,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -698,120 +707,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// dummy structure for testing custom operators
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Size = 1)] |
|
|
|
|
public struct TS |
|
|
|
|
{ |
|
|
|
|
// unary
|
|
|
|
|
public static TS operator +(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator -(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator !(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ~(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ++(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator --(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static explicit operator int(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// binary
|
|
|
|
|
public static TS operator +(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator -(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator *(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator /(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator %(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator &(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator |(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ^(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator <<(TS a, int b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator >>(TS a, int b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// comparisons
|
|
|
|
|
public static bool operator ==(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator !=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator <(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator <=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator >(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator >=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public override int GetHashCode() |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal class LiftedImplicitConversions |
|
|
|
|
internal class T01_LiftedImplicitConversions |
|
|
|
|
{ |
|
|
|
|
public int? ExtendI4(byte? b) |
|
|
|
|
{ |
|
|
|
@ -871,7 +767,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -871,7 +767,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal class LiftedExplicitConversions |
|
|
|
|
internal class T02_LiftedExplicitConversions |
|
|
|
|
{ |
|
|
|
|
private static void Print<T>(T? x) where T : struct |
|
|
|
|
{ |
|
|
|
@ -899,7 +795,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -899,7 +795,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal class NullCoalescingTests |
|
|
|
|
internal class T03_NullCoalescingTests |
|
|
|
|
{ |
|
|
|
|
private static void Print<T>(T x) |
|
|
|
|
{ |
|
|
|
@ -983,4 +879,117 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@@ -983,4 +879,117 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
|
|
|
|
return 0L; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// dummy structure for testing custom operators
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Size = 1)] |
|
|
|
|
public struct TS |
|
|
|
|
{ |
|
|
|
|
// unary
|
|
|
|
|
public static TS operator +(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator -(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator !(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ~(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ++(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator --(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static explicit operator int(TS a) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// binary
|
|
|
|
|
public static TS operator +(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator -(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator *(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator /(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator %(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator &(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator |(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator ^(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator <<(TS a, int b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static TS operator >>(TS a, int b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// comparisons
|
|
|
|
|
public static bool operator ==(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator !=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator <(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator <=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator >(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public static bool operator >=(TS a, TS b) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj) |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
public override int GetHashCode() |
|
|
|
|
{ |
|
|
|
|
throw null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|