@@ -38,7 +38,7 @@ public abstract class DiagnosticVerifier
3838
3939 internal static string TestProjectName = "TestProject" ;
4040
41- #region Get Diagnostics
41+ #region Get Diagnostics
4242
4343 /// <summary>
4444 /// Given classes in the form of strings, their language, and an
@@ -55,10 +55,8 @@ public abstract class DiagnosticVerifier
5555 /// </returns>
5656 [ UsedImplicitly ]
5757 private static Diagnostic [ ] GetSortedDiagnostics ( string [ ] sources , string language , ImmutableArray < DiagnosticAnalyzer > analyzers ,
58- IEnumerable < MetadataReference > references = null )
59- {
60- return GetSortedDiagnosticsFromDocuments ( analyzers , GetDocuments ( sources , language , references ) ) ;
61- }
58+ IEnumerable < MetadataReference > references = null ) =>
59+ GetSortedDiagnosticsFromDocuments ( analyzers , GetDocuments ( sources , language , references ) ) ;
6260
6361 /// <summary>
6462 /// Given an analyzer and a document to apply it to, run the analyzer and gather an
@@ -84,8 +82,14 @@ protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(ImmutableArray<D
8482
8583 foreach ( var project in projects )
8684 {
87- var compilationWithAnalyzers = project . GetCompilationAsync ( ) . GetAwaiter ( ) . GetResult ( ) . WithAnalyzers ( analyzers ) ;
88- var diags = compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
85+ var compilationWithAnalyzers = project . GetCompilationAsync ( )
86+ . GetAwaiter ( )
87+ . GetResult ( )
88+ . WithAnalyzers ( analyzers ) ;
89+
90+ var diags = compilationWithAnalyzers . GetAnalyzerDiagnosticsAsync ( )
91+ . GetAwaiter ( )
92+ . GetResult ( ) ;
8993
9094 foreach ( var diag in diags )
9195 {
@@ -97,7 +101,10 @@ protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(ImmutableArray<D
97101 for ( var i = 0 ; i < documents . Length ; i ++ )
98102 {
99103 var document = documents [ i ] ;
100- var tree = document . GetSyntaxTreeAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
104+
105+ var tree = document . GetSyntaxTreeAsync ( )
106+ . GetAwaiter ( )
107+ . GetResult ( ) ;
101108
102109 if ( tree == diag . Location . SourceTree )
103110 {
@@ -119,14 +126,13 @@ protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(ImmutableArray<D
119126 /// </summary>
120127 /// <param name="diagnostics"> The list of Diagnostics to be sorted </param>
121128 /// <returns> An IEnumerable containing the Diagnostics in order of Location </returns>
122- private static Diagnostic [ ] SortDiagnostics ( IEnumerable < Diagnostic > diagnostics )
123- {
124- return diagnostics . OrderBy ( d => d . Location . SourceSpan . Start ) . ToArray ( ) ;
125- }
129+ private static Diagnostic [ ] SortDiagnostics ( IEnumerable < Diagnostic > diagnostics ) => diagnostics
130+ . OrderBy ( d => d . Location . SourceSpan . Start )
131+ . ToArray ( ) ;
126132
127- #endregion
133+ #endregion
128134
129- #region Set up compilation and documents
135+ #region Set up compilation and documents
130136
131137 /// <summary>
132138 /// Given an array of strings as sources and a language, turn them into a project
@@ -165,10 +171,11 @@ private static Document[] GetDocuments(string[] sources, string language, IEnume
165171 /// <param name="references"></param>
166172 /// <returns> A Document created from the source string </returns>
167173 protected static Document CreateDocument ( string source , string language = LanguageNames . CSharp ,
168- IEnumerable < MetadataReference > references = null )
169- {
170- return CreateProject ( new [ ] { source } , language , references ) . Documents . First ( ) ;
171- }
174+ IEnumerable < MetadataReference > references = null ) => CreateProject ( new [ ]
175+ {
176+ source
177+ } , language , references )
178+ . Documents . First ( ) ;
172179
173180 /// <summary>
174181 /// Create a project using the inputted strings as sources.
@@ -184,7 +191,10 @@ private static Project CreateProject(string[] sources, string language = Languag
184191 IEnumerable < MetadataReference > references = null )
185192 {
186193 var fileNamePrefix = DefaultFilePathPrefix ;
187- var fileExt = language == LanguageNames . CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt ;
194+
195+ var fileExt = language == LanguageNames . CSharp
196+ ? CSharpDefaultFileExt
197+ : VisualBasicDefaultExt ;
188198
189199 var projectId = ProjectId . CreateNewId ( TestProjectName ) ;
190200
@@ -215,5 +225,5 @@ private static Project CreateProject(string[] sources, string language = Languag
215225 return solution . GetProject ( projectId ) ;
216226 }
217227
218- #endregion
228+ #endregion
219229}
0 commit comments