diff --git a/src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs b/src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs index 8cc171331837f1b51244cc90cdc6ea59400fd3c2..bdea319004336fb14a0c171033814143378e3fc6 100644 --- a/src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs +++ b/src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs @@ -334,13 +334,13 @@ private bool TryCreateUpdatedSolution(ChangeSignatureAnalyzedContext context, Ch var annotatedNodes = newRoot.GetAnnotatedNodes(syntaxAnnotation: changeSignatureFormattingAnnotation); - var formattedRoot = Formatter.Format( + var formattedRoot = Formatter.FormatAsync( newRoot, changeSignatureFormattingAnnotation, doc.Project.Solution.Workspace, options: null, rules: GetFormattingRules(doc), - cancellationToken: CancellationToken.None); + cancellationToken: CancellationToken.None).WaitAndGetResult(CancellationToken.None); updatedRoots[docId] = formattedRoot; } diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedLanguageCodeSupport.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedLanguageCodeSupport.cs index 8e64f89d3841226013813320aa795e9844bd069b..ce1f6761b709471b5298ea90a24c498c779ab460 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedLanguageCodeSupport.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedLanguageCodeSupport.cs @@ -218,7 +218,7 @@ public static string GetEventHandlerMemberId(Document document, string className var formattingRules = additionalFormattingRule.Concat(Formatter.GetDefaultFormattingRules(targetDocument)); var workspace = targetDocument.Project.Solution.Workspace; - newRoot = Formatter.Format(newRoot, Formatter.Annotation, workspace, workspace.Options, formattingRules, cancellationToken); + newRoot = Formatter.FormatAsync(newRoot, Formatter.Annotation, workspace, workspace.Options, formattingRules, cancellationToken).WaitAndGetResult(cancellationToken); var newMember = newRoot.GetAnnotatedNodesAndTokens(annotation).Single(); var newMemberText = newMember.ToFullString(); diff --git a/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs b/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs index d3321ea2fa35992256369861deaaf20449074c51..c0779627003986f2195072b9dfef4908ffdf50cc 100644 --- a/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs +++ b/src/Workspaces/CSharpTest/Formatting/CSharpFormattingTestBase.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests.Formatting; @@ -17,7 +18,7 @@ protected override SyntaxNode ParseCompilation(string text, ParseOptions parseOp return SyntaxFactory.ParseCompilationUnit(text, options: (CSharpParseOptions)parseOptions); } - protected void AssertFormat( + protected Task AssertFormatAsync( string expected, string code, bool debugMode = false, @@ -25,10 +26,10 @@ protected override SyntaxNode ParseCompilation(string text, ParseOptions parseOp bool testWithTransformation = true, ParseOptions parseOptions = null) { - AssertFormat(expected, code, SpecializedCollections.SingletonEnumerable(new TextSpan(0, code.Length)), debugMode, changedOptionSet, testWithTransformation, parseOptions); + return AssertFormatAsync(expected, code, SpecializedCollections.SingletonEnumerable(new TextSpan(0, code.Length)), debugMode, changedOptionSet, testWithTransformation, parseOptions); } - protected void AssertFormat( + protected Task AssertFormatAsync( string expected, string code, IEnumerable spans, @@ -37,7 +38,7 @@ protected override SyntaxNode ParseCompilation(string text, ParseOptions parseOp bool testWithTransformation = true, ParseOptions parseOptions = null) { - AssertFormat(expected, code, spans, LanguageNames.CSharp, debugMode, changedOptionSet, testWithTransformation, parseOptions); + return AssertFormatAsync(expected, code, spans, LanguageNames.CSharp, debugMode, changedOptionSet, testWithTransformation, parseOptions); } } -} +} \ No newline at end of file diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs index bc35413686854d344291ae412ac32fd1e2255be7..0651fedc8c6a32fd10f25f7c7a5b97b55107290c 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingMultipleSpanTests.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.Formatting; @@ -18,22 +19,22 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Formatting public class FormattingEngineMultiSpanTests : CSharpFormattingTestBase { [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void EndOfLine() + public async Task EndOfLine() { var content = @"namespace A{/*1*/}/*2*/"; var expected = @"namespace A{}"; - AssertFormat(content, expected); + await AssertFormatAsync(content, expected).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Simple1() + public async Task Simple1() { - AssertFormat("namespace A/*1*/{}/*2*/ class A {}", "namespace A{ } class A {}"); + await AssertFormatAsync("namespace A/*1*/{}/*2*/ class A {}", "namespace A{ } class A {}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontFormatTriviaOutsideOfSpan_IncludingTrailingTriviaOnNewLine() + public async Task DontFormatTriviaOutsideOfSpan_IncludingTrailingTriviaOnNewLine() { var content = @"namespace A /*1*/{ @@ -47,11 +48,11 @@ class A /*1*/{}/*2*/"; class A { }"; - AssertFormat(content, expected); + await AssertFormatAsync(content, expected).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatIncludingTrivia() + public async Task FormatIncludingTrivia() { var content = @"namespace A /*1*/{ @@ -65,11 +66,11 @@ class A /*1*/{}/*2*/"; class A { }"; - AssertFormat(content, expected); + await AssertFormatAsync(content, expected).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MergeSpanAndFormat() + public async Task MergeSpanAndFormat() { var content = @"namespace A /*1*/{ @@ -83,11 +84,11 @@ class A{}/*2*/"; class A { }"; - AssertFormat(content, expected); + await AssertFormatAsync(content, expected).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void OverlappedSpan() + public async Task OverlappedSpan() { var content = @"namespace A /*1*/{ @@ -101,13 +102,13 @@ class A{}/*2*/"; class A { }"; - AssertFormat(content, expected); + await AssertFormatAsync(content, expected).ConfigureAwait(true); } [Fact] [WorkItem(554160, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatSpanNullReference01() + public async Task FormatSpanNullReference01() { var code = @"/*1*/class C { @@ -126,13 +127,13 @@ void F() }"; var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.IndentBlock, false); - AssertFormat(code, expected, changedOptionSet: changingOptions); + await AssertFormatAsync(code, expected, changedOptionSet: changingOptions).ConfigureAwait(true); } [Fact] [WorkItem(554160, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatSpanNullReference02() + public async Task FormatSpanNullReference02() { var code = @"class C/*1*/ { @@ -151,7 +152,7 @@ void F() }"; var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.WrappingPreserveSingleLine, false); - AssertFormat(code, expected, changedOptionSet: changingOptions); + await AssertFormatAsync(code, expected, changedOptionSet: changingOptions).ConfigureAwait(true); } [WorkItem(539231, "DevDiv")] @@ -168,11 +169,11 @@ public void EmptySpan() } } - private void AssertFormat(string content, string expected, Dictionary changedOptionSet = null) + private Task AssertFormatAsync(string content, string expected, Dictionary changedOptionSet = null) { var tuple = PreprocessMarkers(content); - AssertFormat(expected, tuple.Item1, tuple.Item2, changedOptionSet: changedOptionSet); + return AssertFormatAsync(expected, tuple.Item1, tuple.Item2, changedOptionSet: changedOptionSet); } private Tuple> PreprocessMarkers(string codeWithMarker) diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs index 7048d30df62ee33e3fe76f567e160a2ffa2118a2..bd41ec02eb59a49bd7570c6e61893ce41a3e2ae8 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; @@ -15,13 +16,13 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Formatting public class FormattingEngineTests : CSharpFormattingTestBase { [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format1() + public async Task Format1() { - AssertFormat("namespace A { }", "namespace A{}"); + await AssertFormatAsync("namespace A { }", "namespace A{}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format2() + public async Task Format2() { var content = @"class A { }"; @@ -29,11 +30,11 @@ public void Format2() var expected = @"class A { }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format3() + public async Task Format3() { var content = @"class A { @@ -44,11 +45,11 @@ public void Format3() int i = 20; }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format4() + public async Task Format4() { var content = @"class A { @@ -62,11 +63,11 @@ public void Format4() T.S = Test( 10 ); }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format5() + public async Task Format5() { var content = @"class A { @@ -85,11 +86,11 @@ public void Format5() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format6() + public async Task Format6() { var content = @"class A { @@ -108,11 +109,11 @@ public void Format6() }; }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format7() + public async Task Format7() { var content = @"class A { @@ -124,11 +125,11 @@ public void Format7() var a = from i in new[] { 1, 2, 3 } where i > 10 select i; }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format8() + public async Task Format8() { var content = @"class A { @@ -156,11 +157,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format9() + public async Task Format9() { var content = @"class A { @@ -178,11 +179,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Format10() + public async Task Format10() { var content = @"class A { @@ -197,13 +198,13 @@ public void Format10() select i; }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ObjectInitializer() + public async Task ObjectInitializer() { - AssertFormat(@"public class C + await AssertFormatAsync(@"public class C { public C() { @@ -229,13 +230,13 @@ public C() } }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AnonymousType() + public async Task AnonymousType() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { C() { @@ -263,13 +264,13 @@ public void AnonymousType() p4 = true }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MultilineLambda() + public async Task MultilineLambda() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { C() { @@ -297,13 +298,13 @@ public void MultilineLambda() return x + 1; }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AnonymousMethod() + public async Task AnonymousMethod() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { C() { @@ -321,13 +322,13 @@ public void AnonymousMethod() MessageBox.Show(this, ""Timer ticked""); }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen1() + public async Task Scen1() { - AssertFormat(@"namespace Namespace1 + await AssertFormatAsync(@"namespace Namespace1 { class Program { @@ -388,13 +389,13 @@ static void Method(int i, string s, bool b) { } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen2() + public async Task Scen2() { - AssertFormat(@"namespace MyNamespace + await AssertFormatAsync(@"namespace MyNamespace { class Class1 { @@ -684,13 +685,13 @@ static void Main() } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen3() + public async Task Scen3() { - AssertFormat(@"namespace Namespace1 + await AssertFormatAsync(@"namespace Namespace1 { class Program { @@ -708,13 +709,13 @@ static void Main() Program p=new Program(); } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen4() + public async Task Scen4() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { // public void foo() // { @@ -728,13 +729,13 @@ public void Scen4() // // TODO: Add the implementation for Class1.foo() here. // // } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen5() + public async Task Scen5() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { public void Method() { @@ -752,13 +753,13 @@ public void Method() System.Console.WriteLine(); } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen6() + public async Task Scen6() { - AssertFormat(@"namespace Namespace1 + await AssertFormatAsync(@"namespace Namespace1 { class OuterClass { @@ -774,13 +775,13 @@ class InnerClass { } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen7() + public async Task Scen7() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { public void Method() { @@ -810,13 +811,13 @@ public void Method() z: i = 2 * i; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Scen8() + public async Task Scen8() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { public void Method() { @@ -828,13 +829,13 @@ public void Method() { int i = 10; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IndentStatementsInMethod() + public async Task IndentStatementsInMethod() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void Foo() { @@ -850,13 +851,13 @@ void Foo() int y = 0; int z = 0; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IndentFieldsInClass() + public async Task IndentFieldsInClass() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int a = 10; int b; @@ -866,13 +867,13 @@ public void IndentFieldsInClass() int a = 10; int b; int c; -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IndentUserDefaultSettingTest() + public async Task IndentUserDefaultSettingTest() { - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { public void nothing() { @@ -946,16 +947,16 @@ public void nothing_again(Action a) l: goto l; } - }"); + }").ConfigureAwait(true); } [WorkItem(766133, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void RelativeIndentationToFirstTokenInBaseTokenWithObjectInitializers() + public async Task RelativeIndentationToFirstTokenInBaseTokenWithObjectInitializers() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false); - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -986,15 +987,15 @@ class D { public int A { get; set; } public int B { get; set; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void RemoveSpacingAroundBinaryOperatorsShouldMakeAtLeastOneSpaceForIsAndAsKeywords() + public async Task RemoveSpacingAroundBinaryOperatorsShouldMakeAtLeastOneSpaceForIsAndAsKeywords() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.SpacingAroundBinaryOperator, BinaryOperatorSpacingOptions.Remove); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { public void nothing() { @@ -1014,12 +1015,12 @@ public void nothing() string s = o as string; bool b = o is string; } - }", false, changingOptions); + }", false, changingOptions).ConfigureAwait(true); } [WorkItem(772298, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IndentUserSettingNonDefaultTest_OpenBracesOfLambdaWithNoNewLine() + public async Task IndentUserSettingNonDefaultTest_OpenBracesOfLambdaWithNoNewLine() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.IndentBraces, true); @@ -1028,7 +1029,7 @@ public void IndentUserSettingNonDefaultTest_OpenBracesOfLambdaWithNoNewLine() changingOptions.Add(CSharpFormattingOptions.IndentSwitchCaseSection, false); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInLambdaExpressionBody, false); changingOptions.Add(CSharpFormattingOptions.LabelPositioning, LabelPositionOptions.LeftMost); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { public void nothing() { @@ -1045,11 +1046,11 @@ public void nothing() Console.WriteLine(""Nothing""); }); } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IndentUserSettingNonDefaultTest() + public async Task IndentUserSettingNonDefaultTest() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.IndentBraces, true); @@ -1057,7 +1058,7 @@ public void IndentUserSettingNonDefaultTest() changingOptions.Add(CSharpFormattingOptions.IndentSwitchSection, false); changingOptions.Add(CSharpFormattingOptions.IndentSwitchCaseSection, false); changingOptions.Add(CSharpFormattingOptions.LabelPositioning, LabelPositionOptions.LeftMost); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { public void nothing() { @@ -1131,13 +1132,13 @@ public void nothing_again(Action a) l: goto l; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestWrappingDefault() + public async Task TestWrappingDefault() { - AssertFormat(@"class Class5 + await AssertFormatAsync(@"class Class5 { delegate void Del(int x); public int Age { get { int age = 0; return age; } } @@ -1171,15 +1172,15 @@ void bar() switch (x) { case 1: break; case 2: break; default: break; } Del d = delegate(int k) { Console.WriteLine(); Console.WriteLine(); }; } - }"); + }").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestWrappingNonDefault_FormatBlock() + public async Task TestWrappingNonDefault_FormatBlock() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.WrappingPreserveSingleLine, false); - AssertFormat(@"class Class5 + await AssertFormatAsync(@"class Class5 { delegate void Del(int x); public int Age @@ -1240,15 +1241,15 @@ void bar() } void foo() { int xx = 0; int zz = 0;} } -class foo{int x = 0;}", false, changingOptions); +class foo{int x = 0;}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestWrappingNonDefault_FormatStatmtMethDecl() + public async Task TestWrappingNonDefault_FormatStatmtMethDecl() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false); - AssertFormat(@"class Class5 + await AssertFormatAsync(@"class Class5 { delegate void Del(int x); public int Age { get { int age = 0; return age; } } @@ -1305,16 +1306,16 @@ void bar() class foo { int x = 0; -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestWrappingNonDefault() + public async Task TestWrappingNonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.WrappingPreserveSingleLine, false); changingOptions.Add(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false); - AssertFormat(@"class Class5 + await AssertFormatAsync(@"class Class5 { delegate void Del(int x); public int Age @@ -1385,16 +1386,16 @@ void bar() Del d = delegate(int k) { Console.WriteLine(); Console.WriteLine(); }; } } -class foo{int x = 0;}", false, changingOptions); +class foo{int x = 0;}", false, changingOptions).ConfigureAwait(true); } [WorkItem(991480)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestLeaveStatementMethodDeclarationSameLineNotAffectingForStatement() + public async Task TestLeaveStatementMethodDeclarationSameLineNotAffectingForStatement() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false); - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -1407,14 +1408,14 @@ static void Main(string[] args) { for (int d = 0; d < 10; ++d) { } } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [WorkItem(751789, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForOpenBracesDefault() + public async Task NewLineForOpenBracesDefault() { - AssertFormat(@"class f00 + await AssertFormatAsync(@"class f00 { void br() { @@ -1532,12 +1533,12 @@ public class foo : System.Object { public int f { get; set; } } -}"); +}").ConfigureAwait(true); } [WorkItem(751789, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForOpenBracesNonDefault() + public async Task NewLineForOpenBracesNonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInTypes, false); @@ -1547,7 +1548,7 @@ public void NewLineForOpenBracesNonDefault() changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInAnonymousTypes, false); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers, false); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInLambdaExpressionBody, false); - AssertFormat(@"class f00 { + await AssertFormatAsync(@"class f00 { void br() { Func ret = x => { return x + 1; @@ -1643,13 +1644,13 @@ public class foo : System.Object { } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForKeywordDefault() + public async Task NewLineForKeywordDefault() { - AssertFormat(@"class c + await AssertFormatAsync(@"class c { void f00() { @@ -1700,17 +1701,17 @@ void f00() return 0; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForKeywordNonDefault() + public async Task NewLineForKeywordNonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLineForElse, false); changingOptions.Add(CSharpFormattingOptions.NewLineForCatch, false); changingOptions.Add(CSharpFormattingOptions.NewLineForFinally, false); - AssertFormat(@"class c + await AssertFormatAsync(@"class c { void f00() { @@ -1763,13 +1764,13 @@ void f00() return 0; } } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForExpressionDefault() + public async Task NewLineForExpressionDefault() { - AssertFormat(@"class f00 + await AssertFormatAsync(@"class f00 { void br() { @@ -1830,17 +1831,17 @@ void br() }; MyObject obj = new MyObject { X1 = 0, Y1 = 1, X2 = 2, Y2 = 3 }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineForExpressionNonDefault() + public async Task NewLineForExpressionNonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLineForMembersInObjectInit, false); changingOptions.Add(CSharpFormattingOptions.NewLineForMembersInAnonymousTypes, false); changingOptions.Add(CSharpFormattingOptions.NewLineForClausesInQuery, false); - AssertFormat(@"class f00 + await AssertFormatAsync(@"class f00 { void br() { @@ -1894,13 +1895,13 @@ void br() Y2 = 3 }; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Enums_Bug2586() + public async Task Enums_Bug2586() { - AssertFormat(@"enum E + await AssertFormatAsync(@"enum E { a = 10, b, @@ -1910,19 +1911,19 @@ public void Enums_Bug2586() a = 10, b, c -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontInsertLineBreaksInSingleLineEnum() + public async Task DontInsertLineBreaksInSingleLineEnum() { - AssertFormat(@"enum E { a = 10, b, c }", @"enum E { a = 10, b, c }"); + await AssertFormatAsync(@"enum E { a = 10, b, c }", @"enum E { a = 10, b, c }").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AlreadyFormattedSwitchIsNotFormatted_Bug2588() + public async Task AlreadyFormattedSwitchIsNotFormatted_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -1942,13 +1943,13 @@ void M() break; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void BreaksAreAlignedInSwitchCasesFormatted_Bug2587() + public async Task BreaksAreAlignedInSwitchCasesFormatted_Bug2587() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -1968,13 +1969,13 @@ void M() break; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void BreaksAndBracesAreAlignedInSwitchCasesWithBracesFormatted_Bug2587() + public async Task BreaksAndBracesAreAlignedInSwitchCasesWithBracesFormatted_Bug2587() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -1998,13 +1999,13 @@ void M() } } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void LineBreaksAreNotInsertedForSwitchCasesOnASingleLine1() + public async Task LineBreaksAreNotInsertedForSwitchCasesOnASingleLine1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2024,13 +2025,13 @@ void M() default: break; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void LineBreaksAreNotInsertedForSwitchCasesOnASingleLine2() + public async Task LineBreaksAreNotInsertedForSwitchCasesOnASingleLine2() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2050,13 +2051,13 @@ void M() default: { break; } } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatLabelAndGoto1_Bug2588() + public async Task FormatLabelAndGoto1_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2070,13 +2071,13 @@ void M() Foo: goto Foo; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatLabelAndGoto2_Bug2588() + public async Task FormatLabelAndGoto2_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2092,13 +2093,13 @@ void M() Foo: goto Foo; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatNestedLabelAndGoto1_Bug2588() + public async Task FormatNestedLabelAndGoto1_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2118,13 +2119,13 @@ void M() goto Foo; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatNestedLabelAndGoto2_Bug2588() + public async Task FormatNestedLabelAndGoto2_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2146,13 +2147,13 @@ void M() goto Foo; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AlreadyFormattedGotoLabelIsNotFormatted1_Bug2588() + public async Task AlreadyFormattedGotoLabelIsNotFormatted1_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2166,13 +2167,13 @@ void M() Foo: goto Foo; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AlreadyFormattedGotoLabelIsNotFormatted2_Bug2588() + public async Task AlreadyFormattedGotoLabelIsNotFormatted2_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2184,13 +2185,13 @@ void M() { Foo: goto Foo; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AlreadyFormattedGotoLabelIsNotFormatted3_Bug2588() + public async Task AlreadyFormattedGotoLabelIsNotFormatted3_Bug2588() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2206,13 +2207,13 @@ void M() Foo: goto Foo; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontAddLineBreakBeforeWhere1_Bug2582() + public async Task DontAddLineBreakBeforeWhere1_Bug2582() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() where T : I { @@ -2222,23 +2223,23 @@ public void DontAddLineBreakBeforeWhere1_Bug2582() void M() where T : I { } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontAddLineBreakBeforeWhere2_Bug2582() + public async Task DontAddLineBreakBeforeWhere2_Bug2582() { - AssertFormat(@"class C where T : I + await AssertFormatAsync(@"class C where T : I { }", @"class C where T : I { -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontAddSpaceAfterUnaryMinus() + public async Task DontAddSpaceAfterUnaryMinus() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2250,13 +2251,13 @@ void M() { int x = -1; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontAddSpaceAfterUnaryPlus() + public async Task DontAddSpaceAfterUnaryPlus() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2268,12 +2269,12 @@ void M() { int x = +1; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(545909, "DevDiv")] - public void DontAddSpaceAfterIncrement() + public async Task DontAddSpaceAfterIncrement() { var code = @"class C { @@ -2282,12 +2283,12 @@ void M(int[] i) ++i[0]; } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(545909, "DevDiv")] - public void DontAddSpaceBeforeIncrement() + public async Task DontAddSpaceBeforeIncrement() { var code = @"class C { @@ -2296,12 +2297,12 @@ void M(int[] i) i[0]++; } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(545909, "DevDiv")] - public void DontAddSpaceAfterDecrement() + public async Task DontAddSpaceAfterDecrement() { var code = @"class C { @@ -2310,12 +2311,12 @@ void M(int[] i) --i[0]; } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(545909, "DevDiv")] - public void DontAddSpaceBeforeDecrement() + public async Task DontAddSpaceBeforeDecrement() { var code = @"class C { @@ -2324,13 +2325,13 @@ void M(int[] i) i[0]--; } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Anchoring() + public async Task Anchoring() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2346,13 +2347,13 @@ void M() 0, 1, 2); } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Exclamation() + public async Task Exclamation() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { void M() { @@ -2364,13 +2365,13 @@ void M() { if ( ! true ) ; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void StartAndEndTrivia() + public async Task StartAndEndTrivia() { - AssertFormat(@" + await AssertFormatAsync(@" class C { } @@ -2386,13 +2387,13 @@ class C { } -"); +").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FirstTriviaAndAnchoring1() + public async Task FirstTriviaAndAnchoring1() { - AssertFormat(@" + await AssertFormatAsync(@" namespace N { class C @@ -2423,13 +2424,13 @@ class C { -"); +").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FirstTriviaAndAnchoring2() + public async Task FirstTriviaAndAnchoring2() { - AssertFormat(@" + await AssertFormatAsync(@" namespace N { class C @@ -2455,13 +2456,13 @@ class C { -"); +").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FirstTriviaAndAnchoring3() + public async Task FirstTriviaAndAnchoring3() { - AssertFormat(@" + await AssertFormatAsync(@" class C { @@ -2484,13 +2485,13 @@ class C { -"); +").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Base1() + public async Task Base1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { C() : base() { @@ -2500,13 +2501,13 @@ public void Base1() C ( ) : base ( ) { } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void This1() + public async Task This1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { C(int i) : this() { @@ -2520,13 +2521,13 @@ public void This1() } C ( ) { } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryExpression1() + public async Task QueryExpression1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2540,13 +2541,13 @@ int Method() var q = from c in from b in cs select b select c; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryExpression2() + public async Task QueryExpression2() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2564,13 +2565,13 @@ int Method() select b select c; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryExpression3() + public async Task QueryExpression3() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2594,13 +2595,13 @@ int Method() 3) select new { b, c }; } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryExpression4() + public async Task QueryExpression4() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2620,13 +2621,13 @@ int Method() select b select c; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label1() + public async Task Label1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2638,13 +2639,13 @@ int Method() { L : int i = 10 ; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label2() + public async Task Label2() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2658,13 +2659,13 @@ int Method() int x = 1 ; L : int i = 10 ; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label3() + public async Task Label3() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2680,13 +2681,13 @@ int Method() L : int i = 10 ; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label4() + public async Task Label4() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2702,13 +2703,13 @@ int Method() L : int i = 10 ; int next = 30; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label5() + public async Task Label5() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2722,13 +2723,13 @@ int Method() L : int i = 10 ; int next = 30; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label6() + public async Task Label6() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2744,13 +2745,13 @@ int Method() int i = 10 ; int next = 30; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label7() + public async Task Label7() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2768,13 +2769,13 @@ int Method() int i = 10 ; int next = 30; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Label8() + public async Task Label8() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2790,13 +2791,13 @@ int Method() int i = 10; } - } "); + } ").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AutoProperty() + public async Task AutoProperty() { - AssertFormat(@"class Class + await AssertFormatAsync(@"class Class { private int Age { get; set; } public string Names { get; set; } @@ -2804,13 +2805,13 @@ public void AutoProperty() { private int Age{get; set; } public string Names { get; set;} -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NormalPropertyGet() + public async Task NormalPropertyGet() { - AssertFormat(@"class Class + await AssertFormatAsync(@"class Class { private string name; public string Names @@ -2830,13 +2831,13 @@ public string Names return name; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NormalPropertyBoth() + public async Task NormalPropertyBoth() { - AssertFormat(@"class Class + await AssertFormatAsync(@"class Class { private string name; public string Names @@ -2864,13 +2865,13 @@ public string Names name = value; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ErrorHandling1() + public async Task ErrorHandling1() { - AssertFormat(@"class C + await AssertFormatAsync(@"class C { int Method() { @@ -2882,14 +2883,14 @@ int Method() { int a b c ; } - } "); + } ").ConfigureAwait(true); } [WorkItem(537763, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NullableType() + public async Task NullableType() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -2901,25 +2902,25 @@ static void Main(string[] args) { int ? i = 10; } -}"); +}").ConfigureAwait(true); } [WorkItem(537766, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SuppressWrappingOnBraces() + public async Task SuppressWrappingOnBraces() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { } ", @"class Class1 {} -"); +").ConfigureAwait(true); } [WorkItem(537824, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DoWhile() + public async Task DoWhile() { - AssertFormat(@"public class Class1 + await AssertFormatAsync(@"public class Class1 { void Foo() { @@ -2937,14 +2938,14 @@ void Foo() }while (true); } } -"); +").ConfigureAwait(true); } [WorkItem(537774, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SuppressWrappingBug() + public async Task SuppressWrappingBug() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { int Foo() { @@ -2957,14 +2958,14 @@ int Foo() {return 0; } } -"); +").ConfigureAwait(true); } [WorkItem(537768, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void PreserveLineForAttribute() + public async Task PreserveLineForAttribute() { - AssertFormat(@"class Class1 + await AssertFormatAsync(@"class Class1 { [STAThread] static void Main(string[] args) @@ -2978,14 +2979,14 @@ static void Main(string[] args) { } } -"); +").ConfigureAwait(true); } [WorkItem(537878, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NoFormattingOnMissingTokens() + public async Task NoFormattingOnMissingTokens() { - AssertFormat(@"namespace ClassLibrary1 + await AssertFormatAsync(@"namespace ClassLibrary1 { class Class1 { @@ -3005,14 +3006,14 @@ void Foo() } } } -"); +").ConfigureAwait(true); } [WorkItem(537783, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void UnaryExpression() + public async Task UnaryExpression() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3028,14 +3029,14 @@ static void Main(string[] args) a = a++ + 5; } } -"); +").ConfigureAwait(true); } [WorkItem(537885, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Pointer() + public async Task Pointer() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3049,14 +3050,14 @@ static void Main(string[] args) int* p; } } -"); +").ConfigureAwait(true); } [WorkItem(537886, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Tild() + public async Task Tild() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3072,14 +3073,14 @@ static void Main(string[] args) j = ~7; } } -"); +").ConfigureAwait(true); } [WorkItem(537884, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ArrayInitializer1() + public async Task ArrayInitializer1() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3097,14 +3098,14 @@ static void Main(string[] args) }; } } -"); +").ConfigureAwait(true); } [WorkItem(537884, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ArrayInitializer2() + public async Task ArrayInitializer2() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3122,14 +3123,14 @@ static void Main(string[] args) }; } } -"); +").ConfigureAwait(true); } [WorkItem(537884, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ImplicitArrayInitializer() + public async Task ImplicitArrayInitializer() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3147,14 +3148,14 @@ static void Main(string[] args) } ; } } -"); +").ConfigureAwait(true); } [WorkItem(537884, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void CollectionInitializer() + public async Task CollectionInitializer() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3172,14 +3173,14 @@ static void Main(string[] args) }; } } -"); +").ConfigureAwait(true); } [WorkItem(537916, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void AddressOfOperator() + public async Task AddressOfOperator() { - AssertFormat(@"unsafe class Class1 + await AssertFormatAsync(@"unsafe class Class1 { void Method() { @@ -3195,14 +3196,14 @@ void Method() int* p = &a; } } -"); +").ConfigureAwait(true); } [WorkItem(537885, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DereferenceOperator() + public async Task DereferenceOperator() { - AssertFormat(@"unsafe class Class1 + await AssertFormatAsync(@"unsafe class Class1 { void Method() { @@ -3220,32 +3221,32 @@ void Method() Console.WriteLine(* p); } } -"); +").ConfigureAwait(true); } [WorkItem(537905, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Namespaces() + public async Task Namespaces() { - AssertFormat(@"using System; -using System.Data;", @"using System; using System.Data;"); + await AssertFormatAsync(@"using System; +using System.Data;", @"using System; using System.Data;").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NamespaceDeclaration() + public async Task NamespaceDeclaration() { - AssertFormat(@"namespace N + await AssertFormatAsync(@"namespace N { }", @"namespace N { -}"); +}").ConfigureAwait(true); } [WorkItem(537902, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DoWhile1() + public async Task DoWhile1() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3259,13 +3260,13 @@ static void Main(string[] args) do { } while (i < 4); } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewConstraint() + public async Task NewConstraint() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { void Test(T t) where T : new() { @@ -3275,13 +3276,13 @@ void Test(T t) where T : new() void Test(T t) where T : new ( ) { } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void UnaryExpressionWithInitializer() + public async Task UnaryExpressionWithInitializer() { - AssertFormat(@"using System; + await AssertFormatAsync(@"using System; using System.Collections.Generic; using System.Linq; @@ -3307,26 +3308,26 @@ static void Main(string[] args) return; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Attributes1() + public async Task Attributes1() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { [Flags] public void Method() { } }", @"class Program { [ Flags ] public void Method ( ) { } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Attributes2() + public async Task Attributes2() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { [Flags] public void Method() { } @@ -3334,14 +3335,14 @@ public void Attributes2() { [ Flags ] public void Method ( ) { } -}"); +}").ConfigureAwait(true); } [WorkItem(538288, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ColonColon1() + public async Task ColonColon1() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { public void Method() { @@ -3352,34 +3353,34 @@ public void Method() public void Method ( ) { throw new global :: System.NotImplementedException(); } -}"); +}").ConfigureAwait(true); } [WorkItem(538354, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix3939() + public async Task BugFix3939() { - AssertFormat(@"using + await AssertFormatAsync(@"using System. Collections. Generic;", @" using System. Collections. - Generic;"); + Generic;").ConfigureAwait(true); } [WorkItem(538354, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Tab1() + public async Task Tab1() { - AssertFormat(@"using System;", @" using System;"); + await AssertFormatAsync(@"using System;", @" using System;").ConfigureAwait(true); } [WorkItem(538329, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SuppressLinkBreakInIfElseStatement() + public async Task SuppressLinkBreakInIfElseStatement() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3395,14 +3396,14 @@ static void Main(string[] args) if (true) a = 10; else a = 11; } -}"); +}").ConfigureAwait(true); } [WorkItem(538464, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix4087() + public async Task BugFix4087() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main(string[] args) { @@ -3414,13 +3415,13 @@ static void Main(string[] args) { Func fun = x => { return x + 1; } } -}"); +}").ConfigureAwait(true); } [Fact] [WorkItem(538511, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void AttributeTargetSpecifier() + public async Task AttributeTargetSpecifier() { var code = @"public class Class1 { @@ -3438,13 +3439,13 @@ void Test() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(538635, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Finalizer() + public async Task Finalizer() { var code = @"public class Class1 { @@ -3456,13 +3457,13 @@ public void Finalizer() ~Class1() { } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(538743, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix4442() + public async Task BugFix4442() { var code = @"class Program { @@ -3474,13 +3475,13 @@ static void Main(string[] args) } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact] [WorkItem(538658, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix4328() + public async Task BugFix4328() { var code = @"class Program { @@ -3496,13 +3497,13 @@ static void Main(string[] args) double d = new double(); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(538658, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix4515() + public async Task BugFix4515() { var code = @"class Program { @@ -3522,12 +3523,12 @@ static void Main(string[] args) var t2 = sizeof(System.Object); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void CastExpressionTest() + public async Task CastExpressionTest() { var code = @"class Program { @@ -3543,12 +3544,12 @@ static void Main(string[] args) var a = (int)1; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void NamedParameter() + public async Task NamedParameter() { var code = @"class Program { @@ -3564,13 +3565,13 @@ static void Main(string[] args) Main(args: null); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539259, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5143() + public async Task BugFix5143() { var code = @"class Program { @@ -3588,13 +3589,13 @@ static void Main(string[] args) delegate (int x) { return x; }); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539338, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5251() + public async Task BugFix5251() { var code = @"class Program { @@ -3604,13 +3605,13 @@ public void BugFix5251() { public static string Foo { get; private set; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539358, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5277() + public async Task BugFix5277() { var code = @" #if true @@ -3620,13 +3621,13 @@ public void BugFix5277() #if true #endif "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539542, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5544() + public async Task BugFix5544() { var code = @" class Program @@ -3648,13 +3649,13 @@ unsafe static void Main(string[] args) } } "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539587, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5602() + public async Task BugFix5602() { var code = @" class Bug { @@ -3670,13 +3671,13 @@ public static void func() long b = // } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(539616, "DevDiv")] [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5637() + public async Task BugFix5637() { var code = @"class Bug { @@ -3692,12 +3693,12 @@ public static void func() { } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void GenericType() + public async Task GenericType() { var code = @"class Bug { @@ -3711,13 +3712,13 @@ class N : Bug { } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(539878, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5978() + public async Task BugFix5978() { var code = @"class Program { @@ -3757,13 +3758,13 @@ static void Main(string[] args) } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(539878, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5979() + public async Task BugFix5979() { var code = @"delegate int del(int i); class Program @@ -3789,13 +3790,13 @@ static void Main(string[] args) }; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(539891, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix5993() + public async Task BugFix5993() { var code = @"public class MyClass { @@ -3819,13 +3820,13 @@ public static void Main() } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(540315, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix6536() + public async Task BugFix6536() { var code = @"public class MyClass { @@ -3841,13 +3842,13 @@ public static void Main() int i = - -1 + + +1 + -+1 + -+1; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(540801, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix7211() + public async Task BugFix7211() { var code = @"class Program { @@ -3870,13 +3871,13 @@ static void Main(string[] args) } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(541035, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix7564_1() + public async Task BugFix7564_1() { var code = @"class Program { @@ -3899,13 +3900,13 @@ static void Main(string[] args) } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(541035, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void BugFix7564_2() + public async Task BugFix7564_2() { var code = @"class Program { @@ -3928,13 +3929,13 @@ static void Main(string[] args) } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(8385, "DevDiv_Projects/Roslyn")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void NullCoalescingOperator() + public async Task NullCoalescingOperator() { var code = @"class C { @@ -3951,13 +3952,13 @@ void M() object o2 = null ?? null; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(541925, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryContinuation() + public async Task QueryContinuation() { var code = @"using System.Linq; class C @@ -3982,12 +3983,12 @@ static void Main(string[] args) select w; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryContinuation2() + public async Task QueryContinuation2() { var code = @"using System.Linq; class C @@ -4007,13 +4008,13 @@ static void Main(string[] args) select x into } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542305, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void AttributeFormatting1() + public async Task AttributeFormatting1() { var code = @"class Program { @@ -4028,13 +4029,13 @@ void AddClass(string name, [OptionalAttribute] object position, [OptionalAttr { } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542304, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void CloseBracesInArgumentList() + public async Task CloseBracesInArgumentList() { var code = @"class Program { @@ -4063,13 +4064,13 @@ static void Main(string[] args) }, isThreadSafe: true); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542538, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void MissingTokens() + public async Task MissingTokens() { var code = @"using System; delegate void myDelegate(int name = 1); @@ -4091,25 +4092,25 @@ public innerClass() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542199, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void ColumnOfVeryFirstToken() + public async Task ColumnOfVeryFirstToken() { var code = @" W )b"; var expected = @" W )b"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542718, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void EmptySuppressionSpan() + public async Task EmptySuppressionSpan() { var code = @"enum E { @@ -4121,13 +4122,13 @@ public void EmptySuppressionSpan() a,, }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(542790, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void LabelInSwitch() + public async Task LabelInSwitch() { var code = @"class test { @@ -4163,13 +4164,13 @@ public static void Main() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(543112, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatArbitaryNode() + public async Task FormatArbitaryNode() { var expected = @"public int Prop { @@ -4204,7 +4205,7 @@ public void FormatArbitaryNode() Assert.NotNull(property); - var newProperty = Formatter.Format(property, new AdhocWorkspace()); + var newProperty = await Formatter.FormatAsync(property, new AdhocWorkspace()).ConfigureAwait(true); Assert.Equal(expected, newProperty.ToFullString()); } @@ -4212,7 +4213,7 @@ public void FormatArbitaryNode() [Fact] [WorkItem(543140, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void OmittedTypeArgument() + public async Task OmittedTypeArgument() { var code = @"using System; using System.Collections.Generic; @@ -4238,13 +4239,13 @@ static void Main(string[] args) } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(543131, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void TryAfterLabel() + public async Task TryAfterLabel() { var code = @"using System; class Program @@ -4278,12 +4279,12 @@ static int Main() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryContinuation1() + public async Task QueryContinuation1() { var code = @"using System.Linq; @@ -4317,12 +4318,12 @@ where final } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestCSharpFormattingSpacingOptions() + public async Task TestCSharpFormattingSpacingOptions() { var text = @" @@ -4385,12 +4386,12 @@ public string parfoobar(string[] str) } }"; - AssertFormat(expectedFormattedText, text); + await AssertFormatAsync(expectedFormattedText, text).ConfigureAwait(true); } [Fact] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpacingFixInTokenBasedForIfAndSwitchCase() + public async Task SpacingFixInTokenBasedForIfAndSwitchCase() { var code = @"class Class5{ void bar() @@ -4416,13 +4417,13 @@ void bar() } } }"; - AssertFormat(expectedCode, code); + await AssertFormatAsync(expectedCode, code).ConfigureAwait(true); } [Fact] [WorkItem(545335, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void PreprocessorOnSameLine() + public async Task PreprocessorOnSameLine() { var code = @"class C { @@ -4437,13 +4438,13 @@ public void PreprocessorOnSameLine() #line hidden"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(545626, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void ArraysInAttributes() + public async Task ArraysInAttributes() { var code = @"[A(X = new int[] { 1 })] public class A : Attribute @@ -4457,13 +4458,13 @@ public class A : Attribute public int[] X; }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(530580, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void NoNewLineAfterBraceInExpression() + public async Task NoNewLineAfterBraceInExpression() { var code = @"public class A { @@ -4485,13 +4486,13 @@ void Method() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(530580, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void NoIndentForNestedUsingWithoutBraces() + public async Task NoIndentForNestedUsingWithoutBraces() { var code = @"class C { @@ -4517,23 +4518,23 @@ void M() } "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(546678, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void UnicodeWhitespace() + public async Task UnicodeWhitespace() { var code = "\u001A"; - AssertFormat("", code); + await AssertFormatAsync("", code).ConfigureAwait(true); } [Fact] [WorkItem(17431, "DevDiv_Projects/Roslyn")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void NoElasticRuleOnRegularFile() + public async Task NoElasticRuleOnRegularFile() { var code = @"class Consumer { @@ -4549,13 +4550,13 @@ public int P } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(584599, "DevDiv_Projects/Roslyn")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void CaseSection() + public async Task CaseSection() { var code = @"class C { @@ -4595,13 +4596,13 @@ void Method() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(553654, "DevDiv_Projects/Roslyn")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_553654_LabelStatementIndenting() + public async Task Bugfix_553654_LabelStatementIndenting() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.LabelPositioning, LabelPositionOptions.LeftMost); @@ -4629,13 +4630,13 @@ void F() } } }"; - AssertFormat(expected, code, false, changingOptions); + await AssertFormatAsync(expected, code, false, changingOptions).ConfigureAwait(true); } [Fact] [WorkItem(707064, "DevDiv_Projects/Roslyn")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_707064_SpaceAfterSecondSemiColonInFor() + public async Task Bugfix_707064_SpaceAfterSecondSemiColonInFor() { var code = @"class Program { @@ -4656,13 +4657,13 @@ void F() } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(772313, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_772313_ReturnKeywordBeforeQueryClauseDoesNotTriggerNewLineOnFormat() + public async Task Bugfix_772313_ReturnKeywordBeforeQueryClauseDoesNotTriggerNewLineOnFormat() { var code = @"class C { @@ -4681,13 +4682,13 @@ int M() select c; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(772304, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_772313_PreserveMethodParameterIndentWhenAttributePresent() + public async Task Bugfix_772313_PreserveMethodParameterIndentWhenAttributePresent() { var code = @"class C { @@ -4744,29 +4745,29 @@ void M List b ); }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(776513, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_776513_CheckBraceIfNotMissingBeforeApplyingOperationForBracedBlocks() + public async Task Bugfix_776513_CheckBraceIfNotMissingBeforeApplyingOperationForBracedBlocks() { var code = @"var alwaysTriggerList = new[] Dim triggerOnlyWithLettersList ="; var expected = @"var alwaysTriggerList = new[] Dim triggerOnlyWithLettersList ="; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(769342, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ShouldFormatDocCommentWithIndentSameAsTabSizeWithUseTabTrue() + public async Task ShouldFormatDocCommentWithIndentSameAsTabSizeWithUseTabTrue() { var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(@"namespace ConsoleApplication1 + await AssertFormatAsync(@"namespace ConsoleApplication1 { /// /// fka;jsgdflkhsjflgkhdsl; @@ -4782,12 +4783,12 @@ class Program class Program { } -}", changedOptionSet: optionSet); +}", changedOptionSet: optionSet).ConfigureAwait(true); } [WorkItem(797278, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestSpacingOptionAroundControlFlow() + public async Task TestSpacingOptionAroundControlFlow() { const string code = @" class Program @@ -4874,11 +4875,11 @@ public void foo() } }"; var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceWithinOtherParentheses, true } }; - AssertFormat(expected, code, changedOptionSet: optionSet); + await AssertFormatAsync(expected, code, changedOptionSet: optionSet).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestSpacingOptionAfterControlFlowKeyword() + public async Task TestSpacingOptionAfterControlFlowKeyword() { var code = @" class Program @@ -4949,12 +4950,12 @@ public void foo() } }"; var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceAfterControlFlowStatementKeyword, false } }; - AssertFormat(expected, code, changedOptionSet: optionSet); + await AssertFormatAsync(expected, code, changedOptionSet: optionSet).ConfigureAwait(true); } [WorkItem(766212, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestOptionForSpacingAroundCommas() + public async Task TestOptionForSpacingAroundCommas() { var code = @" class Program @@ -4974,7 +4975,7 @@ public void Main() var digits = new List { 1, 2, 3, 4 }; } }"; - AssertFormat(expectedDefault, code); + await AssertFormatAsync(expectedDefault, code).ConfigureAwait(true); var expectedAfterCommaDisabled = @" class Program @@ -4986,7 +4987,7 @@ public void Main() } }"; var optionSet = new Dictionary { { CSharpFormattingOptions.SpaceAfterComma, false } }; - AssertFormat(expectedAfterCommaDisabled, code, changedOptionSet: optionSet); + await AssertFormatAsync(expectedAfterCommaDisabled, code, changedOptionSet: optionSet).ConfigureAwait(true); var expectedBeforeCommaEnabled = @" class Program @@ -4998,13 +4999,13 @@ public void Main() } }"; optionSet.Add(CSharpFormattingOptions.SpaceBeforeComma, true); - AssertFormat(expectedBeforeCommaEnabled, code, changedOptionSet: optionSet); + await AssertFormatAsync(expectedBeforeCommaEnabled, code, changedOptionSet: optionSet).ConfigureAwait(true); } [Fact] [WorkItem(772308, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void Bugfix_772308_SeparateSuppressionForEachCaseLabelEvenIfEmpty() + public async Task Bugfix_772308_SeparateSuppressionForEachCaseLabelEvenIfEmpty() { var code = @" class C @@ -5039,13 +5040,13 @@ int M() } } "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(844913, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void QueryExpressionInExpression() + public async Task QueryExpressionInExpression() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInMethods, false); @@ -5100,13 +5101,13 @@ public void CreateSettingsFile(string path, string comment) } } "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(843479, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void EmbeddedStatementElse() + public async Task EmbeddedStatementElse() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLineForElse, false); @@ -5135,13 +5136,13 @@ void Method() } } "; - AssertFormat(expected, code, false, changingOptions); + await AssertFormatAsync(expected, code, false, changingOptions).ConfigureAwait(true); } [Fact] [WorkItem(772311, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void CommentAtTheEndOfLine() + public async Task CommentAtTheEndOfLine() { var code = @" using System; @@ -5172,13 +5173,13 @@ static void Main(string[] args) } } "; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact] [WorkItem(772311, "DevDiv")] [Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestTab() + public async Task TestTab() { var code = @" using System; @@ -5244,12 +5245,12 @@ private void MenuItemCallback(object sender, EventArgs e) "; var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(expected, code, changedOptionSet: optionSet); - AssertFormat(expected, expected, changedOptionSet: optionSet); + await AssertFormatAsync(expected, code, changedOptionSet: optionSet).ConfigureAwait(true); + await AssertFormatAsync(expected, expected, changedOptionSet: optionSet).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void LeaveBlockSingleLine_False() + public async Task LeaveBlockSingleLine_False() { var code = @" namespace N { class C { int x; } }"; @@ -5264,11 +5265,11 @@ class C }"; var options = new Dictionary() { { CSharpFormattingOptions.WrappingPreserveSingleLine, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void LeaveBlockSingleLine_False2() + public async Task LeaveBlockSingleLine_False2() { var code = @" class C { void foo() { } }"; @@ -5282,11 +5283,11 @@ void foo() }"; var options = new Dictionary() { { CSharpFormattingOptions.WrappingPreserveSingleLine, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void LeaveStatementMethodDeclarationSameLine_False() + public async Task LeaveStatementMethodDeclarationSameLine_False() { var code = @" class Program @@ -5308,11 +5309,11 @@ void foo() }"; var options = new Dictionary() { { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0000() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0000() { var code = @" class Program @@ -5339,11 +5340,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0001() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0001() { var code = @" class Program @@ -5370,11 +5371,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0010() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0010() { var code = @" class Program @@ -5401,11 +5402,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0011() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0011() { var code = @" class Program @@ -5432,11 +5433,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0100() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0100() { var code = @" class Program @@ -5463,11 +5464,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0101() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0101() { var code = @" class Program @@ -5494,11 +5495,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0110() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0110() { var code = @" class Program @@ -5525,11 +5526,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0111() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_0111() { var code = @" class Program @@ -5556,11 +5557,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1000() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1000() { var code = @" class Program @@ -5587,11 +5588,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1001() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1001() { var code = @" class Program @@ -5618,11 +5619,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1010() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1010() { var code = @" class Program @@ -5649,11 +5650,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1011() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1011() { var code = @" class Program @@ -5680,11 +5681,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1100() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1100() { var code = @" class Program @@ -5711,11 +5712,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1101() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1101() { var code = @" class Program @@ -5742,11 +5743,11 @@ class Program { SpaceBeforeComma, false }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1110() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1110() { var code = @" class Program @@ -5773,11 +5774,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, false }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1111() + public async Task SpaceWithinEmptyBracketPrecedencesSpaceBeforeOrAfterComma_1111() { var code = @" class Program @@ -5804,11 +5805,11 @@ class Program { SpaceBeforeComma, true }, { SpaceAfterComma, true }, }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ArrayDeclarationShouldFollowEmptySquareBrackets() + public async Task ArrayDeclarationShouldFollowEmptySquareBrackets() { const string code = @" class Program @@ -5827,11 +5828,11 @@ class Program { CSharpFormattingOptions.SpaceWithinSquareBrackets, true }, { CSharpFormattingOptions.SpaceBetweenEmptySquareBrackets, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SquareBracesBefore_True() + public async Task SquareBracesBefore_True() { var code = @" class Program @@ -5846,11 +5847,11 @@ class Program }"; var options = new Dictionary() { { CSharpFormattingOptions.SpaceBeforeOpenSquareBracket, true } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SquareBracesAndValue_True() + public async Task SquareBracesAndValue_True() { var code = @" class Program @@ -5865,12 +5866,12 @@ class Program }"; var options = new Dictionary() { { CSharpFormattingOptions.SpaceWithinSquareBrackets, true } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [WorkItem(917351, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestLockStatement() + public async Task TestLockStatement() { var code = @" class Program @@ -5900,12 +5901,12 @@ public void Method() { CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [WorkItem(962416, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void TestCheckedAndUncheckedStatement() + public async Task TestCheckedAndUncheckedStatement() { var code = @" class Program @@ -5940,12 +5941,12 @@ public void Method() { CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false } }; - AssertFormat(expected, code, changedOptionSet: options); + await AssertFormatAsync(expected, code, changedOptionSet: options).ConfigureAwait(true); } [WorkItem(953535, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ConditionalMemberAccess() + public async Task ConditionalMemberAccess() { var code = @" using System; @@ -5983,12 +5984,12 @@ static void Main(string[] args) } }"; var parseOptions = new CSharpParseOptions(); - AssertFormat(expected, code, parseOptions: parseOptions); + await AssertFormatAsync(expected, code, parseOptions: parseOptions).ConfigureAwait(true); } [WorkItem(924172, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void IgnoreSpacesInDeclarationStatementEnabled() + public async Task IgnoreSpacesInDeclarationStatementEnabled() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.SpacesIgnoreAroundVariableDeclaration, true); @@ -6009,12 +6010,12 @@ static void Main(string[] args) int s; } }"; - AssertFormat(expected, code, changedOptionSet: changingOptions); + await AssertFormatAsync(expected, code, changedOptionSet: changingOptions).ConfigureAwait(true); } [WorkItem(899492, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void CommentIsLeadingTriviaOfStatementNotLabel() + public async Task CommentIsLeadingTriviaOfStatementNotLabel() { var code = @" class C @@ -6039,12 +6040,12 @@ void M() M(); } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(991547, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontWrappingTryCatchFinallyIfOnSingleLine() + public async Task DontWrappingTryCatchFinallyIfOnSingleLine() { var code = @" class C @@ -6067,11 +6068,11 @@ void M() finally { } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings1() + public async Task InterpolatedStrings1() { var code = @" class C @@ -6093,11 +6094,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings2() + public async Task InterpolatedStrings2() { var code = @" class C @@ -6121,11 +6122,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings3() + public async Task InterpolatedStrings3() { var code = @" class C @@ -6147,11 +6148,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings4() + public async Task InterpolatedStrings4() { var code = @" class C @@ -6175,11 +6176,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings5() + public async Task InterpolatedStrings5() { var code = @" class C @@ -6201,11 +6202,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings6() + public async Task InterpolatedStrings6() { var code = @" class C @@ -6229,11 +6230,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings7() + public async Task InterpolatedStrings7() { var code = @" class C @@ -6255,11 +6256,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings8() + public async Task InterpolatedStrings8() { var code = @" class C @@ -6283,11 +6284,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings9() + public async Task InterpolatedStrings9() { var code = @" class C @@ -6309,11 +6310,11 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void InterpolatedStrings10() + public async Task InterpolatedStrings10() { var code = @" class C @@ -6333,16 +6334,16 @@ void M() } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(1041787)] [WorkItem(1151, "https://github.com/dotnet/roslyn/issues/1151")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ReconstructWhitespaceStringUsingTabs_SingleLineComment() + public async Task ReconstructWhitespaceStringUsingTabs_SingleLineComment() { var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(@"using System; + await AssertFormatAsync(@"using System; class Program { @@ -6358,17 +6359,17 @@ static void Main(string[] args) { Console.WriteLine(""""); // FooBar } -}", false, optionSet); +}", false, optionSet).ConfigureAwait(true); } [WorkItem(961559)] [WorkItem(1041787)] [WorkItem(1151, "https://github.com/dotnet/roslyn/issues/1151")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void ReconstructWhitespaceStringUsingTabs_MultiLineComment() + public async Task ReconstructWhitespaceStringUsingTabs_MultiLineComment() { var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(@"using System; + await AssertFormatAsync(@"using System; class Program { @@ -6384,14 +6385,14 @@ static void Main(string[] args) { Console.WriteLine(""""); /* FooBar */ } -}", false, optionSet); +}", false, optionSet).ConfigureAwait(true); } [WorkItem(1100920)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NoLineOperationAroundInterpolationSyntax() + public async Task NoLineOperationAroundInterpolationSyntax() { - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static string F(int a, int b, int c) { @@ -6403,12 +6404,12 @@ static string F(int a, int b, int c) { return $""{a} (index: 0x{ b}, size: { c}): "" } -}"); +}").ConfigureAwait(true); } [WorkItem(62)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpaceAfterWhenInExceptionFilter() + public async Task SpaceAfterWhenInExceptionFilter() { const string expected = @"class C { @@ -6444,13 +6445,13 @@ void M() } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(285)] [WorkItem(1089196)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatHashInBadDirectiveToZeroColumnAnywhereInsideIfDef() + public async Task FormatHashInBadDirectiveToZeroColumnAnywhereInsideIfDef() { const string code = @"class MyClass { @@ -6475,13 +6476,13 @@ static void Main(string[] args) #endif } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(285)] [WorkItem(1089196)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatHashElseToZeroColumnAnywhereInsideIfDef() + public async Task FormatHashElseToZeroColumnAnywhereInsideIfDef() { const string code = @"class MyClass { @@ -6506,13 +6507,13 @@ static void Main(string[] args) #endif } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(285)] [WorkItem(1089196)] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatHashsToZeroColumnAnywhereInsideIfDef() + public async Task FormatHashsToZeroColumnAnywhereInsideIfDef() { const string code = @"class MyClass { @@ -6539,26 +6540,26 @@ static void Main(string[] args) #endif } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(1118, "https://github.com/dotnet/roslyn/issues/1118")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontAssumeCertainNodeAreAlwaysParented() + public async Task DontAssumeCertainNodeAreAlwaysParented() { var block = SyntaxFactory.Block(); - Formatter.Format(block, new AdhocWorkspace()); + await Formatter.FormatAsync(block, new AdhocWorkspace()).ConfigureAwait(true); } [WorkItem(776, "https://github.com/dotnet/roslyn/issues/776")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpacingRulesAroundMethodCallAndParenthesisAppliedInAttributeNonDefault() + public async Task SpacingRulesAroundMethodCallAndParenthesisAppliedInAttributeNonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.SpaceAfterMethodCallName, true); changingOptions.Add(CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, true); changingOptions.Add(CSharpFormattingOptions.SpaceWithinMethodCallParentheses, true); - AssertFormat(@"[Obsolete ( ""Test"" ), Obsolete ( )] + await AssertFormatAsync(@"[Obsolete ( ""Test"" ), Obsolete ( )] class Program { static void Main(string[] args) @@ -6570,12 +6571,12 @@ class Program static void Main(string[] args) { } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [WorkItem(776, "https://github.com/dotnet/roslyn/issues/776")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpacingRulesAroundMethodCallAndParenthesisAppliedInAttribute() + public async Task SpacingRulesAroundMethodCallAndParenthesisAppliedInAttribute() { var code = @"[Obsolete(""Test""), Obsolete()] class Program @@ -6584,11 +6585,11 @@ static void Main(string[] args) { } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact] - public void SpacingInMethodCallArguments_True() + public async Task SpacingInMethodCallArguments_True() { const string code = @" [Bar(A=1,B=2)] @@ -6622,12 +6623,12 @@ public void foo() { CSharpFormattingOptions.SpaceAfterMethodCallName, true }, { CSharpFormattingOptions.SpaceBetweenEmptyMethodCallParentheses, true }, }; - AssertFormat(expected, code, changedOptionSet: optionSet); + await AssertFormatAsync(expected, code, changedOptionSet: optionSet).ConfigureAwait(true); } [WorkItem(1298, "https://github.com/dotnet/roslyn/issues/1298")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontforceAccessorsToNewLineWithPropertyInitializers() + public async Task DontforceAccessorsToNewLineWithPropertyInitializers() { var code = @"using System.Collections.Generic; @@ -6652,12 +6653,12 @@ class Program public class ExcludeValidation { }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(1339, "https://github.com/dotnet/roslyn/issues/1339")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontFormatAutoPropertyInitializerIfNotDifferentLine() + public async Task DontFormatAutoPropertyInitializerIfNotDifferentLine() { var code = @"class Program { @@ -6667,11 +6668,11 @@ static void Main(string[] args) { } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SpacingForForStatementInfiniteLoop() + public async Task SpacingForForStatementInfiniteLoop() { var code = @" class Program @@ -6693,13 +6694,13 @@ void Main() } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(4421, "https://github.com/dotnet/roslyn/issues/4421")] [WorkItem(4240, "https://github.com/dotnet/roslyn/issues/4240")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void VerifySpacingAfterMethodDeclarationName_Default() + public async Task VerifySpacingAfterMethodDeclarationName_Default() { var code = @"class Program { @@ -6715,13 +6716,13 @@ public void VerifySpacingAfterMethodDeclarationName_Default() public static void M() { } public void F() { } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(4240, "https://github.com/dotnet/roslyn/issues/4240")] [WorkItem(4421, "https://github.com/dotnet/roslyn/issues/4421")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void VerifySpacingAfterMethodDeclarationName_NonDefault() + public async Task VerifySpacingAfterMethodDeclarationName_NonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.SpacingAfterMethodDeclarationName, true); @@ -6739,12 +6740,12 @@ public void VerifySpacingAfterMethodDeclarationName_NonDefault() public static void M () { } public void F () { } }"; - AssertFormat(expected, code, changedOptionSet: changingOptions); + await AssertFormatAsync(expected, code, changedOptionSet: changingOptions).ConfigureAwait(true); } [WorkItem(939, "https://github.com/dotnet/roslyn/issues/939")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DontFormatInsideArrayInitializers() + public async Task DontFormatInsideArrayInitializers() { var code = @"class Program { @@ -6767,13 +6768,13 @@ static void Main(string[] args) }; } }"; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [WorkItem(1184285)] [WorkItem(4280, "https://github.com/dotnet/roslyn/issues/4280")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatDictionaryInitializers() + public async Task FormatDictionaryInitializers() { var code = @"class Program { @@ -6789,12 +6790,12 @@ void Main() var sample = new Dictionary { [""x""] = ""d"", [""z""] = ""XX"" }; } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(3256, "https://github.com/dotnet/roslyn/issues/3256")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SwitchSectionHonorsNewLineForBracesinControlBlockOption_Default() + public async Task SwitchSectionHonorsNewLineForBracesinControlBlockOption_Default() { var code = @"class Program { @@ -6824,12 +6825,12 @@ public void foo() } } }"; - AssertFormat(expected, code); + await AssertFormatAsync(expected, code).ConfigureAwait(true); } [WorkItem(3256, "https://github.com/dotnet/roslyn/issues/3256")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void SwitchSectionHonorsNewLineForBracesinControlBlockOption_NonDefault() + public async Task SwitchSectionHonorsNewLineForBracesinControlBlockOption_NonDefault() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInControlBlocks, false); @@ -6862,16 +6863,16 @@ public void foo() } } }"; - AssertFormat(expected, code, changedOptionSet: changingOptions); + await AssertFormatAsync(expected, code, changedOptionSet: changingOptions).ConfigureAwait(true); } [WorkItem(4014, "https://github.com/dotnet/roslyn/issues/4014")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormattingCodeWithMissingTokensShouldRespectFormatTabsOption1() + public async Task FormattingCodeWithMissingTokensShouldRespectFormatTabsOption1() { var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(@"class Program + await AssertFormatAsync(@"class Program { static void Main() { @@ -6883,16 +6884,16 @@ static void Main() { return // Note the missing semicolon } // The tab here should stay a tab -}", changedOptionSet: optionSet); +}", changedOptionSet: optionSet).ConfigureAwait(true); } [WorkItem(4014, "https://github.com/dotnet/roslyn/issues/4014")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormattingCodeWithMissingTokensShouldRespectFormatTabsOption2() + public async Task FormattingCodeWithMissingTokensShouldRespectFormatTabsOption2() { var optionSet = new Dictionary { { new OptionKey(FormattingOptions.UseTabs, LanguageNames.CSharp), true } }; - AssertFormat(@"struct Foo + await AssertFormatAsync(@"struct Foo { private readonly string bar; @@ -6906,17 +6907,17 @@ public Foo(readonly string bar) public Foo(readonly string bar) { } -}", changedOptionSet: optionSet); +}", changedOptionSet: optionSet).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(84, "https://github.com/dotnet/roslyn/issues/84")] [WorkItem(849870, "DevDiv")] - public void NewLinesForBracesInPropertiesTest() + public async Task NewLinesForBracesInPropertiesTest() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInProperties, false); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { int Foo { get @@ -6943,17 +6944,17 @@ int MethodFoo() { return 42; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(849870, "DevDiv")] [WorkItem(84, "https://github.com/dotnet/roslyn/issues/84")] - public void NewLinesForBracesInAccessorsTest() + public async Task NewLinesForBracesInAccessorsTest() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInAccessors, false); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { int Foo { @@ -6980,18 +6981,18 @@ int MethodFoo() { return 42; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(849870, "DevDiv")] [WorkItem(84, "https://github.com/dotnet/roslyn/issues/84")] - public void NewLinesForBracesInPropertiesAndAccessorsTest() + public async Task NewLinesForBracesInPropertiesAndAccessorsTest() { var changingOptions = new Dictionary(); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInProperties, false); changingOptions.Add(CSharpFormattingOptions.NewLinesForBracesInAccessors, false); - AssertFormat(@"class Class2 + await AssertFormatAsync(@"class Class2 { int Foo { get { @@ -7017,12 +7018,12 @@ int MethodFoo() { return 42; } -}", false, changingOptions); +}", false, changingOptions).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(111079, "devdiv.visualstudio.com")] - public void TestThrowInIfOnSingleLine() + public async Task TestThrowInIfOnSingleLine() { var code = @" class C @@ -7035,12 +7036,12 @@ void M() } "; - AssertFormat(code, code); + await AssertFormatAsync(code, code).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(1711675, "https://connect.microsoft.com/VisualStudio/feedback/details/1711675/autoformatting-issues")] - public void SingleLinePropertiesPreservedWithLeaveStatementsAndMembersOnSingleLineFalse() + public async Task SingleLinePropertiesPreservedWithLeaveStatementsAndMembersOnSingleLineFalse() { var changedOptionSet = new Dictionary { @@ -7048,7 +7049,7 @@ public void SingleLinePropertiesPreservedWithLeaveStatementsAndMembersOnSingleLi { CSharpFormattingOptions.WrappingKeepStatementsOnSingleLine, false}, }; - AssertFormat(@" + await AssertFormatAsync(@" class C { string Name { get; set; } @@ -7056,14 +7057,14 @@ class C class C { string Name { get ; set ; } -}", changedOptionSet: changedOptionSet); +}", changedOptionSet: changedOptionSet).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(4720, "https://github.com/dotnet/roslyn/issues/4720")] - public void KeepAccessorWithAttributeOnSingleLine() + public async Task KeepAccessorWithAttributeOnSingleLine() { - AssertFormat(@" + await AssertFormatAsync(@" class Program { public Int32 PaymentMethodID @@ -7079,14 +7080,14 @@ public Int32 PaymentMethodID [System.Diagnostics.DebuggerStepThrough] get { return 10; } } -}"); +}").ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] [WorkItem(4720, "https://github.com/dotnet/roslyn/issues/4720")] - public void OneSpaceBetweenAccessorsAndAttributes() + public async Task OneSpaceBetweenAccessorsAndAttributes() { - AssertFormat(@" + await AssertFormatAsync(@" class Program { public int SomeProperty { [SomeAttribute] get; [SomeAttribute] private set; } @@ -7094,7 +7095,7 @@ class Program class Program { public int SomeProperty { [SomeAttribute] get; [SomeAttribute] private set; } -}"); +}").ConfigureAwait(true); } } } diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingTriviaTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingTriviaTests.cs index e26cfc8d5a3f1aeb1d21f216b14fb0f70c0d5fb9..afae5b7107e4d021e1a4eba4a823a160cba54762 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingTriviaTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingTriviaTests.cs @@ -5,13 +5,14 @@ using Microsoft.CodeAnalysis.Formatting; using Roslyn.Test.Utilities; using Xunit; +using System.Threading.Tasks; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Formatting { public class FormattingEngineTriviaTests : CSharpFormattingTestBase { [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void PreprocessorInEmptyFile() + public async Task PreprocessorInEmptyFile() { var content = @" @@ -25,11 +26,11 @@ public void PreprocessorInEmptyFile() #error "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment1() + public async Task Comment1() { var content = @" // single line comment class C { }"; @@ -37,11 +38,11 @@ class C { }"; var expected = @"// single line comment class C { }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment2() + public async Task Comment2() { var content = @"class C { @@ -55,11 +56,11 @@ public void Comment2() int i; }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment3() + public async Task Comment3() { var content = @"class C { @@ -71,11 +72,11 @@ public void Comment3() // single line comment }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment4() + public async Task Comment4() { var content = @"class C { @@ -91,11 +92,11 @@ public void Comment4() void Method() { } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment5() + public async Task Comment5() { var content = @"class C { @@ -114,11 +115,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment6() + public async Task Comment6() { var content = @"class C { @@ -139,11 +140,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment7() + public async Task Comment7() { var content = @"class C { @@ -168,11 +169,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment8() + public async Task Comment8() { var content = @"class C { @@ -193,11 +194,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment9() + public async Task Comment9() { var content = @"class C { @@ -218,11 +219,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment10() + public async Task Comment10() { var content = @"class C { @@ -245,11 +246,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment11() + public async Task Comment11() { var content = @"class C { @@ -282,11 +283,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment12() + public async Task Comment12() { var content = @"class C { @@ -319,11 +320,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment13() + public async Task Comment13() { var content = @"class C { @@ -340,11 +341,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment14() + public async Task Comment14() { var content = @"class C { @@ -365,11 +366,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment15() + public async Task Comment15() { var content = @"class C { @@ -386,11 +387,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment16() + public async Task Comment16() { var content = @"class C { @@ -411,11 +412,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment17() + public async Task Comment17() { var content = @"class C { @@ -438,11 +439,11 @@ void Method() } }"; - AssertFormat(expected, content, true); + await AssertFormatAsync(expected, content, true).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment18() + public async Task Comment18() { var content = @"class C { @@ -467,11 +468,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment19() + public async Task Comment19() { var content = @"class C { @@ -498,11 +499,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment20() + public async Task Comment20() { var content = @"class C { @@ -529,13 +530,13 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } // for now, formatting engine doesn't re-indent token if the indentation line contains noisy // chars [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment21() + public async Task Comment21() { var content = @"class C { @@ -553,13 +554,13 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } // for now, formatting engine doesn't re-indent token if the indentation line contains noisy // chars [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment22() + public async Task Comment22() { var content = @"class C { @@ -578,11 +579,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment23() + public async Task Comment23() { var content = @"class C { @@ -599,11 +600,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment24() + public async Task Comment24() { var content = @"class C { @@ -623,11 +624,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment1() + public async Task DocComment1() { var content = @"class C { @@ -648,11 +649,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment2() + public async Task DocComment2() { var content = @"class C { @@ -671,11 +672,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment3() + public async Task DocComment3() { var content = @"class C { @@ -696,11 +697,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment4() + public async Task DocComment4() { var content = @"class C { @@ -719,11 +720,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment5() + public async Task DocComment5() { var content = @"class C { @@ -740,11 +741,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment6() + public async Task DocComment6() { var content = @"class C { @@ -763,11 +764,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment7() + public async Task DocComment7() { var content = @"class C { @@ -786,11 +787,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment8() + public async Task DocComment8() { var content = @"class C { @@ -811,11 +812,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment9() + public async Task DocComment9() { var content = @"class C { @@ -836,11 +837,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment10() + public async Task DocComment10() { var content = @"class C { @@ -865,11 +866,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment11() + public async Task DocComment11() { var content = @"class C { @@ -896,11 +897,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void DocComment12() + public async Task DocComment12() { var content = @"class C { @@ -923,11 +924,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MixCommentAndDocComment1() + public async Task MixCommentAndDocComment1() { var content = @"class C { @@ -952,11 +953,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MixCommentAndDocComment2() + public async Task MixCommentAndDocComment2() { var content = @"class C { @@ -989,11 +990,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MixCommentAndDocComment3() + public async Task MixCommentAndDocComment3() { var content = @"class C { @@ -1024,11 +1025,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MixCommentAndDocComment4() + public async Task MixCommentAndDocComment4() { var content = @"class C { @@ -1057,11 +1058,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor1() + public async Task Preprocessor1() { var content = @"class C { @@ -1082,11 +1083,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor2() + public async Task Preprocessor2() { var content = @"class C { @@ -1109,11 +1110,11 @@ void Method() #endif "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor3() + public async Task Preprocessor3() { var content = @"class C { @@ -1140,11 +1141,11 @@ void Method() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor4() + public async Task Preprocessor4() { var content = @"class C { @@ -1172,11 +1173,11 @@ void Method() "; // turn off transformation check - conditional directive preprocessor - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor5() + public async Task Preprocessor5() { var content = @"class C { @@ -1201,11 +1202,11 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor6() + public async Task Preprocessor6() { var content = @"class C { @@ -1230,11 +1231,11 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor7() + public async Task Preprocessor7() { var content = @"class C { @@ -1259,11 +1260,11 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor8() + public async Task Preprocessor8() { var content = @"class C { @@ -1290,11 +1291,11 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void MixAll() + public async Task MixAll() { var content = @"class C { @@ -1335,12 +1336,12 @@ public void MixAll() "; // turn off transformation check since it doesn't work for conditional directive yet. - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [WorkItem(537895, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor9() + public async Task Preprocessor9() { var content = @"class C { @@ -1367,12 +1368,12 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [WorkItem(537895, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Preprocessor10() + public async Task Preprocessor10() { var content = @"class C { @@ -1397,12 +1398,12 @@ void Method() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [WorkItem(537765, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment25() + public async Task Comment25() { var content = @"class C { @@ -1424,12 +1425,12 @@ public void Comment25() } "; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [WorkItem(537765, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment26() + public async Task Comment26() { var content = @"public class Class1 { @@ -1448,11 +1449,11 @@ void Foo() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment27() + public async Task Comment27() { var content = @"public class Class1 { @@ -1463,11 +1464,11 @@ void Foo() } }"; - AssertFormat(content, content); + await AssertFormatAsync(content, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment28() + public async Task Comment28() { var content = @"public class Class1 { @@ -1490,11 +1491,11 @@ void Foo() } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment29() + public async Task Comment29() { var content = @"public class Class1 { @@ -1512,11 +1513,11 @@ void Foo() } }"; - AssertFormat(code, content); + await AssertFormatAsync(code, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment30() + public async Task Comment30() { var content = @" // Test"; @@ -1524,11 +1525,11 @@ public void Comment30() var code = @" // Test"; - AssertFormat(code, content); + await AssertFormatAsync(code, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment31() + public async Task Comment31() { var content = @"/// /// @@ -1552,12 +1553,12 @@ static void Main(string[] args) } "; - AssertFormat(code, content); + await AssertFormatAsync(code, content).ConfigureAwait(true); } [WorkItem(538703, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void Comment32() + public async Task Comment32() { var content = @"class Program { @@ -1577,12 +1578,12 @@ public void Comment32() } "; - AssertFormat(code, content); + await AssertFormatAsync(code, content).ConfigureAwait(true); } [WorkItem(542316, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void CommentInExpression() + public async Task CommentInExpression() { var content = @"using System; using System.Collections.Generic; @@ -1614,29 +1615,29 @@ static void Main(string[] args) } "; - AssertFormat(code, content); + await AssertFormatAsync(code, content).ConfigureAwait(true); } [WorkItem(542546, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatInvalidCode_1() + public async Task FormatInvalidCode_1() { var content = @"> Roslyn.Utilities.dll! Basic"; - AssertFormat(content, content); + await AssertFormatAsync(content, content).ConfigureAwait(true); } [WorkItem(542546, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatInvalidCode_2() + public async Task FormatInvalidCode_2() { var content = @"> Roslyn.Utilities.dll! Line 43 + 0x5 bytes Basic"; var expectedContent = @"> Roslyn.Utilities.dll! Line 43 + 0x5 bytes Basic"; - AssertFormat(expectedContent, content); + await AssertFormatAsync(expectedContent, content).ConfigureAwait(true); } [WorkItem(537895, "DevDiv")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void EmbededStatement1() + public async Task EmbededStatement1() { var content = @"using System; using System.Collections.Generic; @@ -1668,11 +1669,11 @@ static void Main(string[] args) #endregion } }"; - AssertFormat(expectedContent, content); + await AssertFormatAsync(expectedContent, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void RefKeywords() + public async Task RefKeywords() { var content = @"class C { @@ -1702,18 +1703,18 @@ static void Main(string[] args) } }"; - AssertFormat(expected, content); + await AssertFormatAsync(expected, content).ConfigureAwait(true); } [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void NewLineOptions_LineFeedOnly() + public async Task NewLineOptions_LineFeedOnly() { var tree = SyntaxFactory.ParseCompilationUnit("class C\r\n{\r\n}"); // replace all EOL trivia with elastic markers to force the formatter to add EOL back tree = tree.ReplaceTrivia(tree.DescendantTrivia().Where(tr => tr.IsKind(SyntaxKind.EndOfLineTrivia)), (o, r) => SyntaxFactory.ElasticMarker); - var formatted = Formatter.Format(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.CSharp, "\n")); + var formatted = await Formatter.FormatAsync(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.CSharp, "\n")).ConfigureAwait(true); var actual = formatted.ToFullString(); var expected = "class C\n{\n}"; @@ -1723,7 +1724,7 @@ public void NewLineOptions_LineFeedOnly() [WorkItem(4019, "https://github.com/dotnet/roslyn/issues/4019")] [Fact, Trait(Traits.Feature, Traits.Features.Formatting)] - public void FormatWithTabs() + public async Task FormatWithTabs() { var code = @"#region Assembly mscorlib @@ -1755,7 +1756,7 @@ class F .WithLeadingTrivia(SyntaxFactory.TriviaList()) .WithAdditionalAnnotations(SyntaxAnnotation.ElasticAnnotation)); - var formatted = Formatter.Format(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.UseTabs, LanguageNames.CSharp, true)); + var formatted = await Formatter.FormatAsync(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.UseTabs, LanguageNames.CSharp, true)).ConfigureAwait(true); var actual = formatted.ToFullString(); Assert.Equal(expected, actual); diff --git a/src/Workspaces/Core/Portable/Formatting/Formatter.cs b/src/Workspaces/Core/Portable/Formatting/Formatter.cs index 2269da60ce3f76f0cc77db9ec5887a1c29cfc801..9bf95ce76d9e0d3e7a355da3fbc1df3c59386e04 100644 --- a/src/Workspaces/Core/Portable/Formatting/Formatter.cs +++ b/src/Workspaces/Core/Portable/Formatting/Formatter.cs @@ -162,7 +162,7 @@ internal static async Task FormatAsync(Document document, SyntaxAnnota } var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - return document.WithSyntaxRoot(Format(root, annotation, document.Project.Solution.Workspace, options, rules, cancellationToken)); + return document.WithSyntaxRoot(await FormatAsync(root, annotation, document.Project.Solution.Workspace, options, rules, cancellationToken).ConfigureAwait(false)); } /// @@ -176,10 +176,15 @@ internal static async Task FormatAsync(Document document, SyntaxAnnota /// The formatted tree's root node. public static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) { - return Format(node, annotation, workspace, options, rules: null, cancellationToken: cancellationToken); + return FormatAsync(node, annotation, workspace, options, cancellationToken).WaitAndGetResult(cancellationToken); } - internal static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet options, IEnumerable rules, CancellationToken cancellationToken) + internal static Task FormatAsync(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return FormatAsync(node, annotation, workspace, options, rules: null, cancellationToken: cancellationToken); + } + + internal static Task FormatAsync(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet options, IEnumerable rules, CancellationToken cancellationToken) { if (workspace == null) { @@ -200,7 +205,7 @@ internal static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, ? GetElasticSpans(node) : GetAnnotatedSpans(node, annotation); - return Format(node, spans, workspace, options, rules, cancellationToken); + return FormatAsync(node, spans, workspace, options, rules, cancellationToken); } /// @@ -294,7 +299,12 @@ internal static async Task FormatAsync(SyntaxNode node, IEnumerable< /// The changes necessary to format the tree. public static IList GetFormattedTextChanges(SyntaxNode node, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetFormattedTextChanges(node, SpecializedCollections.SingletonEnumerable(node.FullSpan), workspace, options, rules: null, cancellationToken: cancellationToken); + return GetFormattedTextChangesAsync(node, workspace, options, cancellationToken).WaitAndGetResult(cancellationToken); + } + + internal static Task> GetFormattedTextChangesAsync(SyntaxNode node, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetFormattedTextChangesAsync(node, SpecializedCollections.SingletonEnumerable(node.FullSpan), workspace, options, rules: null, cancellationToken: cancellationToken); } /// @@ -308,7 +318,12 @@ public static IList GetFormattedTextChanges(SyntaxNode node, Workspa /// The changes necessary to format the tree. public static IList GetFormattedTextChanges(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetFormattedTextChanges(node, SpecializedCollections.SingletonEnumerable(span), workspace, options, rules: null, cancellationToken: cancellationToken); + return GetFormattedTextChangesAsync(node, span, workspace, options, cancellationToken).WaitAndGetResult(cancellationToken); + } + + internal static Task> GetFormattedTextChangesAsync(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetFormattedTextChangesAsync(node, SpecializedCollections.SingletonEnumerable(span), workspace, options, rules: null, cancellationToken: cancellationToken); } /// @@ -322,7 +337,12 @@ public static IList GetFormattedTextChanges(SyntaxNode node, TextSpa /// The changes necessary to format the tree. public static IList GetFormattedTextChanges(SyntaxNode node, IEnumerable spans, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) { - return GetFormattedTextChanges(node, spans, workspace, options, rules: null, cancellationToken: cancellationToken); + return GetFormattedTextChangesAsync(node, spans, workspace, options, cancellationToken).WaitAndGetResult(cancellationToken); + } + + internal static Task> GetFormattedTextChangesAsync(SyntaxNode node, IEnumerable spans, Workspace workspace, OptionSet options = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return GetFormattedTextChangesAsync(node, spans, workspace, options, rules: null, cancellationToken: cancellationToken); } internal static IList GetFormattedTextChanges(SyntaxNode node, IEnumerable spans, Workspace workspace, OptionSet options, IEnumerable rules, CancellationToken cancellationToken) diff --git a/src/Workspaces/CoreTest/Formatting/FormattingTestBase.cs b/src/Workspaces/CoreTest/Formatting/FormattingTestBase.cs index 21cd662e95f33d0d530b72cf5144b25857289010..5ee02dc19f576d859155499da4ce257a73b38ed9 100644 --- a/src/Workspaces/CoreTest/Formatting/FormattingTestBase.cs +++ b/src/Workspaces/CoreTest/Formatting/FormattingTestBase.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; @@ -12,7 +13,7 @@ namespace Microsoft.CodeAnalysis.UnitTests.Formatting { public abstract class FormattingTestBase { - protected void AssertFormat( + protected Task AssertFormatAsync( string expected, string code, string language, @@ -20,10 +21,10 @@ public abstract class FormattingTestBase Dictionary changedOptionSet = null, bool testWithTransformation = true) { - AssertFormat(expected, code, SpecializedCollections.SingletonEnumerable(new TextSpan(0, code.Length)), language, debugMode, changedOptionSet, testWithTransformation); + return AssertFormatAsync(expected, code, SpecializedCollections.SingletonEnumerable(new TextSpan(0, code.Length)), language, debugMode, changedOptionSet, testWithTransformation); } - protected void AssertFormat( + protected async Task AssertFormatAsync( string expected, string code, IEnumerable spans, @@ -55,7 +56,7 @@ public abstract class FormattingTestBase } var root = syntaxTree.GetRoot(); - AssertFormat(workspace, expected, root, spans, options, document.GetTextAsync().Result); + await AssertFormatAsync(workspace, expected, root, spans, options, await document.GetTextAsync().ConfigureAwait(true)).ConfigureAwait(true); // format with node and transform AssertFormatWithTransformation(workspace, expected, root, spans, options, treeCompare, parseOptions); @@ -81,9 +82,9 @@ public abstract class FormattingTestBase } } - protected static void AssertFormat(Workspace workspace, string expected, SyntaxNode root, IEnumerable spans, OptionSet optionSet, SourceText sourceText) + protected static async Task AssertFormatAsync(Workspace workspace, string expected, SyntaxNode root, IEnumerable spans, OptionSet optionSet, SourceText sourceText) { - var result = Formatter.GetFormattedTextChanges(root, spans, workspace, optionSet); + var result = await Formatter.GetFormattedTextChangesAsync(root, spans, workspace, optionSet).ConfigureAwait(true); AssertResult(expected, sourceText, result); } diff --git a/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb b/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb index f1ba70a49decff6d1840909916c61c4fb69cea3f..1844d7fa925328d700689bdb1bf88167dd56bbb3 100644 --- a/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb +++ b/src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb @@ -14,7 +14,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Inherits VisualBasicFormattingTestBase - Public Sub Format1() + Public Async Function Format1() As Task Dim code = Namespace A End Namespace @@ -23,11 +23,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Namespace A End Namespace - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub NamespaceBlock() + Public Async Function NamespaceBlock() As Task Dim code = Namespace A Class C End Class @@ -38,11 +38,11 @@ End Namespace End Class End Namespace - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TypeBlock() + Public Async Function TypeBlock() As Task Dim code = Class C Sub Method ( ) End Sub @@ -55,11 +55,11 @@ End Namespace End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub MethodBlock() + Public Async Function MethodBlock() As Task Dim code = Class C Sub Method ( ) Dim a As Integer = 1 @@ -74,11 +74,11 @@ Dim a As Integer = 1 End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub StructBlock() + Public Async Function StructBlock() As Task Dim code = Structure C Sub Method ( ) Dim a As Integer = 1 @@ -97,11 +97,11 @@ Dim a As Integer = 1 End Structure - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub EnumBlock() + Public Async Function EnumBlock() As Task Dim code = Enum C A B @@ -116,11 +116,11 @@ A Z End Enum - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ModuleBlock() + Public Async Function ModuleBlock() As Task Dim code = Module module1 Sub foo() End Sub @@ -131,11 +131,11 @@ Sub foo() End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterfaceBlock() + Public Async Function InterfaceBlock() As Task Dim code = Interface IFoo Sub foo() End Interface @@ -146,11 +146,11 @@ End Module End Interface - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub PropertyBlock() + Public Async Function PropertyBlock() As Task Dim code = Class C Property P ( ) As Integer Get @@ -171,11 +171,11 @@ End Set End Property End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub EventBlock() + Public Async Function EventBlock() As Task Dim code = Class C Public Custom Event MouseDown As EventHandler AddHandler ( ByVal Value As EventHandler ) @@ -204,11 +204,11 @@ End Event End Event End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhileBlockNode() + Public Async Function WhileBlockNode() As Task Dim code = Class C Sub Method ( ) While True @@ -225,11 +225,11 @@ While True End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub UsingBlockNode() + Public Async Function UsingBlockNode() As Task Dim code = Class C Sub Method() Using TraceSource @@ -246,17 +246,17 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub SyncLockBlockNode() + Public Async Function SyncLockBlockNode() As Task Dim code = Class C Sub Method() SyncLock New Object Dim i = 10 End SyncLock - End Sub + End Function End Class Dim expected = Class C @@ -267,11 +267,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WithBlockNode() + Public Async Function WithBlockNode() As Task Dim code = Class C Sub Method() With New Object @@ -288,11 +288,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub IfBlockNode() + Public Async Function IfBlockNode() As Task Dim code = Class C Sub Method() If True Then @@ -317,11 +317,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TryCatchBlockNode() + Public Async Function TryCatchBlockNode() As Task Dim code = Class C Sub Method() Try @@ -356,11 +356,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub SelectBlockNode() + Public Async Function SelectBlockNode() As Task Dim code = Class C Sub Method() Dim i = 1 @@ -391,11 +391,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub DoLoopBlockNode() + Public Async Function DoLoopBlockNode() As Task Dim code = Class C Sub Method() Do @@ -412,11 +412,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub DoUntilBlockNode() + Public Async Function DoUntilBlockNode() As Task Dim code = Class C Sub Method() Do Until False @@ -433,17 +433,17 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ForBlockNode() + Public Async Function ForBlockNode() As Task Dim code = Class C Sub Method() For i = 1 To 10 Step 1 Dim a = 1 Next - End Sub + End Function End Class Dim expected = Class C @@ -454,11 +454,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub AnchorStatement() + Public Async Function AnchorStatement() As Task Dim code = Imports System Imports System. Collections. @@ -469,11 +469,11 @@ Imports System. Collections. Generic - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub AnchorQueryStatement() + Public Async Function AnchorQueryStatement() As Task Dim code = Class C Sub Method() Dim a = From q In @@ -492,11 +492,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub AlignQueryStatement() + Public Async Function AlignQueryStatement() As Task Dim code = Class C Sub Method() Dim a = From q In {1, 3, 5} @@ -513,11 +513,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Operators1() + Public Async Function Operators1() As Task Dim code = Class C Sub Method() Dim a = - 1 @@ -542,11 +542,11 @@ End Class End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Operators2() + Public Async Function Operators2() As Task Dim code = Class C Sub Method() Dim myStr As String @@ -561,11 +561,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Operators3() + Public Async Function Operators3() As Task Dim code = Class C Sub Method() Dim a1 = 1 <= 2 @@ -608,11 +608,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Punctuation() + Public Async Function Punctuation() As Task Dim code = < Fact ( ) , Trait ( Traits . Feature , Traits . Features . Formatting ) > Class A End Class @@ -621,11 +621,11 @@ End Class Class A End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Punctuation2() + Public Async Function Punctuation2() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Method(i := 1) @@ -638,11 +638,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Punctuation3() + Public Async Function Punctuation3() As Task Dim code = Sub Method() @@ -655,11 +655,11 @@ End Class]]> End Sub End Class]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Lambda1() + Public Async Function Lambda1() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim q = Function ( t ) 1 @@ -674,11 +674,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Lambda2() + Public Async Function Lambda2() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim q = Function ( t ) @@ -703,11 +703,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Lambda3() + Public Async Function Lambda3() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim q = @@ -736,11 +736,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Lambda4() + Public Async Function Lambda4() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim q = @@ -775,11 +775,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub LineContinuation1() + Public Async Function LineContinuation1() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim a = 1 + _ @@ -796,11 +796,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub LineContinuation2() + Public Async Function LineContinuation2() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim aa = 1 + _ @@ -817,11 +817,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub LineContinuation3() + Public Async Function LineContinuation3() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim aa = 1 + _ @@ -838,11 +838,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub LineContinuation4() + Public Async Function LineContinuation4() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim aa = 1 + _ @@ -869,11 +869,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub AnonType() + Public Async Function AnonType() As Task Dim code = Class Foo Sub FooMethod() Dim SomeAnonType = New With { @@ -892,11 +892,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub CollectionInitializer() + Public Async Function CollectionInitializer() As Task Dim code = Class Foo Sub FooMethod() Dim somelist = New List(Of Integer) From { @@ -917,11 +917,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Label1() + Public Async Function Label1() As Task Dim code = Class C Sub Method() GoTo l @@ -936,11 +936,11 @@ l: Stop End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Label2() + Public Async Function Label2() As Task Dim code = Class C Sub Method() GoTo foofoofoofoofoo @@ -955,11 +955,11 @@ foofoofoofoofoo: Stop End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Label3() + Public Async Function Label3() As Task Dim code = Class C Sub Foo() foo() @@ -978,11 +978,11 @@ y: End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Trivia1() + Public Async Function Trivia1() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) ' Test @@ -1001,11 +1001,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Trivia2() + Public Async Function Trivia2() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) ''' Test @@ -1024,11 +1024,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Trivia3() + Public Async Function Trivia3() As Task Dim code = Class C Sub Method(Optional ByVal i As Integer = 1) Dim a = _ @@ -1047,12 +1047,12 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix3939() + Public Async Function BugFix3939() As Task Dim code = Imports System. Collections. @@ -1063,12 +1063,12 @@ Imports System. Collections. Generic - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4235() + Public Async Function BugFix4235() As Task Dim code = #If False Then #End If @@ -1079,235 +1079,235 @@ Imports System. #End If - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XmlLiterals1() + Public Async Function XmlLiterals1() As Task Dim code = "Dim xml = < XML > " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals2() + Public Async Function XmlLiterals2() As Task Dim code = "Dim xml = < XML > <%= a %> " Dim expected = " Dim xml = <%= a %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals3() + Public Async Function XmlLiterals3() As Task Dim code = "Dim xml = < local : XML > " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals4() + Public Async Function XmlLiterals4() As Task Dim code = "Dim xml = < local :<%= hello %> > " Dim expected = " Dim xml = >" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals5() + Public Async Function XmlLiterals5() As Task Dim code = "Dim xml = < <%= hello %> > " Dim expected = " Dim xml = <<%= hello %>>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals6() + Public Async Function XmlLiterals6() As Task Dim code = "Dim xml = < <%= hello %> /> " Dim expected = " Dim xml = <<%= hello %>/>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals7() + Public Async Function XmlLiterals7() As Task Dim code = "Dim xml = < xml attr = ""1"" /> " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals8() + Public Async Function XmlLiterals8() As Task Dim code = "Dim xml = < xml attr = '1' /> " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals9() + Public Async Function XmlLiterals9() As Task Dim code = "Dim xml = < xml attr = '1' attr2 = ""2"" attr3 = <%= hello %> /> " Dim expected = " Dim xml = />" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals10() + Public Async Function XmlLiterals10() As Task Dim code = "Dim xml = < xml local:attr = '1' attr2 = ""2"" attr3 = <%= hello %> /> " Dim expected = " Dim xml = />" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals11() + Public Async Function XmlLiterals11() As Task Dim code = "Dim xml = < xml local:attr = '1' <%= attr2 %> = ""2"" local:<%= attr3 %> = <%= hello %> /> " Dim expected = " Dim xml = =""2"" local:<%= attr3 %>=<%= hello %>/>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals12() + Public Async Function XmlLiterals12() As Task Dim code = "Dim xml = < xml> test " Dim expected = " Dim xml = test " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals13() + Public Async Function XmlLiterals13() As Task Dim code = "Dim xml = < xml> test <%= test %> " Dim expected = " Dim xml = test <%= test %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals14() + Public Async Function XmlLiterals14() As Task Dim code = "Dim xml = < xml> test <%= test %> <%= test2 %> " Dim expected = " Dim xml = test <%= test %><%= test2 %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals15() + Public Async Function XmlLiterals15() As Task Dim code = "Dim xml = < xml> <%= test1 %> test <%= test %> <%= test2 %> " Dim expected = " Dim xml = <%= test1 %> test <%= test %><%= test2 %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals16() + Public Async Function XmlLiterals16() As Task Dim code = "Dim xml = < xml> " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals17() + Public Async Function XmlLiterals17() As Task Dim code = "Dim xml = test " Dim expected = " Dim xml = test " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals18() + Public Async Function XmlLiterals18() As Task Dim code = "Dim xml = " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals19() + Public Async Function XmlLiterals19() As Task Dim code = "Dim xml = " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals20() + Public Async Function XmlLiterals20() As Task Dim code = "Dim xml = test " Dim expected = " Dim xml = test " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals21() + Public Async Function XmlLiterals21() As Task Dim code = "Dim xml = test test 2 " Dim expected = " Dim xml = test test 2 " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals22() + Public Async Function XmlLiterals22() As Task Dim code = "Dim xml = tags ]]> " Dim expected = " Dim xml = tags ]]>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals23() + Public Async Function XmlLiterals23() As Task Dim code = "Dim xml = test tags ]]> test 2 " Dim expected = " Dim xml = test tags ]]> test 2 " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals24() + Public Async Function XmlLiterals24() As Task Dim code = "Dim xml = <%= <%=42 %> <%= ""hello""%> %> " Dim expected = " Dim xml = <%= <%= 42 %><%= ""hello"" %> %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals25() + Public Async Function XmlLiterals25() As Task Dim code = "Dim xml = " Dim expected = " Dim xml = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub XmlLiterals26() + Public Async Function XmlLiterals26() As Task Dim code = My.Resources.XmlLiterals.Test1_Input Dim expected = My.Resources.XmlLiterals.Test1_Output - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub XmlLiterals27() + Public Async Function XmlLiterals27() As Task Dim code = My.Resources.XmlLiterals.Test2_Input Dim expected = My.Resources.XmlLiterals.Test2_Output - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub XmlLiterals28() + Public Async Function XmlLiterals28() As Task Dim code = My.Resources.XmlLiterals.Test3_Input Dim expected = My.Resources.XmlLiterals.Test3_Output - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub AttributeOnClass1() + Public Async Function AttributeOnClass1() As Task Dim code = Class Foo @@ -1320,12 +1320,12 @@ End Namespace]]> End Class End Namespace]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub MultipleAttributesOnClass() + Public Async Function MultipleAttributesOnClass() As Task Dim code = @@ -1340,12 +1340,12 @@ End Namespace]]> End Class End Namespace]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub MultipleAttributesOnParameter_1() + Public Async Function MultipleAttributesOnParameter_1() As Task Dim code = @@ -1359,12 +1359,12 @@ Public Class Foo Inherits Attribute End Class]]> - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub MultipleAttributesOnParameter_2() + Public Async Function MultipleAttributesOnParameter_2() As Task Dim code = @@ -1377,12 +1377,12 @@ Public Class Foo Inherits Attribute End Class]]> - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub MultipleAttributesOnParameter_3() + Public Async Function MultipleAttributesOnParameter_3() As Task Dim code = @@ -1407,11 +1407,11 @@ Public Class Foo Inherits Attribute End Class]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InheritsImplementsOnClass() + Public Async Function InheritsImplementsOnClass() As Task Dim code = End Class]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InheritsImplementsWithGenericsOnClass() + Public Async Function InheritsImplementsWithGenericsOnClass() As Task Dim code = End Class]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InheritsOnInterface() + Public Async Function InheritsOnInterface() As Task Dim code = Interface I Inherits J End Interface @@ -1462,11 +1462,11 @@ End Interface Interface J End Interface - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceMethodParens() + Public Async Function WhitespaceMethodParens() As Task Dim code = Class SomeClass Sub Foo ( x As Integer ) Foo ( 42 ) @@ -1479,11 +1479,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceKeywordParens() + Public Async Function WhitespaceKeywordParens() As Task Dim code = Class SomeClass Sub Foo If(x And(y Or(z)) Then Stop @@ -1496,11 +1496,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceLiteralAndTypeCharacters() + Public Async Function WhitespaceLiteralAndTypeCharacters() As Task Dim code = End Sub End Class]]> - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceNullable() + Public Async Function WhitespaceNullable() As Task Dim code = Class Foo Property someprop As Integer ? @@ -1574,11 +1574,11 @@ End Class End Function End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceArrayBraces() + Public Async Function WhitespaceArrayBraces() As Task Dim code = Class Foo Sub Method() Dim arr() ={ 1, 2, 3 } @@ -1591,11 +1591,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceStatementSeparator() + Public Async Function WhitespaceStatementSeparator() As Task Dim code = Class Foo Sub Method() Dim x=2:Dim y=3:Dim z=4 @@ -1608,11 +1608,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WhitespaceRemovedBeforeComment() + Public Async Function WhitespaceRemovedBeforeComment() As Task Dim code = Class Foo Sub Method() Dim a = 4 ' This is a comment that doesn't move @@ -1629,11 +1629,11 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabled1() + Public Async Function ReFormatWithTabsEnabled1() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1655,11 +1655,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabled2() + Public Async Function ReFormatWithTabsEnabled2() As Task ' tabs after the first token on a line should be converted to spaces Dim code = @@ -1683,11 +1683,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabled3() + Public Async Function ReFormatWithTabsEnabled3() As Task ' This is a regression test for the assert: it may still not pass after the assert is fixed. Dim code = @@ -1711,11 +1711,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabled4() + Public Async Function ReFormatWithTabsEnabled4() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1741,11 +1741,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabled5() + Public Async Function ReFormatWithTabsEnabled5() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1771,11 +1771,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsDisabled() + Public Async Function ReFormatWithTabsDisabled() As Task Dim code = "Class SomeClass" + vbCrLf + vbTab + "Sub Foo()" + vbCrLf + @@ -1797,11 +1797,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithDifferentIndent1() + Public Async Function ReFormatWithDifferentIndent1() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1823,11 +1823,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithDifferentIndent2() + Public Async Function ReFormatWithDifferentIndent2() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1849,11 +1849,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 6} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub ReFormatWithTabsEnabledSmallIndentAndLargeTab() + Public Async Function ReFormatWithTabsEnabledSmallIndentAndLargeTab() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1875,11 +1875,11 @@ End Class {New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2} } - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet).ConfigureAwait(True) + End Function - Public Sub RegressionCommentFollowsSubsequentIndent4173() + Public Async Function RegressionCommentFollowsSubsequentIndent4173() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1894,11 +1894,11 @@ End Class " End Sub" + vbCrLf + "End Class" - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub FormatUsingOverloads() + Public Async Function FormatUsingOverloads() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1913,21 +1913,21 @@ End Class " End Sub" + vbCrLf + "End Class" - AssertFormatUsingAllEntryPoints(code, expected) - End Sub + Await AssertFormatUsingAllEntryPointsAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub BugFix4173_1() + Public Async Function BugFix4173_1() As Task Dim code = "Dim a = <%=%> " Dim expected = " Dim a = <%= %>" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub BugFix4173_2() + Public Async Function BugFix4173_2() As Task Dim code = Class Foo Sub Foo() ' Comment Foo() @@ -1945,11 +1945,11 @@ End Class {New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True} } - AssertFormatLf2CrLf(code.Value, expected.Value, optionSet) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value, optionSet).ConfigureAwait(True) + End Function - Public Sub FormatUsingAutoGeneratedCodeOperationProvider() + Public Async Function FormatUsingAutoGeneratedCodeOperationProvider() As Task Dim code = "Class SomeClass" + vbCrLf + " Sub Foo()" + vbCrLf + @@ -1964,21 +1964,21 @@ End Class " End Sub" + vbCrLf + "End Class" - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub BugFix4173_3() + Public Async Function BugFix4173_3() As Task Dim code = My.Resources.XmlLiterals.Test4_Input Dim expected = My.Resources.XmlLiterals.Test4_Output - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub BugFix4173_4() + Public Async Function BugFix4173_4() As Task Dim code = Class C Sub Main(args As String()) Dim r = 2 @@ -1992,35 +1992,35 @@ End Sub End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4173_5() + Public Async Function BugFix4173_5() As Task Dim code = Module Module1 Public Sub foo () End Sub End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4173_6() + Public Async Function BugFix4173_6() As Task Dim code = Module module1 #If True Then #End If: foo() End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4173_7() + Public Async Function BugFix4173_7() As Task Dim code = Module Module1 Sub Main() Dim x = Sub() @@ -2037,12 +2037,12 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4173_8() + Public Async Function BugFix4173_8() As Task Dim code = Module Module1 Sub Main() ' @@ -2061,12 +2061,12 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4173_9() + Public Async Function BugFix4173_9() As Task Dim code = Module Module1 Sub Main() #If True Then @@ -2083,24 +2083,24 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4482() + Public Async Function BugFix4482() As Task Dim code = _' Public Function GroupBy(Of K, R)( _ _' ByVal key As KeyFunc(Of K), _ _' ByVal selector As SelectorFunc(Of K, QueryableCollection(Of T), R)) _ ' As QueryableCollection(Of R) - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4459() + Public Async Function BugFix4459() As Task Dim code = Option Strict Off Module Module1 Sub Main() @@ -2123,13 +2123,13 @@ Module Module1 End Function} End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4352() + Public Async Function BugFix4352() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2150,77 +2150,77 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4394() - AssertFormat(My.Resources.XmlLiterals.Test5_Input, My.Resources.XmlLiterals.Test5_Output) - End Sub + Public Async Function BugFix4394() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.Test5_Input, My.Resources.XmlLiterals.Test5_Output).ConfigureAwait(True) + End Function - Public Sub GetTypeTest() + Public Async Function GetTypeTest() As Task Dim code = "Dim a = GetType ( Object )" Dim expected = " Dim a = GetType(Object)" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub NewObjectTest() + Public Async Function NewObjectTest() As Task Dim code = "Dim a = New Object ( )" Dim expected = " Dim a = New Object()" - AssertFormat(CreateMethod(code), CreateMethod(expected), debugMode:=True) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected), debugMode:=True).ConfigureAwait(True) + End Function - Public Sub CTypeTest() + Public Async Function CTypeTest() As Task Dim code = "Dim a = CType ( args , String ( ) ) " Dim expected = " Dim a = CType(args, String())" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub TernaryConditionTest() + Public Async Function TernaryConditionTest() As Task Dim code = "Dim a = If ( True , 1, 2)" Dim expected = " Dim a = If(True, 1, 2)" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub TryCastTest() + Public Async Function TryCastTest() As Task Dim code = "Dim a = TryCast ( args , String())" Dim expected = " Dim a = TryCast(args, String())" - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub BugFix4394_1() + Public Async Function BugFix4394_1() As Task Dim code = My.Resources.XmlLiterals.Test6_Input Dim expected = My.Resources.XmlLiterals.Test6_Output - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub BugFix4639() + Public Async Function BugFix4639() As Task Dim code = "Imports " Dim expected = "Imports " - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub BugFix4641() + Public Async Function BugFix4641() As Task Dim code = Module module1 Structure C @@ -2240,24 +2240,24 @@ End Module Dim cc As C? = New C?() End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4642() + Public Async Function BugFix4642() As Task Dim code = _ Dim expected = _ - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4644() + Public Async Function BugFix4644() As Task Dim code = Option Explicit Off Module Module1 Sub Main() @@ -2294,12 +2294,12 @@ Module Module1 End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix4647() + Public Async Function BugFix4647() As Task Dim code = Option Explicit Off Module Module1 Sub Main() @@ -2338,21 +2338,21 @@ x) End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub WorkItem4737() + Public Async Function WorkItem4737() As Task Dim code = "Dim x = " Dim expected = " Dim x = " - AssertFormat(CreateMethod(code), CreateMethod(expected)) - End Sub + Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected)).ConfigureAwait(True) + End Function - Public Sub BugFix4826() + Public Async Function BugFix4826() As Task Dim code = Imports <xmlns:a=""> Module Program Sub Main() @@ -2372,11 +2372,11 @@ Module Program End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub Parentheses() + Public Async Function Parentheses() As Task Dim code = Class GenericMethod Sub Method(Of T)(t1 As T) NewMethod(Of T)(t1) @@ -2389,12 +2389,12 @@ End Module End Class - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5022() + Public Async Function BugFix5022() As Task Dim code = Class A : _ Dim x @@ -2404,13 +2404,13 @@ End Class : _ Dim x End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5232() + Public Async Function BugFix5232() As Task Dim code = Imports System Module M Sub Main() @@ -2425,13 +2425,13 @@ Module M End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5270() + Public Async Function BugFix5270() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2454,13 +2454,13 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5277() + Public Async Function BugFix5277() As Task Dim code = #If True Then #End If @@ -2471,13 +2471,13 @@ End Module #End If - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5432() + Public Async Function BugFix5432() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2502,24 +2502,24 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5268() + Public Async Function BugFix5268() As Task Dim code = #If True _ - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5268_1() + Public Async Function BugFix5268_1() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2529,13 +2529,13 @@ Module Program End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5456() + Public Async Function BugFix5456() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2555,13 +2555,13 @@ Module Program Dim foo = New With {.foo = "foo", .bar = "bar"} End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5457() + Public Async Function BugFix5457() As Task Dim code = Module module1 Sub main() Dim var1 As New Class1 @@ -2592,13 +2592,13 @@ Public Class Class1 Public foofoo As String End Class - AssertFormatSpan(code.Value.Replace(vbLf, vbCrLf), expected.Value.Replace(vbLf, vbCrLf)) - End Sub + Await AssertFormatSpanAsync(code.Value.Replace(vbLf, vbCrLf), expected.Value.Replace(vbLf, vbCrLf)).ConfigureAwait(True) + End Function - Public Sub BugFix5492() + Public Async Function BugFix5492() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2626,13 +2626,13 @@ Module Program End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5497() + Public Async Function BugFix5497() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2656,13 +2656,13 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5594() + Public Async Function BugFix5594() As Task Dim code = <Assembly : MyAttr()> <Module : MyAttr()> @@ -2692,13 +2692,13 @@ Module Module1 End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5595() + Public Async Function BugFix5595() As Task Dim code = Imports System.Xml <SomeAttr()> Module Module1 @@ -2714,13 +2714,13 @@ Imports System.Xml End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5637() + Public Async Function BugFix5637() As Task Dim code = Public Class Class1 'this line is comment line Sub sub1(ByVal aa As Integer) @@ -2735,34 +2735,34 @@ End Class End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XmlTest() - AssertFormat(My.Resources.XmlLiterals.XmlTest1_Input, My.Resources.XmlLiterals.XmlTest1_Output) - End Sub + Public Async Function XmlTest() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest1_Input, My.Resources.XmlLiterals.XmlTest1_Output).ConfigureAwait(True) + End Function - Public Sub XmlDocument() - AssertFormat(My.Resources.XmlLiterals.XmlTest2_Input, My.Resources.XmlLiterals.XmlTest2_Output) - End Sub + Public Async Function XmlDocument() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest2_Input, My.Resources.XmlLiterals.XmlTest2_Output).ConfigureAwait(True) + End Function - Public Sub XmlProcessingInstruction() - AssertFormat(My.Resources.XmlLiterals.XmlTest3_Input, My.Resources.XmlLiterals.XmlTest3_Output) - End Sub + Public Async Function XmlProcessingInstruction() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest3_Input, My.Resources.XmlLiterals.XmlTest3_Output).ConfigureAwait(True) + End Function - Public Sub XmlTest5442() + Public Async Function XmlTest5442() As Task Using workspace = New AdhocWorkspace() Dim project = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.VisualBasic) @@ -2777,15 +2777,15 @@ End Class Dim root2 = document2.GetSyntaxRootAsync().Result ' format second time - Dim result2 = Formatter.GetFormattedTextChanges(root, workspace) + Dim result2 = Await Formatter.GetFormattedTextChangesAsync(root, workspace).ConfigureAwait(True) AssertResult(My.Resources.XmlLiterals.XmlTest4_Input_Output, document2.GetTextAsync().Result, result2) End Using - End Sub + End Function - Public Sub BugFix5731() + Public Async Function BugFix5731() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2810,13 +2810,13 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5547() + Public Async Function BugFix5547() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -2843,22 +2843,22 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix5430() + Public Async Function BugFix5430() As Task Dim code = My.Resources.XmlLiterals.IndentationTest1 - AssertFormat(code, code) - End Sub + Await AssertFormatAsync(code, code).ConfigureAwait(True) + End Function - Public Sub BugFix5989() + Public Async Function BugFix5989() As Task Dim code = Imports System Module Program @@ -2877,13 +2877,13 @@ Module Program End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix6367() + Public Async Function BugFix6367() As Task Dim code = Module Program Sub Main(args As String()) Dim a As Integer = 1'Test @@ -2898,63 +2898,63 @@ End Module End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BugFix6367_1() + Public Async Function BugFix6367_1() As Task Dim code = Module Program Sub Main(args As String()) Dim a As Integer = 1 'Test End Sub End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BugFix7023_1() + Public Async Function BugFix7023_1() As Task Dim code = Module Program Public Operator +(x As Integer, y As Integer) Console.WriteLine("FOO") End Operator End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub XmlTextWithEmbededExpression1() - AssertFormat(My.Resources.XmlLiterals.XmlTest5_Input, My.Resources.XmlLiterals.XmlTest5_Output) - End Sub + Public Async Function XmlTextWithEmbededExpression1() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest5_Input, My.Resources.XmlLiterals.XmlTest5_Output).ConfigureAwait(True) + End Function - Public Sub XmlTextWithEmbededExpression2() - AssertFormat(My.Resources.XmlLiterals.XmlTest6_Input, My.Resources.XmlLiterals.XmlTest6_Output) - End Sub + Public Async Function XmlTextWithEmbededExpression2() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest6_Input, My.Resources.XmlLiterals.XmlTest6_Output).ConfigureAwait(True) + End Function - Public Sub XmlText() - AssertFormat(My.Resources.XmlLiterals.XmlTest7_Input, My.Resources.XmlLiterals.XmlTest7_Output) - End Sub + Public Async Function XmlText() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest7_Input, My.Resources.XmlLiterals.XmlTest7_Output).ConfigureAwait(True) + End Function - Public Sub XmlTextWithComment() - AssertFormat(My.Resources.XmlLiterals.XmlTest8_Input, My.Resources.XmlLiterals.XmlTest8_Output) - End Sub + Public Async Function XmlTextWithComment() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest8_Input, My.Resources.XmlLiterals.XmlTest8_Output).ConfigureAwait(True) + End Function - Public Sub MultipleControlVariables() + Public Async Function MultipleControlVariables() As Task Dim code = Module Program Sub Main(args As String()) Dim i, j As Integer @@ -2973,13 +2973,13 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ColonTrivia() + Public Async Function ColonTrivia() As Task Dim code = Module Program Sub Foo3() : End Sub @@ -2996,12 +2996,12 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub MemberAccessInObjectMemberInitializer() + Public Async Function MemberAccessInObjectMemberInitializer() As Task Dim code = Module Program Sub Main() Dim aw = New With {.a = 1, .b = 2+.a} @@ -3014,12 +3014,12 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub BinaryConditionalExpression() + Public Async Function BinaryConditionalExpression() As Task Dim code = Module Program Sub Main() Dim x = If(Nothing, "") ' Inline @@ -3034,13 +3034,13 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub Preprocessors() + Public Async Function Preprocessors() As Task Dim code = Imports System Imports System.Collections.Generic Imports System.Linq @@ -3077,35 +3077,35 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub RandomCode1() + Public Async Function RandomCode1() As Task Dim code = 'Imports alias 'foo' conflicts with 'foo' declared in the root namespace' Dim expected = 'Imports alias 'foo' conflicts with 'foo' declared in the root namespace' - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub RandomCode2() + Public Async Function RandomCode2() As Task Dim code = 'Imports alias 'foo' conflicts with 'foo' declared in the root namespace' Dim expected = 'Imports alias 'foo' conflicts with 'foo' declared in the root namespace' - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ColonTrivia1() + Public Async Function ColonTrivia1() As Task Dim code = Imports _ System.Collections.Generic _ : @@ -3133,13 +3133,13 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ColonTrivia2() + Public Async Function ColonTrivia2() As Task Dim code = Imports _ System.Collections.Generic _ : @@ -3153,13 +3153,13 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub KeyInAnonymousType() + Public Async Function KeyInAnonymousType() As Task Dim code = Class C Sub S() Dim product = New With {Key.Name = "foo"} @@ -3174,13 +3174,13 @@ End Class End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestGetXmlNamespace() + Public Async Function TestGetXmlNamespace() As Task Dim code = Class C Sub S() Dim x = GetXmlNamespace(asdf) @@ -3195,21 +3195,21 @@ End Class End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub StructuredTrivia() + Public Async Function StructuredTrivia() As Task Dim code = #const foo=2.0d Dim expected = #const foo = 2.0d - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub FormatComment1() + Public Async Function FormatComment1() As Task Dim code = Class A Sub Test() Console.WriteLine() @@ -3229,12 +3229,12 @@ End Class Console.WriteLine() End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub FormatComment2() + Public Async Function FormatComment2() As Task Dim code = Class A Sub Test() Console.WriteLine() @@ -3254,13 +3254,13 @@ End Class Console.WriteLine() End Sub End Class - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub FormatBadCode() + Public Async Function FormatBadCode() As Task Dim code = Imports System Class Program Shared Sub Main(args As String()) @@ -3270,13 +3270,13 @@ Class Program End Sub End Class - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub AttributeInParameterList() + Public Async Function AttributeInParameterList() As Task Dim code = Module Program Sub Main( <Description> args As String()) End Sub @@ -3287,13 +3287,13 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XmlElement_Expression() + Public Async Function XmlElement_Expression() As Task Dim code = Module Program Dim x = <x <%= "" %> /> End Module @@ -3302,13 +3302,13 @@ End Module Dim x = <x <%= "" %>/> End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XmlElementStartTag() + Public Async Function XmlElementStartTag() As Task Dim code = Module Program Dim x = <code > @@ -3321,13 +3321,13 @@ End Module </code> End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ForNext_MultipleVariables() + Public Async Function ForNext_MultipleVariables() As Task Dim code = Module Program Sub Method() For a = 0 To 1 @@ -3346,13 +3346,13 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ForNext_MultipleVariables2() + Public Async Function ForNext_MultipleVariables2() As Task Dim code = Module Program Sub Method() For z = 0 To 1 @@ -3375,13 +3375,13 @@ End Module End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub DictionaryAccessOperator() + Public Async Function DictionaryAccessOperator() As Task Dim code = Class S Default Property Def(s As String) As String Get @@ -3414,18 +3414,18 @@ Module Program End Sub End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XmlElementStartTag1() - AssertFormat(My.Resources.XmlLiterals.XmlElementStartTag1_Input, My.Resources.XmlLiterals.XmlElementStartTag1_Output) - End Sub + Public Async Function XmlElementStartTag1() As Task + Await AssertFormatAsync(My.Resources.XmlLiterals.XmlElementStartTag1_Input, My.Resources.XmlLiterals.XmlElementStartTag1_Output).ConfigureAwait(True) + End Function - Public Sub ElasticNewlines() + Public Async Function ElasticNewlines() As Task Dim text = Class C Implements INotifyPropertyChanged Dim _p As Integer @@ -3483,24 +3483,24 @@ End Class.Value.Replace(vbLf, vbCrLf) root = root.ReplaceNode(method, method.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(foo)) Using workspace = New AdhocWorkspace() - Dim result = Formatter.Format(root, foo, workspace).ToString() + Dim result = (Await Formatter.FormatAsync(root, foo, workspace).ConfigureAwait(True)).ToString() Assert.Equal(expected, result) End Using - End Sub + End Function - Public Sub SpacesInXmlStrings() + Public Async Function SpacesInXmlStrings() As Task Dim text = "Imports " - AssertFormat(text, text) - End Sub + Await AssertFormatAsync(text, text).ConfigureAwait(True) + End Function - Public Sub SpaceBetweenPercentGreaterThanAndXmlName() + Public Async Function SpaceBetweenPercentGreaterThanAndXmlName() As Task Dim text = Module Program Sub Main(args As String()) End Sub @@ -3509,11 +3509,11 @@ End Class.Value.Replace(vbLf, vbCrLf) End Function End Module - AssertFormatLf2CrLf(text.Value, text.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, text.Value).ConfigureAwait(True) + End Function - Public Sub SpacingAroundXmlEntityLiterals() + Public Async Function SpacingAroundXmlEntityLiterals() As Task Dim code = End Class ]]> - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub BadDirectivesAreValidRanges() + Public Async Function BadDirectivesAreValidRanges() As Task Dim code = #If False Then #end Region @@ -3548,12 +3548,12 @@ End Class #End If - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestElseIfFormatting_Directive() + Public Async Function TestElseIfFormatting_Directive() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub IndentContinuedLineOfSingleLineLambdaToFunctionKeyword() + Public Async Function IndentContinuedLineOfSingleLineLambdaToFunctionKeyword() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestSpaceBetweenEqualsAndDotOfXml() + Public Async Function TestSpaceBetweenEqualsAndDotOfXml() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub AnchorIndentToTheFirstTokenOfXmlBlock() + Public Async Function AnchorIndentToTheFirstTokenOfXmlBlock() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ForcedSpaceBetweenXmlNameTokenAndPercentGreaterThanToken() + Public Async Function ForcedSpaceBetweenXmlNameTokenAndPercentGreaterThanToken() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestElseIfFormattingForNestedSingleLineIf() + Public Async Function TestElseIfFormattingForNestedSingleLineIf() As Task Dim code = - Public Sub TestDontCrashOnMissingTokenWithComment() + Public Async Function TestDontCrashOnMissingTokenWithComment() As Task Dim code = - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function - Public Sub TestBang() + Public Async Function TestBang() As Task Dim code = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InsertSpaceBetweenXMLMemberAttributeAccessAndEqualsToken() + Public Async Function InsertSpaceBetweenXMLMemberAttributeAccessAndEqualsToken() As Task Dim expected = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestMemberAccessAfterOpenParen() + Public Async Function TestMemberAccessAfterOpenParen() As Task Dim expected = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestXmlMemberAccessDot() + Public Async Function TestXmlMemberAccessDot() As Task Dim expected = - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestElasticFormattingPropertySetter() + Public Async Function TestElasticFormattingPropertySetter() As Task Dim parameterList = SyntaxFactory.ParseParameterList(String.Format("(value As {0})", "Integer")) Dim setter = SyntaxFactory.AccessorBlock(SyntaxKind.SetAccessorBlock, SyntaxFactory.AccessorStatement(SyntaxKind.SetAccessorStatement, SyntaxFactory.Token(SyntaxKind.SetKeyword)). @@ -3915,14 +3915,14 @@ End Module End Class.Value) Dim propertyBlock = document.GetSyntaxRootAsync().Result.DescendantNodes().OfType(Of PropertyBlockSyntax).Single() - document = Formatter.FormatAsync(document.WithSyntaxRoot(document.GetSyntaxRootAsync().Result.ReplaceNode(propertyBlock, propertyBlock.WithAccessors(SyntaxFactory.SingletonList(setter))))).Result + document = Await Formatter.FormatAsync(document.WithSyntaxRoot(document.GetSyntaxRootAsync().Result.ReplaceNode(propertyBlock, propertyBlock.WithAccessors(SyntaxFactory.SingletonList(setter))))).ConfigureAwait(True) Dim actual = document.GetTextAsync().Result.ToString() Assert.Equal(actual, actual) - End Sub + End Function - Public Sub TestWarningDirectives() + Public Async Function TestWarningDirectives() As Task Dim text = # enable warning[BC000],bc123, ap456,_789' comment Module Program @@ -3945,11 +3945,11 @@ End Module #enable warning - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TestIncompleteWarningDirectives() + Public Async Function TestIncompleteWarningDirectives() As Task Dim text = # disable Module M1 @@ -3964,13 +3964,13 @@ Module M1 End Module - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub TriviaAtEndOfCaseBelongsToNextCase() + Public Async Function TriviaAtEndOfCaseBelongsToNextCase() As Task Dim text = Class X Function F(x As Integer) As Integer @@ -4005,12 +4005,12 @@ Class X End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub XelementAttributeSpacing() + Public Async Function XelementAttributeSpacing() As Task Dim text = Class X Function F(x As Integer) As Integer @@ -4029,11 +4029,11 @@ Class X End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub ConditionalAccessFormatting() + Public Async Function ConditionalAccessFormatting() As Task Const code = " Module Module1 Class G @@ -4076,11 +4076,11 @@ Module Module1 End Module " - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub ChainedConditionalAccessFormatting() + Public Async Function ChainedConditionalAccessFormatting() As Task Const code = " Module Module1 Class G @@ -4123,11 +4123,11 @@ Module Module1 End Module " - AssertFormat(code, expected) - End Sub + Await AssertFormatAsync(code, expected).ConfigureAwait(True) + End Function - Public Sub NameOfFormatting() + Public Async Function NameOfFormatting() As Task Dim text = Module M Dim s = NameOf ( M ) @@ -4140,11 +4140,11 @@ Module M End Module - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterpolatedString1() + Public Async Function InterpolatedString1() As Task Dim text = Class C Sub M() @@ -4163,11 +4163,11 @@ Class C End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterpolatedString2() + Public Async Function InterpolatedString2() As Task Dim text = Class C Sub M() @@ -4188,11 +4188,11 @@ Class C End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterpolatedString3() + Public Async Function InterpolatedString3() As Task Dim text = Class C Sub M() @@ -4211,11 +4211,11 @@ Class C End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterpolatedString4() + Public Async Function InterpolatedString4() As Task Dim text = Class C Sub M() @@ -4236,11 +4236,11 @@ Class C End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub InterpolatedString5() + Public Async Function InterpolatedString5() As Task Dim text = Class C Sub M() @@ -4257,12 +4257,12 @@ Class C End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub CaseCommentsRemainsUndisturbed() + Public Async Function CaseCommentsRemainsUndisturbed() As Task Dim text = Class Program Sub Main(args As String()) @@ -4295,27 +4295,27 @@ Class Program End Class - AssertFormatLf2CrLf(text.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(text.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub NewLineOption_LineFeedOnly() + Public Async Function NewLineOption_LineFeedOnly() As Task Dim tree = SyntaxFactory.ParseCompilationUnit("Class C" & vbCrLf & "End Class") ' replace all EOL trivia with elastic markers to force the formatter to add EOL back tree = tree.ReplaceTrivia(tree.DescendantTrivia().Where(Function(tr) tr.IsKind(SyntaxKind.EndOfLineTrivia)), Function(o, r) SyntaxFactory.ElasticMarker) - Dim formatted = Formatter.Format(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.VisualBasic, vbLf)) + Dim formatted = Await Formatter.FormatAsync(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.VisualBasic, vbLf)).ConfigureAwait(True) Dim actual = formatted.ToFullString() Dim expected = "Class C" & vbLf & "End Class" Assert.Equal(expected, actual) - End Sub + End Function - Public Sub FormatLabelFollowedByDotExpression() + Public Async Function FormatLabelFollowedByDotExpression() As Task Dim code = Module Module1 Sub Main() @@ -4336,12 +4336,12 @@ lab: .Capacity = 15 End Module - AssertFormatLf2CrLf(code.Value, expected.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, expected.Value).ConfigureAwait(True) + End Function - Public Sub FormatOmittedArgument() + Public Async Function FormatOmittedArgument() As Task Dim code = Class C Sub M() @@ -4353,8 +4353,8 @@ Class C End Sub End Class - AssertFormatLf2CrLf(code.Value, code.Value) - End Sub + Await AssertFormatLf2CrLfAsync(code.Value, code.Value).ConfigureAwait(True) + End Function End Class End Namespace \ No newline at end of file diff --git a/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb b/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb index 464bc1627003dbd4cdaf95c8aa3939c0f3e08af8..c35e4a638b99827fc166ca5f3c4dcb6f24a5ddb2 100644 --- a/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb +++ b/src/Workspaces/VisualBasicTest/Formatting/VisualBasicFormattingTestBase.vb @@ -30,14 +30,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Return StringFromLines(adjustedLines.ToArray()) End Function - Protected Sub AssertFormatLf2CrLf(code As String, expected As String, Optional optionSet As Dictionary(Of OptionKey, Object) = Nothing) + Protected Function AssertFormatLf2CrLfAsync(code As String, expected As String, Optional optionSet As Dictionary(Of OptionKey, Object) = Nothing) As Task code = code.Replace(vbLf, vbCrLf) expected = expected.Replace(vbLf, vbCrLf) - AssertFormat(code, expected, changedOptionSet:=optionSet) - End Sub + Return AssertFormatAsync(code, expected, changedOptionSet:=optionSet) + End Function - Protected Sub AssertFormatUsingAllEntryPoints(code As String, expected As String) + Protected Async Function AssertFormatUsingAllEntryPointsAsync(code As String, expected As String) As Task Using workspace = New AdhocWorkspace() Dim project = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.VisualBasic) @@ -49,50 +49,50 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting Dim spans = New List(Of TextSpan)() spans.Add(syntaxTree.GetRoot().FullSpan) - Dim changes = Formatter.GetFormattedTextChanges(syntaxTree.GetRoot(CancellationToken.None), workspace, cancellationToken:=CancellationToken.None) + Dim changes = Await Formatter.GetFormattedTextChangesAsync(syntaxTree.GetRoot(CancellationToken.None), workspace, cancellationToken:=CancellationToken.None).ConfigureAwait(True) AssertResult(expected, document.GetTextAsync().Result, changes) - changes = Formatter.GetFormattedTextChanges(syntaxTree.GetRoot(), syntaxTree.GetRoot(CancellationToken.None).FullSpan, workspace, cancellationToken:=CancellationToken.None) + changes = Await Formatter.GetFormattedTextChangesAsync(syntaxTree.GetRoot(), syntaxTree.GetRoot(CancellationToken.None).FullSpan, workspace, cancellationToken:=CancellationToken.None).ConfigureAwait(True) AssertResult(expected, document.GetTextAsync().Result, changes) spans = New List(Of TextSpan)() spans.Add(syntaxTree.GetRoot().FullSpan) - changes = Formatter.GetFormattedTextChanges(syntaxTree.GetRoot(CancellationToken.None), spans, workspace, cancellationToken:=CancellationToken.None) + changes = Await Formatter.GetFormattedTextChangesAsync(syntaxTree.GetRoot(CancellationToken.None), spans, workspace, cancellationToken:=CancellationToken.None).ConfigureAwait(True) AssertResult(expected, document.GetTextAsync().Result, changes) ' format with node and transform AssertFormatWithTransformation(workspace, expected, syntaxTree.GetRoot(), spans, Nothing, False) End Using - End Sub + End Function - Protected Sub AssertFormatSpan(markupCode As String, expected As String) + Protected Function AssertFormatSpanAsync(markupCode As String, expected As String) As Task Dim code As String = Nothing Dim cursorPosition As Integer? = Nothing Dim spans As IList(Of TextSpan) = Nothing MarkupTestFile.GetSpans(markupCode, code, spans) - AssertFormat(expected, code, spans) - End Sub + Return AssertFormatAsync(expected, code, spans) + End Function - Protected Overloads Sub AssertFormat( + Protected Overloads Function AssertFormatAsync( code As String, expected As String, Optional debugMode As Boolean = False, Optional changedOptionSet As Dictionary(Of OptionKey, Object) = Nothing, Optional testWithTransformation As Boolean = False, - Optional experimental As Boolean = False) - AssertFormat(expected, code, SpecializedCollections.SingletonEnumerable(New TextSpan(0, code.Length)), debugMode, changedOptionSet, testWithTransformation, experimental:=experimental) - End Sub + 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 Sub AssertFormat( + 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 testWithTransformation As Boolean = False, - Optional experimental As Boolean = False) + Optional experimental As Boolean = False) As Task Dim parseOptions = New VisualBasicParseOptions() If (experimental) Then @@ -100,8 +100,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting ' parseOptions = parseOptions.WithExperimentalFeatures End If - AssertFormat(expected, code, spans, LanguageNames.VisualBasic, debugMode, changedOptionSet, testWithTransformation, parseOptions) - End Sub + Return AssertFormatAsync(expected, code, spans, LanguageNames.VisualBasic, debugMode, changedOptionSet, testWithTransformation, parseOptions) + End Function Private Function StringFromLines(ParamArray lines As String()) As String Return String.Join(Environment.NewLine, lines)