提交 8191c9c2 编写于 作者: M Mike Mazmanyan 提交者: dopare

Fixes #18311 - Incorrect quick info for ValueTuple<T>

上级 35ad8fa5
......@@ -381,6 +381,11 @@ private bool CanUseTupleTypeName(INamedTypeSymbol tupleSymbol)
{
INamedTypeSymbol currentUnderlying = tupleSymbol.TupleUnderlyingType;
if (currentUnderlying.Arity == 1)
{
return false;
}
while (currentUnderlying.Arity == TupleTypeSymbol.RestPosition)
{
tupleSymbol = (INamedTypeSymbol)currentUnderlying.TypeArguments[TupleTypeSymbol.RestPosition - 1];
......
......@@ -825,13 +825,13 @@ .maxstack 8
var partialParamType = partialNamesMethod.Parameters.Single().Type;
Assert.False(partialParamType.IsErrorType());
Assert.True(partialParamType.IsTupleType);
Assert.Equal("((System.Int32 e1, System.Int32))", partialParamType.ToTestDisplayString());
Assert.Equal("ValueTuple<(System.Int32 e1, System.Int32)>", partialParamType.ToTestDisplayString());
var allNullNamesMethod = c.GetMember<MethodSymbol>("AllNullNamesMethod");
var allNullParamType = allNullNamesMethod.Parameters.Single().Type;
Assert.False(allNullParamType.IsErrorType());
Assert.True(allNullParamType.IsTupleType);
Assert.Equal("((System.Int32, System.Int32))", allNullParamType.ToTestDisplayString());
Assert.Equal("ValueTuple<(System.Int32, System.Int32)>", allNullParamType.ToTestDisplayString());
}
[Fact]
......@@ -8870,19 +8870,19 @@ void M((int, int, int, int, int, int, int, int) p)
comp.VerifyDiagnostics(
// (42,53): error CS0452: The type '(int)' must be a reference type in order to use it as parameter 'TRest' in the generic type or method 'ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>'
// void M((int, int, int, int, int, int, int, int) p)
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "(int)").WithLocation(42, 53),
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "ValueTuple<int>").WithLocation(42, 53),
// (42,53): error CS0452: The type 'int' must be a reference type in order to use it as parameter 'T1' in the generic type or method 'ValueTuple<T1>'
// void M((int, int, int, int, int, int, int, int) p)
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple<T1>", "T1", "int").WithLocation(42, 53),
// (44,18): error CS0452: The type '(int)' must be a reference type in order to use it as parameter 'TRest' in the generic type or method 'ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>'
// var t0 = (1, 2, 3, 4, 5, 6, 7, 8);
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(1, 2, 3, 4, 5, 6, 7, 8)").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "(int)").WithLocation(44, 18),
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(1, 2, 3, 4, 5, 6, 7, 8)").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "ValueTuple<int>").WithLocation(44, 18),
// (44,40): error CS0452: The type 'int' must be a reference type in order to use it as parameter 'T1' in the generic type or method 'ValueTuple<T1>'
// var t0 = (1, 2, 3, 4, 5, 6, 7, 8);
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "8").WithArguments("System.ValueTuple<T1>", "T1", "int").WithLocation(44, 40),
// (45,9): error CS0452: The type '(int)' must be a reference type in order to use it as parameter 'TRest' in the generic type or method 'ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>'
// (int, int, int, int, int, int, int, int) t1 = t0;
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(int, int, int, int, int, int, int, int)").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "(int)").WithLocation(45, 9),
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(int, int, int, int, int, int, int, int)").WithArguments("System.ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>", "TRest", "ValueTuple<int>").WithLocation(45, 9),
// (45,45): error CS0452: The type 'int' must be a reference type in order to use it as parameter 'T1' in the generic type or method 'ValueTuple<T1>'
// (int, int, int, int, int, int, int, int) t1 = t0;
Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "int").WithArguments("System.ValueTuple<T1>", "T1", "int").WithLocation(45, 45)
......@@ -10541,9 +10541,9 @@ static void Main()
"System.Int32 (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).a6",
"System.Int32 (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).Item7",
"System.Int32 (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).a7",
"(System.Int32) (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).Rest",
"ValueTuple<System.Int32> (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).Rest",
"(System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1)..ctor()",
"(System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1)..ctor(System.Int32 item1, System.Int32 item2, System.Int32 item3, System.Int32 item4, System.Int32 item5, System.Int32 item6, System.Int32 item7, (System.Int32) rest)",
"(System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1)..ctor(System.Int32 item1, System.Int32 item2, System.Int32 item3, System.Int32 item4, System.Int32 item5, System.Int32 item6, System.Int32 item7, ValueTuple<System.Int32> rest)",
"System.Boolean (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).Equals(System.Object obj)",
"System.Boolean (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).Equals((System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32) other)",
"System.Boolean (System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7, System.Int32 Item1).System.Collections.IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer comparer)",
......@@ -10606,22 +10606,22 @@ static void Main()
AssertTupleTypeEquality(m8TupleRestTuple);
AssertTestDisplayString(m8TupleRestTuple.GetMembers(),
"System.Int32 (System.Int32).Item1",
"(System.Int32)..ctor()",
"(System.Int32)..ctor(System.Int32 item1)",
"System.Boolean (System.Int32).Equals(System.Object obj)",
"System.Boolean (System.Int32).Equals((System.Int32) other)",
"System.Boolean (System.Int32).System.Collections.IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer comparer)",
"System.Int32 (System.Int32).System.IComparable.CompareTo(System.Object other)",
"System.Int32 (System.Int32).CompareTo((System.Int32) other)",
"System.Int32 (System.Int32).System.Collections.IStructuralComparable.CompareTo(System.Object other, System.Collections.IComparer comparer)",
"System.Int32 (System.Int32).GetHashCode()",
"System.Int32 (System.Int32).System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)",
"System.Int32 (System.Int32).System.ITupleInternal.GetHashCode(System.Collections.IEqualityComparer comparer)",
"System.String (System.Int32).ToString()",
"System.String (System.Int32).System.ITupleInternal.ToStringEnd()",
"System.Int32 (System.Int32).System.ITupleInternal.Size.get",
"System.Int32 (System.Int32).System.ITupleInternal.Size { get; }");
"System.Int32 ValueTuple<System.Int32>.Item1",
"ValueTuple<System.Int32>..ctor()",
"ValueTuple<System.Int32>..ctor(System.Int32 item1)",
"System.Boolean ValueTuple<System.Int32>.Equals(System.Object obj)",
"System.Boolean ValueTuple<System.Int32>.Equals(ValueTuple<System.Int32> other)",
"System.Boolean ValueTuple<System.Int32>.System.Collections.IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer comparer)",
"System.Int32 ValueTuple<System.Int32>.System.IComparable.CompareTo(System.Object other)",
"System.Int32 ValueTuple<System.Int32>.CompareTo(ValueTuple<System.Int32> other)",
"System.Int32 ValueTuple<System.Int32>.System.Collections.IStructuralComparable.CompareTo(System.Object other, System.Collections.IComparer comparer)",
"System.Int32 ValueTuple<System.Int32>.GetHashCode()",
"System.Int32 ValueTuple<System.Int32>.System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)",
"System.Int32 ValueTuple<System.Int32>.System.ITupleInternal.GetHashCode(System.Collections.IEqualityComparer comparer)",
"System.String ValueTuple<System.Int32>.ToString()",
"System.String ValueTuple<System.Int32>.System.ITupleInternal.ToStringEnd()",
"System.Int32 ValueTuple<System.Int32>.System.ITupleInternal.Size.get",
"System.Int32 ValueTuple<System.Int32>.System.ITupleInternal.Size { get; }");
}
[Fact]
......
......@@ -4549,6 +4549,39 @@ public class C
SymbolDisplayPartKind.FieldName);
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, CompilerTrait(CompilerFeature.Tuples)]
public void TupleWith1Arity()
{
var text = @"
using System;
public class C
{
public ValueTuple<int> f;
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs;
Func<NamespaceSymbol, Symbol> findSymbol = global =>
global.
GetTypeMembers("C").Single().
GetMembers("f").Single();
var format = new SymbolDisplayFormat(memberOptions: SymbolDisplayMemberOptions.IncludeType,
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters);
TestSymbolDescription(
text,
findSymbol,
format,
TestOptions.Regular,
"ValueTuple<Int32> f",
SymbolDisplayPartKind.StructName,
SymbolDisplayPartKind.Punctuation,
SymbolDisplayPartKind.StructName,
SymbolDisplayPartKind.Punctuation,
SymbolDisplayPartKind.Space,
SymbolDisplayPartKind.FieldName);
}
[Fact, CompilerTrait(CompilerFeature.Tuples)]
public void TupleWithNames()
{
......
......@@ -330,6 +330,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private Shared Function CanUseTupleTypeName(tupleSymbol As INamedTypeSymbol) As Boolean
Dim currentUnderlying As INamedTypeSymbol = tupleSymbol.TupleUnderlyingType
If currentUnderlying.Arity = 1 Then
Return False
End If
While currentUnderlying.Arity = TupleTypeSymbol.RestPosition
tupleSymbol = DirectCast(currentUnderlying.TypeArguments(TupleTypeSymbol.RestPosition - 1), INamedTypeSymbol)
Debug.Assert(tupleSymbol.IsTupleType)
......
......@@ -8844,13 +8844,13 @@ additionalReferences:=s_valueTupleRefs)
Dim partialParamType = partialNamesMethod.Parameters.Single().Type
Assert.False(partialParamType.IsErrorType())
Assert.True(partialParamType.IsTupleType)
Assert.Equal("((e1 As System.Int32, System.Int32))", partialParamType.ToTestDisplayString())
Assert.Equal("ValueTuple(Of (e1 As System.Int32, System.Int32))", partialParamType.ToTestDisplayString())
Dim allNullNamesMethod = c.GetMember(Of MethodSymbol)("AllNullNamesMethod")
Dim allNullParamType = allNullNamesMethod.Parameters.Single().Type
Assert.False(allNullParamType.IsErrorType())
Assert.True(allNullParamType.IsTupleType)
Assert.Equal("((System.Int32, System.Int32))", allNullParamType.ToTestDisplayString())
Assert.Equal("ValueTuple(Of (System.Int32, System.Int32))", allNullParamType.ToTestDisplayString())
End Sub
<Fact>
......@@ -13323,19 +13323,19 @@ End Class
comp.AssertTheseDiagnostics(
<errors>
BC32106: Type argument '(Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
BC32106: Type argument 'Integer' does not satisfy the 'Class' constraint for type parameter 'T1'.
Sub M(p As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer))
~
BC32106: Type argument 'Integer' does not satisfy the 'Class' constraint for type parameter 'T1'.
BC32106: Type argument 'ValueTuple(Of Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
Sub M(p As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer))
~
BC32106: Type argument '(Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
BC32106: Type argument 'ValueTuple(Of Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
Dim t0 = (1, 2, 3, 4, 5, 6, 7, 8)
~~~~~~~~~~~~~~~~~~~~~~~~
BC32106: Type argument 'Integer' does not satisfy the 'Class' constraint for type parameter 'T1'.
Dim t0 = (1, 2, 3, 4, 5, 6, 7, 8)
~
BC32106: Type argument '(Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
BC32106: Type argument 'ValueTuple(Of Integer)' does not satisfy the 'Class' constraint for type parameter 'TRest'.
Dim t1 As (Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) = t0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC32106: Type argument 'Integer' does not satisfy the 'Class' constraint for type parameter 'T1'.
......@@ -14872,14 +14872,14 @@ BC37261: Tuple element name 'Item1' is only allowed at position 1.
"(a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).a6 As System.Int32",
"(a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Item7 As System.Int32",
"(a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).a7 As System.Int32",
"(a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Rest As (System.Int32)",
"(a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Rest As ValueTuple(Of System.Int32)",
"Sub (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32)..ctor()",
"Sub (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32)..ctor(item1 As System.Int32, item2 As System.Int32, item3 As System.Int32, item4 As System.Int32, item5 As System.Int32, item6 As System.Int32, item7 As System.Int32, rest As (System.Int32))",
"Sub (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32)..ctor(item1 As System.Int32, item2 As System.Int32, item3 As System.Int32, item4 As System.Int32, item5 As System.Int32, item6 As System.Int32, item7 As System.Int32, rest As ValueTuple(Of System.Int32))",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Equals(obj As System.Object) As System.Boolean",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Equals(other As System.ValueTuple(Of System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, (System.Int32))) As System.Boolean",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).Equals(other As System.ValueTuple(Of System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, ValueTuple(Of System.Int32))) As System.Boolean",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).System.Collections.IStructuralEquatable.Equals(other As System.Object, comparer As System.Collections.IEqualityComparer) As System.Boolean",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).System.IComparable.CompareTo(other As System.Object) As System.Int32",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).CompareTo(other As System.ValueTuple(Of System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, (System.Int32))) As System.Int32",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).CompareTo(other As System.ValueTuple(Of System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, System.Int32, ValueTuple(Of System.Int32))) As System.Int32",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).System.Collections.IStructuralComparable.CompareTo(other As System.Object, comparer As System.Collections.IComparer) As System.Int32",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).GetHashCode() As System.Int32",
"Function (a1 As System.Int32, a2 As System.Int32, a3 As System.Int32, a4 As System.Int32, a5 As System.Int32, a6 As System.Int32, a7 As System.Int32, Item1 As System.Int32).System.Collections.IStructuralEquatable.GetHashCode(comparer As System.Collections.IEqualityComparer) As System.Int32",
......@@ -14934,22 +14934,22 @@ BC37261: Tuple element name 'Item1' is only allowed at position 1.
AssertTupleTypeEquality(m8TupleRestTuple)
AssertTestDisplayString(m8TupleRestTuple.GetMembers(),
"(System.Int32).Item1 As System.Int32",
"Sub (System.Int32)..ctor()",
"Sub (System.Int32)..ctor(item1 As System.Int32)",
"Function (System.Int32).Equals(obj As System.Object) As System.Boolean",
"Function (System.Int32).Equals(other As (System.Int32)) As System.Boolean",
"Function (System.Int32).System.Collections.IStructuralEquatable.Equals(other As System.Object, comparer As System.Collections.IEqualityComparer) As System.Boolean",
"Function (System.Int32).System.IComparable.CompareTo(other As System.Object) As System.Int32",
"Function (System.Int32).CompareTo(other As (System.Int32)) As System.Int32",
"Function (System.Int32).System.Collections.IStructuralComparable.CompareTo(other As System.Object, comparer As System.Collections.IComparer) As System.Int32",
"Function (System.Int32).GetHashCode() As System.Int32",
"Function (System.Int32).System.Collections.IStructuralEquatable.GetHashCode(comparer As System.Collections.IEqualityComparer) As System.Int32",
"Function (System.Int32).System.ITupleInternal.GetHashCode(comparer As System.Collections.IEqualityComparer) As System.Int32",
"Function (System.Int32).ToString() As System.String",
"Function (System.Int32).System.ITupleInternal.ToStringEnd() As System.String",
"Function (System.Int32).System.ITupleInternal.get_Size() As System.Int32",
"ReadOnly Property (System.Int32).System.ITupleInternal.Size As System.Int32"
"ValueTuple(Of System.Int32).Item1 As System.Int32",
"Sub ValueTuple(Of System.Int32)..ctor()",
"Sub ValueTuple(Of System.Int32)..ctor(item1 As System.Int32)",
"Function ValueTuple(Of System.Int32).Equals(obj As System.Object) As System.Boolean",
"Function ValueTuple(Of System.Int32).Equals(other As ValueTuple(Of System.Int32)) As System.Boolean",
"Function ValueTuple(Of System.Int32).System.Collections.IStructuralEquatable.Equals(other As System.Object, comparer As System.Collections.IEqualityComparer) As System.Boolean",
"Function ValueTuple(Of System.Int32).System.IComparable.CompareTo(other As System.Object) As System.Int32",
"Function ValueTuple(Of System.Int32).CompareTo(other As ValueTuple(Of System.Int32)) As System.Int32",
"Function ValueTuple(Of System.Int32).System.Collections.IStructuralComparable.CompareTo(other As System.Object, comparer As System.Collections.IComparer) As System.Int32",
"Function ValueTuple(Of System.Int32).GetHashCode() As System.Int32",
"Function ValueTuple(Of System.Int32).System.Collections.IStructuralEquatable.GetHashCode(comparer As System.Collections.IEqualityComparer) As System.Int32",
"Function ValueTuple(Of System.Int32).System.ITupleInternal.GetHashCode(comparer As System.Collections.IEqualityComparer) As System.Int32",
"Function ValueTuple(Of System.Int32).ToString() As System.String",
"Function ValueTuple(Of System.Int32).System.ITupleInternal.ToStringEnd() As System.String",
"Function ValueTuple(Of System.Int32).System.ITupleInternal.get_Size() As System.Int32",
"ReadOnly Property ValueTuple(Of System.Int32).System.ITupleInternal.Size As System.Int32"
)
End Sub
......
......@@ -4678,6 +4678,36 @@ End Class
SymbolDisplayPartKind.Punctuation)
End Sub
<WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")>
<Fact()>
Public Sub TupleWith1Arity()
TestSymbolDescription(
<compilation>
<file name="a.vb">
Imports System
Class C
Private f As ValueTuple(Of Integer)
End Class
</file>
</compilation>,
FindSymbol("C.f"),
New SymbolDisplayFormat(memberOptions:=SymbolDisplayMemberOptions.IncludeType,
genericsOptions:=SymbolDisplayGenericsOptions.IncludeTypeParameters),
"f As ValueTuple(Of Int32)",
0,
{SymbolDisplayPartKind.FieldName,
SymbolDisplayPartKind.Space,
SymbolDisplayPartKind.Keyword,
SymbolDisplayPartKind.Space,
SymbolDisplayPartKind.ClassName,
SymbolDisplayPartKind.Punctuation,
SymbolDisplayPartKind.Keyword,
SymbolDisplayPartKind.Space,
SymbolDisplayPartKind.StructName,
SymbolDisplayPartKind.Punctuation},
references:={MetadataReference.CreateFromImage(TestResources.NetFX.ValueTuple.tuplelib)})
End Sub
<Fact()>
Public Sub TupleWithNames()
TestSymbolDescription(
......
......@@ -4837,6 +4837,114 @@ class C : I
MainDescription("(int, int) C.Name { get; set; }"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity0VariableName()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var y$$ = ValueTuple.Create();
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("(local variable) ValueTuple y"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity0ImplicitVar()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var$$ y = ValueTuple.Create();
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("struct System.ValueTuple"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity1VariableName()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var y$$ = ValueTuple.Create(1);
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("(local variable) ValueTuple<int> y"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity1ImplicitVar()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var$$ y = ValueTuple.Create(1);
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("ValueTuple<System.Int32>"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity2VariableName()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var y$$ = ValueTuple.Create(1, 1);
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("(local variable) (int, int) y"));
}
[WorkItem(18311, "https://github.com/dotnet/roslyn/issues/18311")]
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task ValueTupleWithArity2ImplicitVar()
{
await TestAsync(
@"
using System;
public class C
{
void M()
{
var$$ y = ValueTuple.Create(1, 1);
}
}
" + TestResources.NetFX.ValueTuple.tuplelib_cs,
MainDescription("(System.Int32, System.Int32)"));
}
[Fact, Trait(Traits.Feature, Traits.Features.QuickInfo)]
public async Task TestRefMethod()
{
......
......@@ -307,9 +307,9 @@ static void M()
.maxstack 2
.locals init ((int, int, int, int, int, int, int, int) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""int System.ValueTuple<int, int, int, int, int, int, int, (int)>.Item4""
IL_0001: ldfld ""int System.ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>.Item4""
IL_0006: ldloc.0
IL_0007: ldfld ""(int) System.ValueTuple<int, int, int, int, int, int, int, (int)>.Rest""
IL_0007: ldfld ""ValueTuple<int> System.ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>.Rest""
IL_000c: ldfld ""int System.ValueTuple<int>.Item1""
IL_0011: add
IL_0012: ret
......@@ -341,10 +341,10 @@ static void M()
.maxstack 2
.locals init ((int, int, int Three, int Four, int, int, int, int Eight) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""(int) System.ValueTuple<int, int, int, int, int, int, int, (int)>.Rest""
IL_0001: ldfld ""ValueTuple<int> System.ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>.Rest""
IL_0006: ldfld ""int System.ValueTuple<int>.Item1""
IL_000b: ldloc.0
IL_000c: ldfld ""(int) System.ValueTuple<int, int, int, int, int, int, int, (int)>.Rest""
IL_000c: ldfld ""ValueTuple<int> System.ValueTuple<int, int, int, int, int, int, int, ValueTuple<int>>.Rest""
IL_0011: ldfld ""int System.ValueTuple<int>.Item1""
IL_0016: add
IL_0017: ret
......
......@@ -318,9 +318,9 @@ End Class"
.maxstack 2
.locals init ((Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer)).Item4 As Integer""
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Item4 As Integer""
IL_0006: ldloc.0
IL_0007: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer)).Rest As (Integer)""
IL_0007: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_000c: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_0011: add.ovf
IL_0012: ret
......@@ -355,10 +355,10 @@ End Class"
.maxstack 2
.locals init ((Integer, Integer, Three As Integer, Four As Integer, Integer, Integer, Integer, Eight As Integer) V_0) //x
IL_0000: ldloc.0
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer)).Rest As (Integer)""
IL_0001: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_0006: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_000b: ldloc.0
IL_000c: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, (Integer)).Rest As (Integer)""
IL_000c: ldfld ""System.ValueTuple(Of Integer, Integer, Integer, Integer, Integer, Integer, Integer, ValueTuple(Of Integer)).Rest As ValueTuple(Of Integer)""
IL_0011: ldfld ""System.ValueTuple(Of Integer).Item1 As Integer""
IL_0016: add.ovf
IL_0017: ret
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册