From 8191c9c290d0a8f24c468bf1bf391c275616fc9f Mon Sep 17 00:00:00 2001 From: Mike Mazmanyan Date: Fri, 7 Apr 2017 08:30:45 -0400 Subject: [PATCH] Fixes #18311 - Incorrect quick info for ValueTuple --- .../SymbolDisplayVisitor.Types.cs | 5 + .../Test/Emit/CodeGen/CodeGenTupleTest.cs | 46 ++++---- .../SymbolDisplay/SymbolDisplayTests.cs | 33 ++++++ .../SymbolDisplayVisitor.Types.vb | 4 + .../Test/Emit/CodeGen/CodeGenTuples.vb | 52 ++++----- .../SymbolDisplay/SymbolDisplayTests.vb | 30 +++++ .../QuickInfo/SemanticQuickInfoSourceTests.cs | 108 ++++++++++++++++++ .../Test/ExpressionCompiler/TupleTests.cs | 8 +- .../Test/ExpressionCompiler/TupleTests.vb | 8 +- 9 files changed, 237 insertions(+), 57 deletions(-) diff --git a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs index 5fbabc81399..098efc9ff05 100644 --- a/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs +++ b/src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs @@ -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]; diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index 2bd11938610..8a0d3bf18f2 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -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("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' // void M((int, int, int, int, int, int, int, int) p) - Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple", "TRest", "(int)").WithLocation(42, 53), + Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple", "TRest", "ValueTuple").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' // void M((int, int, int, int, int, int, int, int) p) Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "p").WithArguments("System.ValueTuple", "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' // 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", "TRest", "(int)").WithLocation(44, 18), + Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(1, 2, 3, 4, 5, 6, 7, 8)").WithArguments("System.ValueTuple", "TRest", "ValueTuple").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' // var t0 = (1, 2, 3, 4, 5, 6, 7, 8); Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "8").WithArguments("System.ValueTuple", "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' // (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", "TRest", "(int)").WithLocation(45, 9), + Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "(int, int, int, int, int, int, int, int)").WithArguments("System.ValueTuple", "TRest", "ValueTuple").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' // (int, int, int, int, int, int, int, int) t1 = t0; Diagnostic(ErrorCode.ERR_RefConstraintNotSatisfied, "int").WithArguments("System.ValueTuple", "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 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 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.Item1", + "ValueTuple..ctor()", + "ValueTuple..ctor(System.Int32 item1)", + "System.Boolean ValueTuple.Equals(System.Object obj)", + "System.Boolean ValueTuple.Equals(ValueTuple other)", + "System.Boolean ValueTuple.System.Collections.IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer comparer)", + "System.Int32 ValueTuple.System.IComparable.CompareTo(System.Object other)", + "System.Int32 ValueTuple.CompareTo(ValueTuple other)", + "System.Int32 ValueTuple.System.Collections.IStructuralComparable.CompareTo(System.Object other, System.Collections.IComparer comparer)", + "System.Int32 ValueTuple.GetHashCode()", + "System.Int32 ValueTuple.System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)", + "System.Int32 ValueTuple.System.ITupleInternal.GetHashCode(System.Collections.IEqualityComparer comparer)", + "System.String ValueTuple.ToString()", + "System.String ValueTuple.System.ITupleInternal.ToStringEnd()", + "System.Int32 ValueTuple.System.ITupleInternal.Size.get", + "System.Int32 ValueTuple.System.ITupleInternal.Size { get; }"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs b/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs index af1f8458e13..005838fc5fb 100644 --- a/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/SymbolDisplay/SymbolDisplayTests.cs @@ -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 f; +} +" + TestResources.NetFX.ValueTuple.tuplelib_cs; + Func 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 f", + SymbolDisplayPartKind.StructName, + SymbolDisplayPartKind.Punctuation, + SymbolDisplayPartKind.StructName, + SymbolDisplayPartKind.Punctuation, + SymbolDisplayPartKind.Space, + SymbolDisplayPartKind.FieldName); + } + [Fact, CompilerTrait(CompilerFeature.Tuples)] public void TupleWithNames() { diff --git a/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb b/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb index 515eb8c13cc..a3d4850e914 100644 --- a/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb +++ b/src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb @@ -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) diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index df77ec168f2..a2f5425e8ae 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -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 @@ -13323,19 +13323,19 @@ End Class comp.AssertTheseDiagnostics( -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 diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb index 48d886a9ecb..9ee588d513c 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb @@ -4678,6 +4678,36 @@ End Class SymbolDisplayPartKind.Punctuation) End Sub + + + Public Sub TupleWith1Arity() + TestSymbolDescription( + + +Imports System +Class C + Private f As ValueTuple(Of Integer) +End Class + + , + 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 + Public Sub TupleWithNames() TestSymbolDescription( diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs index a31462b519c..c6232dabd8d 100644 --- a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs @@ -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 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")); + } + + [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() { diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs index d3cbea65c3d..136152cb89a 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/TupleTests.cs @@ -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.Item4"" + IL_0001: ldfld ""int System.ValueTuple>.Item4"" IL_0006: ldloc.0 - IL_0007: ldfld ""(int) System.ValueTuple.Rest"" + IL_0007: ldfld ""ValueTuple System.ValueTuple>.Rest"" IL_000c: ldfld ""int System.ValueTuple.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.Rest"" + IL_0001: ldfld ""ValueTuple System.ValueTuple>.Rest"" IL_0006: ldfld ""int System.ValueTuple.Item1"" IL_000b: ldloc.0 - IL_000c: ldfld ""(int) System.ValueTuple.Rest"" + IL_000c: ldfld ""ValueTuple System.ValueTuple>.Rest"" IL_0011: ldfld ""int System.ValueTuple.Item1"" IL_0016: add IL_0017: ret diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb index 300405b68fd..199c53be582 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/TupleTests.vb @@ -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 -- GitLab