提交 af299823 编写于 作者: J Julien 提交者: GitHub

Porting more tuple tests to VB (#13994)

上级 338174ad
......@@ -7191,7 +7191,7 @@ public override string ToString()
Assert.Equal(Conversion.NoConversion, model.GetConversion(node));
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/11289")]
[Fact]
[WorkItem(11289, "https://github.com/dotnet/roslyn/issues/11289")]
public void TupleConvertedTypeUDC04()
{
......@@ -7265,7 +7265,7 @@ public override string ToString()
CompileAndVerify(comp, expectedOutput: "{1, qq}");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/11289")]
[Fact]
[WorkItem(11289, "https://github.com/dotnet/roslyn/issues/11289")]
public void TupleConvertedTypeUDC05()
{
......@@ -7348,7 +7348,7 @@ public override string ToString()
{1, qq}");
}
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/11289")]
[Fact]
[WorkItem(11289, "https://github.com/dotnet/roslyn/issues/11289")]
public void TupleConvertedTypeUDC06()
{
......
......@@ -1595,6 +1595,9 @@ DoneWithDiagnostics:
If targetType.IsTupleType Then
Dim destTupleType = DirectCast(targetType, TupleTypeSymbol)
TupleTypeSymbol.ReportNamesMismatchesIfAny(targetType, sourceTuple, diagnostics)
' do not lose the original element names in the literal if different from names in the target
' Come back to this, what about locations? (https:'github.com/dotnet/roslyn/issues/11013)
targetType = destTupleType.WithElementNames(sourceTuple.ArgumentNamesOpt)
......
......@@ -1766,8 +1766,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
WRN_ConstraintsFailedForInferredArgs2 = 41006
WRN_ConditionalNotValidOnFunction = 41007
WRN_UseSwitchInsteadOfAttribute = 41008
WRN_TupleLiteralNameMismatch = 41009
'// AVAILABLE 41009 - 41199
'// AVAILABLE 41010 - 41199
WRN_ReferencedAssemblyDoesNotHaveStrongName = 41997
WRN_RecursiveAddHandlerCall = 41998
WRN_ImplicitConversionCopyBack = 41999
......
......@@ -1005,5 +1005,26 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
' of https://github.com/dotnet/roslyn/issues/14104
Return SpecializedCollections.EmptyEnumerable(Of PropertySymbol)()
End Function
Friend Shared Sub ReportNamesMismatchesIfAny(destination As TypeSymbol, literal As BoundTupleLiteral, diagnostics As DiagnosticBag)
Dim sourceNames = literal.ArgumentNamesOpt
If sourceNames.IsDefault Then
Return
End If
Dim destinationNames As ImmutableArray(Of String) = destination.TupleElementNames
Dim sourceLength As Integer = sourceNames.Length
Dim allMissing As Boolean = destinationNames.IsDefault
Debug.Assert(allMissing OrElse destinationNames.Length = sourceLength)
For i = 0 To sourceLength - 1
Dim sourceName = sourceNames(i)
If sourceName IsNot Nothing AndAlso (allMissing OrElse String.CompareOrdinal(destinationNames(i), sourceName) <> 0) Then
diagnostics.Add(ERRID.WRN_TupleLiteralNameMismatch, literal.Arguments(i).Syntax.Parent.Location, sourceName, destination)
End If
Next
End Sub
End Class
End Namespace
......@@ -14574,6 +14574,24 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The tuple element name &apos;{0}&apos; is ignored because a different name is specified by the target type &apos;{1}&apos;..
'''</summary>
Friend ReadOnly Property WRN_TupleLiteralNameMismatch() As String
Get
Return ResourceManager.GetString("WRN_TupleLiteralNameMismatch", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to The tuple element name is ignored because a different name is specified by the assignment target..
'''</summary>
Friend ReadOnly Property WRN_TupleLiteralNameMismatch_Title() As String
Get
Return ResourceManager.GetString("WRN_TupleLiteralNameMismatch_Title", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to {0} &apos;{1}&apos; and partial {2} &apos;{3}&apos; conflict in {4} &apos;{5}&apos;, but are being merged because one of them is declared partial..
'''</summary>
......
......@@ -5382,6 +5382,12 @@
<data name="ERR_TupleDuplicateElementName" xml:space="preserve">
<value>Tuple element names must be unique.</value>
</data>
<data name="WRN_TupleLiteralNameMismatch" xml:space="preserve">
<value>The tuple element name '{0}' is ignored because a different name is specified by the target type '{1}'.</value>
</data>
<data name="WRN_TupleLiteralNameMismatch_Title" xml:space="preserve">
<value>The tuple element name is ignored because a different name is specified by the assignment target.</value>
</data>
<data name="ERR_TupleReservedElementName" xml:space="preserve">
<value>Tuple element name '{0}' is only allowed at position {1}.</value>
</data>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册