Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -12,7 +12,11 @@ interface I<T>
{
}
class C
class B<T>
{
}
class C : B<dynamic>
{
public C (dynamic d)
{
@@ -108,6 +112,9 @@ class Test
if (t.GetConstructors ()[0].GetCustomAttributes (ca, false).Length != 0)
return 21;
if (t.GetCustomAttributes (ca, false).Length != 1)
return 22;
// Transformations
DynamicAttribute da;
da = t.GetMember ("t")[0].GetCustomAttributes (ca, false)[0] as DynamicAttribute;

View File

@@ -6,3 +6,6 @@
gtest-230.cs
test-pattern-02.cs
test-pattern-04.cs
test-pattern-05.cs
test-pattern-07.cs

View File

@@ -0,0 +1,21 @@
class X
{
void Test (string arg)
{
while (Call (out string s))
{
arg = s.ToString ();
}
}
static bool Call (out string s)
{
s = "";
return true;
}
public static void Main ()
{
Call (out string s);
}
}

View File

@@ -0,0 +1,16 @@
// Introduced in C#7
class VV
{
VV () => Test ();
~VV () => Test ();
void Test ()
{
}
public static void Main ()
{
}
}

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
class Expr
{
public int Field;
public Expr Next;
}
static class X
{
public static IEnumerable<int> Test (this Expr expr)
{
var exprCur = expr;
while (exprCur != null)
{
if (exprCur is Expr list)
{
yield return list.Field;
exprCur = list.Next;
}
else
{
yield return 2;
yield break;
}
}
}
public static void Main ()
{
}
}

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
class Expr
{
public int Field;
}
static class X
{
public static IEnumerable<int> Test (Expr expr)
{
object exprCur = expr;
if (exprCur is Expr list) {
yield return list.Field;
}
}
public static IEnumerable<string> Test2 (int? expr)
{
int? exprCur = expr;
while (exprCur != null) {
if (exprCur is int list) {
yield return list.ToString ();
}
}
}
public static void Main ()
{
Test (null);
Test2 (3);
}
}

View File

@@ -0,0 +1,53 @@
using System;
static class X
{
static (int, string) Test1 ()
{
return ValueTuple.Create (1, "2");
}
static void Test2 ((int Item1, int Item2) arg)
{
}
static void Test3 ((int a, string b) arg)
{
}
static (int a, string b) Test4 ()
{
return ValueTuple.Create (1, "x");
}
static int Main ()
{
var res = Test1 ();
if (res.Item1 != 1) {
return 1;
}
if (res.Item2 != "2") {
return 2;
}
ValueTuple<int, string> res2 = res;
Test3 (ValueTuple.Create (1, "2"));
var res3 = Test4 ();
if (res3.Item1 != 1)
return 3;
if (res3.a != 1)
return 4;
if (res3.Item2 != "x")
return 5;
if (res3.b != "x")
return 6;
return 0;
}
}

View File

@@ -0,0 +1,38 @@
using System;
class TupleConversions
{
public static void Main ()
{
object oarg = 4;
(sbyte v1, long v2) t1 = (-1, 2);
var t2 = (-1, 2);
IComparable o = (x1: "a", x2: 1.ToString ());
var arg = (x1: 1, x2: 1.ToString ());
if (arg.x2 != "1")
return;
Foo ((x1: (oarg, 'v'), x2: 1.ToString ()));
Test3 (ValueTuple.Create (1, "2"));
(int v1, string v2) y = (1, null);
(int v1, Action v2) y2 = (1, Main);
(int v1, Action v2) y3 = (ValueTuple<int, Action>) (1, Main);
(string v1, object v2) b = ("a", "b");
(int v1, long v2)? x = null;
}
static void Foo<T> (T arg)
{
}
static void Test3 ((long a, object b) arg)
{
}
}

View File

@@ -0,0 +1,71 @@
using System;
using System.Linq.Expressions;
class TupleDeconstruct
{
static int s_xx;
static long s_yy;
public static int Main ()
{
var (xx, yy) = (1, 2);
if (xx != 1)
return 1;
if (yy != 2)
return 2;
int x, y;
(x, y) = (1, 2);
if (x != 1)
return 3;
if (y != 2)
return 4;
(s_xx, s_yy) = Test3 ();
if (s_xx != 1)
return 5;
if (s_yy != 3)
return 6;
// var cwd = new ClassWithDeconstruct ();
// var (m1, m2) = cwd;
// (string, string) ss = cwd; // Error
return 0;
}
static void Test2 ()
{
var c = new C ();
(c.Prop1, c.Prop2) = (1, 2);
}
static (int, long) Test3 ()
{
return (1, 3);
}
static void TestCustom ()
{
return;
}
}
class ClassWithDeconstruct
{
public void Deconstruct (out string f, out string s)
{
f = "a";
s = "z";
}
}
class C
{
public int Prop1 { get; set; }
public int Prop2 { get; set; }
}

View File

@@ -0,0 +1,14 @@
// Compiler options: -t:library
using System;
using System.Collections.Generic;
public class X
{
public static (int a, string, bool b, object) Test1 ()
{
return ValueTuple.Create (1, "2", true, new X ());
}
public static (int x, (int x2, string y2), bool z) Field;
}

View File

@@ -0,0 +1,17 @@
// Compiler options: -r:test-tuple-04-lib.dll
class Test
{
public static int Main ()
{
var x = X.Test1 ();
if (x.b != true)
return 1;
var z = X.Field;
if (z.z != false)
return 2;
return 0;
}
}

181
mcs/tests/test-tuple-05.cs Normal file
View File

@@ -0,0 +1,181 @@
//
// tuple names attribute decoration
//
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.Linq;
interface I<T>
{
}
class B<T>
{
}
class C // : B<(int a, int b)> // TODO: I<(a, b)
{
public C((int a, int b) d)
{
}
public (int a, int b) a;
public (int, (int a, int b)) c;
public (int a, int b) Prop { set; get; }
public (int a, int b) Prop2 { set { } }
public (int a, int b)? this[(int a, int b) d] { set { } get { return null; } }
public (int a, int b)? Method(ref (int a, int b) d)
{
return null;
}
public (int a, int b)[] t;
public (int a, int b)[,] t2;
// TODO: public Func<(int a, int b), int, (int c, int d)[]> v;
// public I<(int a, int b)>[] iface;
// TODO: public Action<(long, (long u, long))[], object, (int a, int b)> d2;
public (((int aa1, int aa2) a1, (int, int) a2) x1, ((int cc1, int cc2) b1, (int dd1, int dd2) b2) x2) d3;
}
delegate (int a, int b) Del((int a, int b) d);
class Test
{
public static int Main()
{
Type t = typeof(C);
Type ca = typeof(TupleElementNamesAttribute);
TupleElementNamesAttribute da;
if (t.GetMember("a")[0].GetCustomAttributes(ca, false).Length != 1)
return 1;
if (t.GetMember("c")[0].GetCustomAttributes(ca, false).Length != 1)
return 3;
if (t.GetMember("Prop")[0].GetCustomAttributes(ca, false).Length != 1)
return 4;
if (t.GetMember("get_Prop")[0].GetCustomAttributes(ca, false).Length != 0)
return 5;
if (t.GetMethod("get_Prop").ReturnParameter.GetCustomAttributes(ca, false).Length != 1)
return 6;
if (t.GetMember("set_Prop")[0].GetCustomAttributes(ca, false).Length != 0)
return 7;
if (t.GetMethod("set_Prop").ReturnParameter.GetCustomAttributes(ca, false).Length != 0)
return 8;
if (t.GetMethod("set_Prop").GetParameters()[0].GetCustomAttributes(ca, false).Length != 1)
return 9;
if (t.GetMember("Prop2")[0].GetCustomAttributes(ca, false).Length != 1)
return 10;
if (t.GetMember("set_Prop2")[0].GetCustomAttributes(ca, false).Length != 0)
return 11;
if (t.GetMember("Item")[0].GetCustomAttributes(ca, false).Length != 1)
return 12;
if (t.GetMethod("get_Item").ReturnParameter.GetCustomAttributes(ca, false).Length != 1)
return 13;
if (t.GetMethod("get_Item").GetParameters()[0].GetCustomAttributes(ca, false).Length != 1)
return 14;
if (t.GetMethod("set_Item").ReturnParameter.GetCustomAttributes(ca, false).Length != 0)
return 15;
if (t.GetMethod("set_Item").GetParameters()[0].GetCustomAttributes(ca, false).Length != 1)
return 16;
if (t.GetMethod("set_Item").GetParameters()[1].GetCustomAttributes(ca, false).Length != 1)
return 17;
if (t.GetMember("Method")[0].GetCustomAttributes(ca, false).Length != 0)
return 18;
var res = t.GetMethod("Method").GetParameters()[0].GetCustomAttributes(ca, false);
if (res.Length != 1)
return 19;
da = res[0] as TupleElementNamesAttribute;
if (da == null)
return 190;
if (!da.TransformNames.SequenceEqual(new string[] { "a", "b" }))
return 191;
if (t.GetConstructors()[0].GetParameters()[0].GetCustomAttributes(ca, false).Length != 1)
return 20;
if (t.GetConstructors()[0].GetCustomAttributes(ca, false).Length != 0)
return 21;
// if (t.GetCustomAttributes(ca, false).Length != 1)
// return 22;
// Transformations
da = t.GetMember("t")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
if (da == null)
return 40;
if (!da.TransformNames.SequenceEqual(new string[] { "a", "b" }))
return 41;
da = t.GetMember("t2")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
if (da == null)
return 42;
if (!da.TransformNames.SequenceEqual(new string[] { "a", "b" }))
return 43;
//da = t.GetMember("v")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
//if (da == null)
// return 44;
//if (!da.TransformNames.SequenceEqual(new string[] { "a", "b", "c", "d" }))
// return 45;
//da = t.GetMember("iface")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
//if (da == null)
// return 46;
//if (!da.TransformNames.SequenceEqual(new string[] { "a", "b" }))
// return 47;
//da = t.GetMember("d2")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
//if (da == null)
// return 48;
//if (!da.TransformNames.SequenceEqual(new string[] { null, null, "u", null, "a", "b" }))
// return 49;
da = t.GetMember("d3")[0].GetCustomAttributes(ca, false)[0] as TupleElementNamesAttribute;
if (da == null)
return 50;
if (!da.TransformNames.SequenceEqual(new string[] { "x1", "x2", "a1", "a2", "aa1", "aa2", null, null, "b1", "b2", "cc1", "cc2", "dd1", "dd2" }))
return 51;
t = typeof(Del);
if (t.GetMember("Invoke")[0].GetCustomAttributes(ca, false).Length != 0)
return 100;
if (t.GetMethod("Invoke").GetParameters()[0].GetCustomAttributes(ca, false).Length != 1)
return 101;
if (t.GetMethod("Invoke").ReturnParameter.GetCustomAttributes(ca, false).Length != 1)
return 102;
Console.WriteLine("ok");
return 0;
}
}

View File

@@ -0,0 +1,19 @@
class Base
{
public virtual (int, long rest) Foo ()
{
return (1, 2);
}
}
class Test : Base
{
public override (int, long rest) Foo ()
{
return (3, 4);
}
public static void Main ()
{
}
}

View File

@@ -1 +1 @@
c0c676d6cdef0f51a5d571bc37d9e9004e1fa245
db5bfbd387c5090a47e7c7e01c8813a6cec6540e