@@ -9,12 +9,9 @@ namespace StyleCop.Analyzers.Test.HelperTests
99 using Microsoft . CodeAnalysis ;
1010 using Microsoft . CodeAnalysis . CSharp ;
1111 using Microsoft . CodeAnalysis . Formatting ;
12- using Microsoft . CodeAnalysis . Testing ;
13- using Microsoft . CodeAnalysis . Testing . Verifiers ;
1412 using Microsoft . CodeAnalysis . Text ;
1513 using StyleCop . Analyzers . Helpers ;
1614 using StyleCop . Analyzers . Settings . ObjectModel ;
17- using StyleCop . Analyzers . Test . Helpers ;
1815 using StyleCop . Analyzers . Test . Verifiers ;
1916 using Xunit ;
2017
@@ -114,7 +111,7 @@ public class IndentationHelperTests
114111 public async Task VerifyGetIndentationStepsAsync ( string indentationString , int expectedIndentationSteps , int indentationSize , int tabSize )
115112 {
116113 var testSource = $ "{ indentationString } public class TestClass {{}}";
117- var document = CreateTestDocument ( testSource , indentationSize , false , tabSize ) ;
114+ var document = await CreateTestDocumentAsync ( testSource , indentationSize , false , tabSize , CancellationToken . None ) . ConfigureAwait ( false ) ;
118115 StyleCopSettings settings = SettingsHelper . GetStyleCopSettings ( document . Project . AnalyzerOptions , CancellationToken . None ) ;
119116
120117 var syntaxRoot = await document . GetSyntaxRootAsync ( ) . ConfigureAwait ( false ) ;
@@ -132,7 +129,7 @@ public async Task VerifyGetIndentationStepsAsync(string indentationString, int e
132129 public async Task VerifyGetIndentationStepsForTokenNotAtStartOfLineAsync ( )
133130 {
134131 var testSource = " public class TestClass {}" ;
135- var document = CreateTestDocument ( testSource ) ;
132+ var document = await CreateTestDocumentAsync ( testSource , cancellationToken : CancellationToken . None ) . ConfigureAwait ( false ) ;
136133 StyleCopSettings settings = SettingsHelper . GetStyleCopSettings ( document . Project . AnalyzerOptions , CancellationToken . None ) ;
137134
138135 var syntaxRoot = await document . GetSyntaxRootAsync ( ) . ConfigureAwait ( false ) ;
@@ -141,7 +138,7 @@ public async Task VerifyGetIndentationStepsForTokenNotAtStartOfLineAsync()
141138 Assert . Equal ( 0 , IndentationHelper . GetIndentationSteps ( settings . Indentation , secondToken ) ) ;
142139 }
143140
144- private static Document CreateTestDocument ( string source , int indentationSize = 4 , bool useTabs = false , int tabSize = 4 )
141+ private static async Task < Document > CreateTestDocumentAsync ( string source , int indentationSize = 4 , bool useTabs = false , int tabSize = 4 , CancellationToken cancellationToken = default )
145142 {
146143 var workspace = GenericAnalyzerTest . CreateWorkspace ( ) ;
147144 workspace . Options = workspace . Options
@@ -152,15 +149,12 @@ private static Document CreateTestDocument(string source, int indentationSize =
152149 var projectId = ProjectId . CreateNewId ( ) ;
153150 var documentId = DocumentId . CreateNewId ( projectId ) ;
154151 var compilationOptions = new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary , allowUnsafe : true ) ;
152+ var references = await GenericAnalyzerTest . ReferenceAssemblies . ResolveAsync ( LanguageNames . CSharp , cancellationToken ) . ConfigureAwait ( false ) ;
155153
156154 var solution = workspace . CurrentSolution
157155 . AddProject ( projectId , TestProjectName , TestProjectName , LanguageNames . CSharp )
158156 . WithProjectCompilationOptions ( projectId , compilationOptions )
159- . AddMetadataReference ( projectId , MetadataReferences . CorlibReference )
160- . AddMetadataReference ( projectId , MetadataReferences . SystemReference )
161- . AddMetadataReference ( projectId , MetadataReferences . SystemCoreReference )
162- . AddMetadataReference ( projectId , GenericAnalyzerTest . CSharpSymbolsReference )
163- . AddMetadataReference ( projectId , MetadataReferences . CodeAnalysisReference )
157+ . AddMetadataReferences ( projectId , references )
164158 . AddDocument ( documentId , TestFilename , SourceText . From ( source ) ) ;
165159
166160 StyleCopSettings defaultSettings = new StyleCopSettings ( ) ;
0 commit comments