Skip to content

Commit

Permalink
Ensure elastic trivia for reusable syntax in field generator (#62346)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 authored Jul 2, 2022
1 parent c605f77 commit 8fd033c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ End Namespace
Await TestMovementNewFileAsync(initialMarkup, expectedText1, expectedText2, newFileName, selection, newTypeName)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveStaticMembers)>
<WorkItem(62283, "https://github.com/dotnet/roslyn/issues/62283")>
Public Async Function TestMoveField_MultipleDeclarators() As Task
Dim initialMarkup = "
Class Program

Public Shared G[||]oo As Integer, Bar As Integer

End Class
"
Dim newTypeName = "Class1Helpers"
Dim newFileName = "Class1Helpers.vb"
Dim selection = ImmutableArray.Create("Goo")
Dim expectedText1 = "
Class Program

Public Shared Bar As Integer

End Class
"
Dim expectedText2 = "Class Class1Helpers

Public Shared Goo As Integer
End Class
"

Await TestMovementNewFileAsync(initialMarkup, expectedText1, expectedText2, newFileName, selection, newTypeName)
End Function

<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsMoveStaticMembers)>
Public Async Function TestMoveProperty() As Task
Dim initialMarkup = "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
options As CodeGenerationContextInfo) As FieldDeclarationSyntax
Dim reusableSyntax = GetReuseableSyntaxNodeForSymbol(Of FieldDeclarationSyntax)(field, options)
If reusableSyntax IsNot Nothing Then
return reusableSyntax
Return EnsureLastElasticTrivia(reusableSyntax)
End If

Dim initializerNode = TryCast(CodeGenerationFieldInfo.GetInitializer(field), ExpressionSyntax)
Expand Down

0 comments on commit 8fd033c

Please sign in to comment.