diff --git a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
index 2239f26aa..6d75516da 100644
--- a/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
+++ b/ICSharpCode.Decompiler.Tests/CorrectnessTestRunner.cs
@@ -196,12 +196,6 @@ namespace ICSharpCode.Decompiler.Tests
RunCS(options: options);
}
- [Test]
- public void RefLocalsAndReturns([ValueSource("roslynOnlyOptions")] CompilerOptions options)
- {
- RunCS(options: options);
- }
-
[Test]
public void BitNot([Values(false, true)] bool force32Bit)
{
diff --git a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
index f87cc0876..c6d570204 100644
--- a/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
+++ b/ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
@@ -88,7 +88,6 @@
-
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/RefLocalsAndReturns.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/RefLocalsAndReturns.cs
deleted file mode 100644
index 59f846290..000000000
--- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/RefLocalsAndReturns.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
-{
- class RefLocalsAndReturns
- {
- static int[] numbers = { 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023 };
- static string[] strings = { "Hello", "World" };
- static string NullString = "";
- static int DefaultInt = 0;
-
- public delegate ref TReturn RefFunc(T1 param1);
-
- public static TReturn Invoker(RefFunc action, T1 value)
- {
- return action(value);
- }
-
- public static ref int FindNumber(int target)
- {
- for (int ctr = 0; ctr < numbers.Length; ctr++) {
- if (numbers[ctr] >= target)
- return ref numbers[ctr];
- }
- return ref numbers[0];
- }
-
- public static ref int LastNumber()
- {
- return ref numbers[numbers.Length - 1];
- }
-
- public static ref int ElementAtOrDefault(int index)
- {
- return ref index < 0 || index >= numbers.Length ? ref DefaultInt : ref numbers[index];
- }
-
- public static ref int LastOrDefault()
- {
- return ref numbers.Length > 0 ? ref numbers[numbers.Length - 1] : ref DefaultInt;
- }
-
- public static void DoubleNumber(ref int num)
- {
- Console.WriteLine("old: " + num);
- num *= 2;
- Console.WriteLine("new: " + num);
- }
-
- public static ref string GetOrSetString(int index)
- {
- if (index < 0 || index >= strings.Length)
- return ref NullString;
- return ref strings[index];
- }
-
- public static void Main(string[] args)
- {
- DoubleNumber(ref FindNumber(32));
- Console.WriteLine(string.Join(", ", numbers));
- DoubleNumber(ref LastNumber());
- Console.WriteLine(string.Join(", ", numbers));
- Console.WriteLine(GetOrSetString(0));
- GetOrSetString(0) = "Goodbye";
- Console.WriteLine(string.Join(" ", strings));
- GetOrSetString(5) = "Here I mutated the null value!?";
- Console.WriteLine(GetOrSetString(-5));
-
- Console.WriteLine(Invoker(x => ref numbers[x], 0));
- Console.WriteLine(LastOrDefault());
- LastOrDefault() = 10000;
- Console.WriteLine(ElementAtOrDefault(-5));
- }
- }
-}
diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
index 67bc28561..484ffdebc 100644
--- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
+++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/RefLocalsAndReturns.cs
@@ -2,10 +2,33 @@
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
+ internal static class Ext
+ {
+ public static void ExtOnRef(this ref RefLocalsAndReturns.NormalStruct s)
+ {
+ }
+ public static void ExtOnIn(this in RefLocalsAndReturns.NormalStruct s)
+ {
+ }
+ public static void ExtOnRef(this ref RefLocalsAndReturns.ReadOnlyStruct s)
+ {
+ }
+ public static void ExtOnIn(this in RefLocalsAndReturns.ReadOnlyStruct s)
+ {
+ }
+ public static void ExtOnRef(this ref RefLocalsAndReturns.ReadOnlyRefStruct s)
+ {
+ }
+ public static void ExtOnIn(this in RefLocalsAndReturns.ReadOnlyRefStruct s)
+ {
+ }
+ }
+
internal class RefLocalsAndReturns
{
public delegate ref T RefFunc();
public delegate ref readonly T ReadOnlyRefFunc();
+ public delegate ref TReturn RefFunc(T1 param1);
public ref struct RefStruct
{
@@ -35,6 +58,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
+ private static int[] numbers = new int[10] {
+ 1,
+ 3,
+ 7,
+ 15,
+ 31,
+ 63,
+ 127,
+ 255,
+ 511,
+ 1023
+ };
+
+ private static string[] strings = new string[2] {
+ "Hello",
+ "World"
+ };
+
+ private static string NullString = "";
+
+ private static int DefaultInt = 0;
+
public static ref T GetRef()
{
throw new NotImplementedException();
@@ -80,5 +125,87 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
ReadOnlyStruct readOnlyStruct = rs;
readOnlyStruct.Method();
}
+
+ public static TReturn Invoker(RefFunc action, T1 value)
+ {
+ return action(value);
+ }
+
+ public static ref int FindNumber(int target)
+ {
+ for (int i = 0; i < numbers.Length; i++) {
+ if (numbers[i] >= target) {
+ return ref numbers[i];
+ }
+ }
+ return ref numbers[0];
+ }
+
+ public static ref int LastNumber()
+ {
+ return ref numbers[numbers.Length - 1];
+ }
+
+ public static ref int ElementAtOrDefault(int index)
+ {
+ if (index >= 0 && index < numbers.Length) {
+ return ref numbers[index];
+ }
+ return ref DefaultInt;
+ }
+
+ public static ref int LastOrDefault()
+ {
+ if (numbers.Length != 0) {
+ return ref numbers[numbers.Length - 1];
+ }
+ return ref DefaultInt;
+ }
+
+ public static void DoubleNumber(ref int num)
+ {
+ Console.WriteLine("old: " + num);
+ num *= 2;
+ Console.WriteLine("new: " + num);
+ }
+
+ public static ref string GetOrSetString(int index)
+ {
+ if (index < 0 || index >= strings.Length) {
+ return ref NullString;
+ }
+
+ return ref strings[index];
+ }
+
+ public void CallSiteTests(NormalStruct s, ReadOnlyStruct r, ReadOnlyRefStruct rr)
+ {
+ s.ExtOnIn();
+ s.ExtOnRef();
+ r.ExtOnIn();
+ r.ExtOnRef();
+ rr.ExtOnIn();
+ rr.ExtOnRef();
+ CallOnInParam(in s, in r);
+ }
+
+ public static void Main(string[] args)
+ {
+ DoubleNumber(ref args.Length == 1 ? ref numbers[0] : ref DefaultInt);
+ DoubleNumber(ref FindNumber(32));
+ Console.WriteLine(string.Join(", ", numbers));
+ DoubleNumber(ref LastNumber());
+ Console.WriteLine(string.Join(", ", numbers));
+ Console.WriteLine(GetOrSetString(0));
+ GetOrSetString(0) = "Goodbye";
+ Console.WriteLine(string.Join(" ", strings));
+ GetOrSetString(5) = "Here I mutated the null value!?";
+ Console.WriteLine(GetOrSetString(-5));
+
+ Console.WriteLine(Invoker((int x) => ref numbers[x], 0));
+ Console.WriteLine(LastOrDefault());
+ LastOrDefault() = 10000;
+ Console.WriteLine(ElementAtOrDefault(-5));
+ }
}
}