diff --git a/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs b/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs index 0d0a5cf68d90ce11dff416e8df69bf27c87228cc..d5b7d4d905071bbe547d79cb1699a2eb3461f7a3 100644 --- a/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs +++ b/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Formatting; using Roslyn.Utilities; @@ -21,23 +21,23 @@ protected Workspace DefaultWorkspace protected override SyntaxNode ParseCompilation(string text, ParseOptions parseOptions) => SyntaxFactory.ParseCompilationUnit(text, options: (CSharpParseOptions)parseOptions); - protected Task AssertFormatAsync( + private protected Task AssertFormatAsync( string expected, string code, bool debugMode = false, - Dictionary changedOptionSet = null, + OptionsCollection changedOptionSet = null, bool testWithTransformation = true, ParseOptions parseOptions = null) { return AssertFormatAsync(expected, code, SpecializedCollections.SingletonEnumerable(new TextSpan(0, code.Length)), debugMode, changedOptionSet, testWithTransformation, parseOptions); } - protected Task AssertFormatAsync( + private protected Task AssertFormatAsync( string expected, string code, IEnumerable spans, bool debugMode = false, - Dictionary changedOptionSet = null, + OptionsCollection changedOptionSet = null, bool testWithTransformation = true, ParseOptions parseOptions = null) { diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs index 79233af49720a0532e2cdf05209e2509ac26056b..7dd4894842d7693c6161ac48b8fc10a1c89eed10 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs @@ -7,8 +7,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Formatting; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; @@ -123,9 +123,9 @@ void F() System.Console.WriteLine(); } }"; - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.IndentBlock, false } + { CSharpFormattingOptions2.IndentBlock, false } }; await AssertFormatAsync(code, expected, changedOptionSet: changingOptions); } @@ -150,9 +150,9 @@ void F() System.Console.WriteLine(); } }"; - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingPreserveSingleLine, false } + { CSharpFormattingOptions2.WrappingPreserveSingleLine, false } }; await AssertFormatAsync(code, expected, changedOptionSet: changingOptions); } @@ -170,7 +170,7 @@ public async Task EmptySpan() var result = Formatter.Format(await syntaxTree.GetRootAsync(), TextSpan.FromBounds(0, 0), workspace, cancellationToken: CancellationToken.None); } - private Task AssertFormatAsync(string content, string expected, Dictionary changedOptionSet = null) + private Task AssertFormatAsync(string content, string expected, OptionsCollection changedOptionSet = null) { var tuple = PreprocessMarkers(content); diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs index 09e6c58de62eed54a38561615c04620c762db49a..48b7350ee1c623cef3037b9284bed720ce8ec79b 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs @@ -2,17 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; +using System; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; -using static Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions; -using System; +using static Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions2; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Formatting { @@ -955,9 +954,9 @@ public void nothing_again(Action a) [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task RelativeIndentationToFirstTokenInBaseTokenWithObjectInitializers() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false } + { CSharpFormattingOptions2.NewLinesForBracesInObjectCollectionArrayInitializers, false } }; await AssertFormatAsync(@"class Program { @@ -996,9 +995,9 @@ class D [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task RemoveSpacingAroundBinaryOperatorsShouldMakeAtLeastOneSpaceForIsAndAsKeywords() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacingAroundBinaryOperator, BinaryOperatorSpacingOptions.Remove } + { CSharpFormattingOptions2.SpacingAroundBinaryOperator, BinaryOperatorSpacingOptions.Remove } }; await AssertFormatAsync(@"class Class2 { @@ -1027,7 +1026,7 @@ public void nothing() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentUserSettingNonDefaultTest_OpenBracesOfLambdaWithNoNewLine() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentBraces, true }, { IndentBlock, false }, @@ -1060,7 +1059,7 @@ public void nothing() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentUserSettingNonDefaultTest() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentBraces, true }, { IndentBlock, false }, @@ -1151,7 +1150,7 @@ public void nothing_again(Action a) [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentSwitch_IndentCase_IndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, true }, { IndentSwitchCaseSection, true }, @@ -1191,7 +1190,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentSwitch_IndentCase_NoIndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, true }, { IndentSwitchCaseSection, true }, @@ -1231,7 +1230,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentSwitch_NoIndentCase_IndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, true }, { IndentSwitchCaseSection, false }, @@ -1271,7 +1270,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IndentSwitch_NoIndentCase_NoIndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, true }, { IndentSwitchCaseSection, false }, @@ -1311,7 +1310,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NoIndentSwitch_IndentCase_IndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, false }, { IndentSwitchCaseSection, true }, @@ -1351,7 +1350,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NoIndentSwitch_IndentCase_NoIndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, false }, { IndentSwitchCaseSection, true }, @@ -1391,7 +1390,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NoIndentSwitch_NoIndentCase_IndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, false }, { IndentSwitchCaseSection, false }, @@ -1431,7 +1430,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NoIndentSwitch_NoIndentCase_NoIndentWhenBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { IndentSwitchSection, false }, { IndentSwitchCaseSection, false }, @@ -1510,9 +1509,9 @@ void bar() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task TestWrappingNonDefault_FormatBlock() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingPreserveSingleLine, false } + { CSharpFormattingOptions2.WrappingPreserveSingleLine, false } }; await AssertFormatAsync(@"class Class5 { @@ -1581,9 +1580,9 @@ class goo{int x = 0;}", false, changingOptions); [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task TestWrappingNonDefault_FormatStatmtMethDecl() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } + { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false } }; await AssertFormatAsync(@"class Class5 { @@ -1648,10 +1647,10 @@ class goo [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task TestWrappingNonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingPreserveSingleLine, false }, - { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } + { CSharpFormattingOptions2.WrappingPreserveSingleLine, false }, + { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false } }; await AssertFormatAsync(@"class Class5 { @@ -1731,9 +1730,9 @@ class goo{int x = 0;}", false, changingOptions); [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task TestLeaveStatementMethodDeclarationSameLineNotAffectingForStatement() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } + { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false } }; await AssertFormatAsync(@"class Program { @@ -1888,7 +1887,7 @@ public class goo : System.Object [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NewLineForOpenBracesNonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { NewLinesForBracesInTypes, false }, { NewLinesForBracesInMethods, false }, @@ -2078,11 +2077,11 @@ void f00() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NewLineForKeywordNonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLineForElse, false }, - { CSharpFormattingOptions.NewLineForCatch, false }, - { CSharpFormattingOptions.NewLineForFinally, false } + { CSharpFormattingOptions2.NewLineForElse, false }, + { CSharpFormattingOptions2.NewLineForCatch, false }, + { CSharpFormattingOptions2.NewLineForFinally, false } }; await AssertFormatAsync(@"class c { @@ -2144,7 +2143,7 @@ void f00() [WorkItem(33458, "https://github.com/dotnet/roslyn/issues/33458")] public async Task NoNewLineForElseChecksBraceOwner() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { { NewLineForElse, false }, { NewLinesForBracesInControlBlocks, false }, @@ -2244,11 +2243,11 @@ void br() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task NewLineForExpressionNonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLineForMembersInObjectInit, false }, - { CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, false }, - { CSharpFormattingOptions.NewLineForClausesInQuery, false } + { CSharpFormattingOptions2.NewLineForMembersInObjectInit, false }, + { CSharpFormattingOptions2.NewLineForMembersInAnonymousTypes, false }, + { CSharpFormattingOptions2.NewLineForClausesInQuery, false } }; await AssertFormatAsync(@"class f00 { @@ -5190,9 +5189,9 @@ void M() [WorkItem(27268, "https://github.com/dotnet/roslyn/issues/27268")] public async Task FormatRecursivePattern_PreferSpaceBetweenTypeAndPositionalSubpattern() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceAfterMethodCallName, true } + { CSharpFormattingOptions2.SpaceAfterMethodCallName, true } }; var code = @"class C { @@ -5214,9 +5213,9 @@ void M() [WorkItem(27268, "https://github.com/dotnet/roslyn/issues/27268")] public async Task FormatRecursivePattern_PreferSpaceInsidePositionalSubpatternParentheses() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceWithinMethodCallParentheses, true } + { CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true } }; var code = @"class C { @@ -5240,9 +5239,9 @@ void M() [WorkItem(27268, "https://github.com/dotnet/roslyn/issues/27268")] public async Task FormatRecursivePattern_PreferSpaceInsideEmptyPositionalSubpatternParentheses() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, true } + { CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, true } }; var code = @"class C { @@ -5266,8 +5265,8 @@ void M() [WorkItem(34683, "https://github.com/dotnet/roslyn/issues/34683")] public async Task FormatRecursivePattern_InBinaryOperation() { - var changingOptions = new Dictionary(); - changingOptions.Add(CSharpFormattingOptions.SpaceWithinMethodCallParentheses, true); + var changingOptions = new OptionsCollection(LanguageNames.CSharp); + changingOptions.Add(CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true); var code = @"class C { void M() @@ -6009,9 +6008,9 @@ void Method() [Trait(Traits.Feature, Traits.Features.Formatting)] public async Task Bugfix_553654_LabelStatementIndenting() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.LabelPositioning, LabelPositionOptions.LeftMost } + { CSharpFormattingOptions2.LabelPositioning, LabelPositionOptions.LeftMost } }; var code = @"class Program @@ -6172,7 +6171,7 @@ public async Task Bugfix_776513_CheckBraceIfNotMissingBeforeApplyingOperationFor [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task ShouldFormatDocCommentWithIndentSameAsTabSizeWithUseTabTrue() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"namespace ConsoleApplication1 { @@ -6281,7 +6280,7 @@ public void goo() { } } }"; - var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceWithinOtherParentheses, true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.SpaceWithinOtherParentheses, true } }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); } @@ -6370,7 +6369,7 @@ public void goo() { } } }"; - var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceAfterControlFlowStatementKeyword, false } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.SpaceAfterControlFlowStatementKeyword, false } }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); } @@ -6407,7 +6406,7 @@ public void Main() var digits = new List { 1,2,3,4 }; } }"; - var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceAfterComma, false } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.SpaceAfterComma, false } }; await AssertFormatAsync(expectedAfterCommaDisabled, code, changedOptionSet: optionSet); var expectedBeforeCommaEnabled = @" @@ -6419,7 +6418,7 @@ public void Main() var digits = new List { 1 ,2 ,3 ,4 }; } }"; - optionSet.Add(CSharpFormattingOptions.SpaceBeforeComma, true); + optionSet.Add(CSharpFormattingOptions2.SpaceBeforeComma, true); await AssertFormatAsync(expectedBeforeCommaEnabled, code, changedOptionSet: optionSet); } @@ -6469,9 +6468,9 @@ int M() [Trait(Traits.Feature, Traits.Features.Formatting)] public async Task QueryExpressionInExpression() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInMethods, false } + { CSharpFormattingOptions2.NewLinesForBracesInMethods, false } }; var code = @" @@ -6532,9 +6531,9 @@ public void CreateSettingsFile(string path, string comment) [Trait(Traits.Feature, Traits.Features.Formatting)] public async Task EmbeddedStatementElse() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLineForElse, false } + { CSharpFormattingOptions2.NewLineForElse, false } }; var code = @" @@ -6762,7 +6761,7 @@ private void MenuItemCallback(object sender, EventArgs e) } } "; - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); await AssertFormatAsync(expected, expected, changedOptionSet: optionSet); @@ -6783,7 +6782,7 @@ class C } }"; - var options = new Dictionary() { { CSharpFormattingOptions.WrappingPreserveSingleLine, false } }; + var options = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.WrappingPreserveSingleLine, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -6801,7 +6800,7 @@ void goo() } }"; - var options = new Dictionary() { { CSharpFormattingOptions.WrappingPreserveSingleLine, false } }; + var options = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.WrappingPreserveSingleLine, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -6827,7 +6826,7 @@ void goo() } }"; - var options = new Dictionary() { { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } }; + var options = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -6852,7 +6851,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, false }, @@ -6883,7 +6882,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, false }, @@ -6914,7 +6913,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, false }, @@ -6945,7 +6944,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, false }, @@ -6976,7 +6975,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, true }, @@ -7007,7 +7006,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, true }, @@ -7038,7 +7037,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, true }, @@ -7069,7 +7068,7 @@ class Program var a = new[] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, false }, { SpaceWithinSquareBrackets, true }, @@ -7100,7 +7099,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, false }, @@ -7131,7 +7130,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, false }, @@ -7162,7 +7161,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, false }, @@ -7193,7 +7192,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, false }, @@ -7224,7 +7223,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, true }, @@ -7255,7 +7254,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, true }, @@ -7286,7 +7285,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, true }, @@ -7317,7 +7316,7 @@ class Program var a = new[ ] { 0 }; }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBetweenEmptySquareBrackets, true }, { SpaceWithinSquareBrackets, true }, @@ -7353,7 +7352,7 @@ void LocalFunction(int i , string s) } }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { { SpaceBeforeComma, true }, }; @@ -7375,10 +7374,10 @@ class Program var t = new Goo(new[] { ""a"", ""b"" }); }"; - var options = new Dictionary + var options = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceWithinSquareBrackets, true }, - { CSharpFormattingOptions.SpaceBetweenEmptySquareBrackets, false } + { CSharpFormattingOptions2.SpaceWithinSquareBrackets, true }, + { CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -7398,7 +7397,7 @@ class Program int [] x; }"; - var options = new Dictionary() { { CSharpFormattingOptions.SpaceBeforeOpenSquareBracket, true } }; + var options = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.SpaceBeforeOpenSquareBracket, true } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -7417,7 +7416,7 @@ class Program int[ 3 ] x; }"; - var options = new Dictionary() { { CSharpFormattingOptions.SpaceWithinSquareBrackets, true } }; + var options = new OptionsCollection(LanguageNames.CSharp) { { CSharpFormattingOptions2.SpaceWithinSquareBrackets, true } }; await AssertFormatAsync(expected, code, changedOptionSet: options); } @@ -7448,9 +7447,9 @@ public void Method() } }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false } + { CSharpFormattingOptions2.NewLinesForBracesInControlBlocks, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); @@ -7488,9 +7487,9 @@ public void Method() } }"; - var options = new Dictionary() + var options = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false } + { CSharpFormattingOptions2.NewLinesForBracesInControlBlocks, false } }; await AssertFormatAsync(expected, code, changedOptionSet: options); @@ -7543,9 +7542,9 @@ static void Main(string[] args) [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task IgnoreSpacesInDeclarationStatementEnabled() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, true } + { CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, true } }; var code = @" class Program @@ -7896,7 +7895,7 @@ void M() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task ReconstructWhitespaceStringUsingTabs_SingleLineComment() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"using System; class Program @@ -7922,7 +7921,7 @@ static void Main(string[] args) [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task ReconstructWhitespaceStringUsingTabs_MultiLineComment() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"using System; class Program @@ -8109,11 +8108,11 @@ public void DontAssumeCertainNodeAreAlwaysParented() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task SpacingRulesAroundMethodCallAndParenthesisAppliedInAttributeNonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceAfterMethodCallName, true }, - { CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, true }, - { CSharpFormattingOptions.SpaceWithinMethodCallParentheses, true } + { CSharpFormattingOptions2.SpaceAfterMethodCallName, true }, + { CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, true }, + { CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true } }; await AssertFormatAsync(@"[Obsolete ( ""Test"" ), Obsolete ( )] class Program @@ -8173,11 +8172,11 @@ public void goo() M ( ); } }"; - var optionSet = new Dictionary + var optionSet = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceWithinMethodCallParentheses, true }, - { CSharpFormattingOptions.SpaceAfterMethodCallName, true }, - { CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, true }, + { CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true }, + { CSharpFormattingOptions2.SpaceAfterMethodCallName, true }, + { CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, true }, }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); } @@ -8276,9 +8275,9 @@ void Main() } } }"; - var optionSet = new Dictionary + var optionSet = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceAfterSemicolonsInForStatement, false }, + { CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement, false }, }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); @@ -8307,10 +8306,10 @@ void Main() } } }"; - var optionSet = new Dictionary + var optionSet = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceBeforeSemicolonsInForStatement, true }, - { CSharpFormattingOptions.SpaceAfterSemicolonsInForStatement, false }, + { CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement, true }, + { CSharpFormattingOptions2.SpaceAfterSemicolonsInForStatement, false }, }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); @@ -8339,9 +8338,9 @@ void Main() } } }"; - var optionSet = new Dictionary + var optionSet = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpaceBeforeSemicolonsInForStatement, true }, + { CSharpFormattingOptions2.SpaceBeforeSemicolonsInForStatement, true }, }; await AssertFormatAsync(expected, code, changedOptionSet: optionSet); @@ -8374,9 +8373,9 @@ public async Task VerifySpacingAfterMethodDeclarationName_Default() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task VerifySpacingAfterMethodDeclarationName_NonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacingAfterMethodDeclarationName, true } + { CSharpFormattingOptions2.SpacingAfterMethodDeclarationName, true } }; var code = @"class Program { @@ -8484,9 +8483,9 @@ public void goo() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task SwitchSectionHonorsNewLineForBracesinControlBlockOption_NonDefault() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false } + { CSharpFormattingOptions2.NewLinesForBracesInControlBlocks, false } }; var code = @"class Program { @@ -8524,7 +8523,7 @@ public void goo() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task FormattingCodeWithMissingTokensShouldRespectFormatTabsOption1() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"class Program { @@ -8545,7 +8544,7 @@ static void Main() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task FormattingCodeWithMissingTokensShouldRespectFormatTabsOption2() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"struct Goo { @@ -8568,7 +8567,7 @@ public Goo(readonly string bar) [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task FormattingCodeWithBrokenLocalDeclarationShouldRespectFormatTabsOption() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"class AClass { @@ -8608,7 +8607,7 @@ void DoSomething() [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] public async Task FormattingCodeWithBrokenInterpolatedStringShouldRespectFormatTabsOption() { - var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; + var optionSet = new OptionsCollection(LanguageNames.CSharp) { { FormattingOptions2.UseTabs, true } }; await AssertFormatAsync(@"class AClass { @@ -8632,9 +8631,9 @@ void Main() [WorkItem(849870, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849870")] public async Task NewLinesForBracesInPropertiesTest() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInProperties, false } + { CSharpFormattingOptions2.NewLinesForBracesInProperties, false } }; await AssertFormatAsync(@"class Class2 { @@ -8671,9 +8670,9 @@ int MethodGoo() [WorkItem(84, "https://github.com/dotnet/roslyn/issues/84")] public async Task NewLinesForBracesInAccessorsTest() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInAccessors, false } + { CSharpFormattingOptions2.NewLinesForBracesInAccessors, false } }; await AssertFormatAsync(@"class Class2 { @@ -8710,10 +8709,10 @@ int MethodGoo() [WorkItem(84, "https://github.com/dotnet/roslyn/issues/84")] public async Task NewLinesForBracesInPropertiesAndAccessorsTest() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.NewLinesForBracesInProperties, false }, - { CSharpFormattingOptions.NewLinesForBracesInAccessors, false } + { CSharpFormattingOptions2.NewLinesForBracesInProperties, false }, + { CSharpFormattingOptions2.NewLinesForBracesInAccessors, false } }; await AssertFormatAsync(@"class Class2 { @@ -8766,10 +8765,10 @@ void M() [WorkItem(1711675, "https://connect.microsoft.com/VisualStudio/feedback/details/1711675/autoformatting-issues")] public async Task SingleLinePropertiesPreservedWithLeaveStatementsAndMembersOnSingleLineFalse() { - var changedOptionSet = new Dictionary + var changedOptionSet = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.WrappingPreserveSingleLine, true }, - { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false}, + { CSharpFormattingOptions2.WrappingPreserveSingleLine, true }, + { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false}, }; await AssertFormatAsync(@" @@ -9361,7 +9360,7 @@ public void Foo() { var expectedSpacing = spacingAfterMethodDeclarationName ? " " : ""; var initialSpacing = spacingAfterMethodDeclarationName ? "" : " "; - var changedOptionSet = new Dictionary { { SpacingAfterMethodDeclarationName, spacingAfterMethodDeclarationName } }; + var changedOptionSet = new OptionsCollection(LanguageNames.CSharp) { { SpacingAfterMethodDeclarationName, spacingAfterMethodDeclarationName } }; await AssertFormatAsync( $@" public unsafe class Test @@ -9380,9 +9379,9 @@ public unsafe class Test [WorkItem(31868, "https://github.com/dotnet/roslyn/issues/31868")] public async Task SpaceAroundDeclaration() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, true } + { CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, true } }; await AssertFormatAsync( @" @@ -9407,10 +9406,10 @@ public void FixMyType() [WorkItem(31868, "https://github.com/dotnet/roslyn/issues/31868")] public async Task SpaceAroundDeclarationAndPreserveSingleLine() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, true }, - { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } + { CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, true }, + { CSharpFormattingOptions2.WrappingKeepStatementsOnSingleLine, false } }; await AssertFormatAsync( @" @@ -9505,9 +9504,9 @@ public void FixMyType(object o) [WorkItem(37030, "https://github.com/dotnet/roslyn/issues/37030")] public async Task SpaceAroundEnumMemberDeclarationIgnored() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, true } + { CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, true } }; await AssertFormatAsync( @" @@ -9528,9 +9527,9 @@ enum TestEnum [WorkItem(37030, "https://github.com/dotnet/roslyn/issues/37030")] public async Task SpaceAroundEnumMemberDeclarationSingle() { - var changingOptions = new Dictionary + var changingOptions = new OptionsCollection(LanguageNames.CSharp) { - { CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, false } + { CSharpFormattingOptions2.SpacesIgnoreAroundVariableDeclaration, false } }; await AssertFormatAsync( @" diff --git a/src/Workspaces/CoreTestUtilities/Formatting/FormattingTestBase.cs b/src/Workspaces/CoreTestUtilities/Formatting/FormattingTestBase.cs index d3107bf3a5ca83eeab8014257919378afa3a0ff1..2a2e306c9ee8b2fd8e29a9f5e815669a49144364 100644 --- a/src/Workspaces/CoreTestUtilities/Formatting/FormattingTestBase.cs +++ b/src/Workspaces/CoreTestUtilities/Formatting/FormattingTestBase.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; @@ -20,24 +21,24 @@ namespace Microsoft.CodeAnalysis.UnitTests.Formatting [UseExportProvider] public abstract class FormattingTestBase { - protected Task AssertFormatAsync( + private protected Task AssertFormatAsync( string expected, string code, string language, bool debugMode = false, - Dictionary? changedOptionSet = null, + OptionsCollection? changedOptionSet = null, bool testWithTransformation = true) { return AssertFormatAsync(expected, code, new[] { new TextSpan(0, code.Length) }, language, debugMode, changedOptionSet, testWithTransformation); } - protected async Task AssertFormatAsync( + private protected async Task AssertFormatAsync( string expected, string code, IEnumerable spans, string language, bool debugMode = false, - Dictionary? changedOptionSet = null, + OptionsCollection? changedOptionSet = null, bool treeCompare = true, ParseOptions? parseOptions = null) { diff --git a/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj b/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj index f2e87be507a786b6a7be40cfe1620e7cbeeb5704..fa4dc51ce50e4d1e73e635595283c16f1cb63082 100644 --- a/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj +++ b/src/Workspaces/CoreTestUtilities/Roslyn.Services.UnitTests.Utilities.csproj @@ -41,6 +41,8 @@ + + diff --git a/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb b/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb index 656b1dd8424b5fa14c76eab79df03da58730000d..12699b5d9286eefbe0755d6612f1549b41cb9a40 100644 --- a/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb +++ b/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb @@ -2,8 +2,8 @@ ' 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.Formatting -Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic @@ -1706,11 +1706,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1734,11 +1734,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1762,11 +1762,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1792,11 +1792,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1822,11 +1822,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1849,11 +1849,11 @@ End Class vbTab + "End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1875,11 +1875,11 @@ End Class " End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} + {FormattingOptions2.UseTabs, False}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 4} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1901,11 +1901,11 @@ End Class " End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2} + {FormattingOptions2.UseTabs, False}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 2} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1927,11 +1927,11 @@ End Class " End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 6} + {FormattingOptions2.UseTabs, False}, + {FormattingOptions2.TabSize, 4}, + {FormattingOptions2.IndentationSize, 6} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -1953,11 +1953,11 @@ End Class " End Sub" + vbCrLf + "End Class" - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}, - {New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 3}, - {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2} + {FormattingOptions2.UseTabs, True}, + {FormattingOptions2.TabSize, 3}, + {FormattingOptions2.IndentationSize, 2} } Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet) @@ -2025,9 +2025,9 @@ End Class End Sub End Class - Dim optionSet = New Dictionary(Of OptionKey, Object) From + Dim optionSet = New OptionsCollection(LanguageNames.VisualBasic) From { - {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True} + {FormattingOptions2.UseTabs, True} } Await AssertFormatLf2CrLfAsync(code.Value, expected.Value, optionSet) diff --git a/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb b/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb index e47668ef6fa8755b91ba86f3dcc7ae39234c448f..7881726aec877ce9840a2fb0eeb8fb6c71d29bf2 100644 --- a/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb +++ b/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb @@ -4,8 +4,8 @@ Imports System.Collections.Immutable Imports System.Threading +Imports Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions Imports Microsoft.CodeAnalysis.Formatting -Imports Microsoft.CodeAnalysis.Options Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.UnitTests.Formatting Imports Roslyn.Test.Utilities @@ -42,7 +42,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Return StringFromLines(adjustedLines.ToArray()) End Function - Protected Function AssertFormatLf2CrLfAsync(code As String, expected As String, Optional optionSet As Dictionary(Of OptionKey, Object) = Nothing) As Task + Private Protected Function AssertFormatLf2CrLfAsync(code As String, expected As String, Optional optionSet As OptionsCollection = Nothing) As Task code = code.Replace(vbLf, vbCrLf) expected = expected.Replace(vbLf, vbCrLf) @@ -87,22 +87,22 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Return AssertFormatAsync(expected, code, spans) End Function - Protected Overloads Function AssertFormatAsync( + Private Protected Overloads Function AssertFormatAsync( code As String, expected As String, Optional debugMode As Boolean = False, - Optional changedOptionSet As Dictionary(Of OptionKey, Object) = Nothing, + Optional changedOptionSet As OptionsCollection = Nothing, Optional testWithTransformation As Boolean = False, Optional experimental As Boolean = False) As Task Return AssertFormatAsync(expected, code, SpecializedCollections.SingletonEnumerable(New TextSpan(0, code.Length)), debugMode, changedOptionSet, testWithTransformation, experimental:=experimental) End Function - Protected Overloads Function AssertFormatAsync( + Private Protected Overloads Function AssertFormatAsync( expected As String, code As String, spans As IEnumerable(Of TextSpan), Optional debugMode As Boolean = False, - Optional changedOptionSet As Dictionary(Of OptionKey, Object) = Nothing, + Optional changedOptionSet As OptionsCollection = Nothing, Optional testWithTransformation As Boolean = False, Optional experimental As Boolean = False) As Task