in src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb [1628:1960]
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled1() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Goo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled2() As Task
Dim code =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Goo()" + vbTab + vbTab + "'comment" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Goo() 'comment" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled3() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo() ' Comment" + vbCrLf +
" Goo() " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo() ' Comment" + vbCrLf +
vbTab + vbTab + "Goo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled4() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Dim abc = Sub()" + vbCrLf +
" Console.WriteLine(42)" + vbCrLf +
" End Sub" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Dim abc = Sub()" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + vbTab + " Console.WriteLine(42)" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + " End Sub" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled5() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Dim abc = 2 + " + vbCrLf +
" 3 + " + vbCrLf +
" 4 " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Dim abc = 2 +" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + vbTab + "3 +" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + " 4" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(10742, "https://github.com/dotnet/roslyn/issues/10742")>
Public Async Function ReFormatWithTabsEnabled6() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo() ' Comment" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo() ' Comment" + vbCrLf +
vbTab + vbTab + "Goo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsDisabled() As Task
Dim code =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Goo()" + vbCrLf +
vbTab + vbTab + "Goo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithDifferentIndent1() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithDifferentIndent2() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 6}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabledSmallIndentAndLargeTab() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
vbTab + " Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 3},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function RegressionCommentFollowsSubsequentIndent4173() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" 'comment" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" 'comment" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatUsingOverloads() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
"Goo() " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Goo()" + vbCrLf +
" Goo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Await AssertFormatUsingAllEntryPointsAsync(code, expected)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_1() As Task
Dim code = "Dim a = <xml> <%=<xml></xml>%> </xml>"
Dim expected = " Dim a = <xml><%= <xml></xml> %></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_2() As Task
Dim code = <Code>Class Goo
Sub Goo()
Goo()
End Sub