未验证 提交 21803cb4 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #45614 from hartmair/master

Fix VB case correction for named tuple identifiers
......@@ -124,6 +124,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CaseCorrection
Return CaseCorrectIdentifierIfNamesDiffer(token, newToken, otherPartParam, namesMustBeEqualIgnoringCase:=True)
End If
End If
Else
' Named tuple expression
Dim nameColonEquals = TryCast(token.Parent?.Parent, NameColonEqualsSyntax)
If nameColonEquals IsNot Nothing AndAlso TypeOf nameColonEquals.Parent?.Parent Is TupleExpressionSyntax Then
Return newToken
End If
End If
End If
End If
......
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.CaseCorrection
Public Class CaseCorrectionTests
Inherits VisualBasicCaseCorrectionTestBase
<Fact, Trait(Traits.Feature, Traits.Features.CaseCorrection)>
<WorkItem(45508, "https://github.com/dotnet/roslyn/issues/45508")>
Public Async Function NamedTupleIdentifier() As Task
Dim code = <Code>Class C
Sub NamedTupleCasing(value1 As Integer)
Dim a = (Value1:=Value1, Value2:=2)
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub NamedTupleCasing(value1 As Integer)
Dim a = (Value1:=value1, Value2:=2)
End Sub
End Class</Code>
Await AssertCaseCorrectAsync(code.Value, expected.Value)
End Function
End Class
End Namespace
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.CaseCorrection
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.CaseCorrection
<UseExportProvider>
Public Class VisualBasicCaseCorrectionTestBase
Protected Shared Async Function AssertCaseCorrectAsync(code As String, expected As String) As Task
Using workspace = New AdhocWorkspace()
Dim project = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.VisualBasic)
Dim document = project.AddDocument("Document", SourceText.From(code))
Dim newNode = Await CaseCorrector.CaseCorrectAsync(document, New TextSpan(0, code.Length))
Dim actual = Await newNode.GetTextAsync()
AssertEx.EqualOrDiff(expected, actual.ToString())
End Using
End Function
End Class
End Namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册