Browse Source

Add more tests for C# 12 ref readonly parameters

pull/3243/head
Siegfried Pammer 12 months ago
parent
commit
5a66518581
  1. 68
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs

68
ICSharpCode.Decompiler.Tests/TestCases/Correctness/OverloadResolution.cs

@ -36,6 +36,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -36,6 +36,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
Issue1747();
CallAmbiguousOutParam();
CallWithInParam();
CallWithRefReadOnlyParam();
#if CS90
NativeIntTests(new IntPtr(1), 2);
#endif
@ -277,6 +278,73 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -277,6 +278,73 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
}
#endregion
#region Ref readonly Parameter
static void CallWithRefReadOnlyParam()
{
#if CS120
#pragma warning disable CS9193
Console.WriteLine("OverloadSetWithRefReadOnlyParam:");
OverloadSetWithRefReadOnlyParam(1);
OverloadSetWithRefReadOnlyParam(2L);
int i = 3;
OverloadSetWithRefReadOnlyParam(in i);
OverloadSetWithRefReadOnlyParam((long)4);
Console.WriteLine("OverloadSetWithRefReadOnlyParam2:");
OverloadSetWithRefReadOnlyParam2(1);
OverloadSetWithRefReadOnlyParam2((object)1);
Console.WriteLine("OverloadSetWithRefReadOnlyParam3:");
OverloadSetWithRefReadOnlyParam3(1);
OverloadSetWithRefReadOnlyParam3<int>(2);
OverloadSetWithRefReadOnlyParam3((object)3);
Console.WriteLine("RefReadOnlyVsRegularParam:");
RefReadOnlyVsRegularParam(1);
i = 2;
RefReadOnlyVsRegularParam(in i);
#endif
}
#if CS120
static void OverloadSetWithRefReadOnlyParam(ref readonly int i)
{
Console.WriteLine("ref readonly int " + i);
}
static void OverloadSetWithRefReadOnlyParam(long l)
{
Console.WriteLine("long " + l);
}
static void OverloadSetWithRefReadOnlyParam2(ref readonly long i)
{
Console.WriteLine("ref readonly long " + i);
}
static void OverloadSetWithRefReadOnlyParam2(object o)
{
Console.WriteLine("object " + o);
}
static void OverloadSetWithRefReadOnlyParam3(ref readonly int i)
{
Console.WriteLine("ref readonly int " + i);
}
static void OverloadSetWithRefReadOnlyParam3<T>(T a)
{
Console.WriteLine("T " + a);
}
static void RefReadOnlyVsRegularParam(ref readonly int i)
{
Console.WriteLine("ref readonly int " + i);
}
static void RefReadOnlyVsRegularParam(int i)
{
Console.WriteLine("int " + i);
}
#endif
#endregion
#region In Parameter
static void CallWithInParam()
{

Loading…
Cancel
Save