@@ -13,8 +13,8 @@ public class TracingAnalyser : Analyser
1313 {
1414 private bool init ;
1515
16- public TracingAnalyser ( IProgressMonitor pm , ILogger logger , bool addAssemblyTrapPrefix , PathTransformer pathTransformer )
17- : base ( pm , logger , addAssemblyTrapPrefix , pathTransformer )
16+ public TracingAnalyser ( IProgressMonitor pm , ILogger logger , PathTransformer pathTransformer , IPathCache pathCache , bool addAssemblyTrapPrefix )
17+ : base ( pm , logger , pathTransformer , pathCache , addAssemblyTrapPrefix )
1818 {
1919 }
2020
@@ -25,7 +25,8 @@ public TracingAnalyser(IProgressMonitor pm, ILogger logger, bool addAssemblyTrap
2525 /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
2626 public bool BeginInitialize ( IEnumerable < string > roslynArgs )
2727 {
28- return init = LogRoslynArgs ( roslynArgs , Extraction . Extractor . Version ) ;
28+ LogExtractorInfo ( ) ;
29+ return init = LogRoslynArgs ( roslynArgs ) ;
2930 }
3031
3132 /// <summary>
@@ -47,21 +48,20 @@ public void EndInitialize(
4748 this . options = options ;
4849 this . compilation = compilation ;
4950 this . extractor = new Extraction . Extractor ( cwd , args , GetOutputName ( compilation , commandLineArguments ) , [ ] , Logger , PathTransformer , ExtractorMode . None , options . QlTest ) ;
50- LogDiagnostics ( ) ;
51+ var errorCount = LogDiagnostics ( compilation ) ;
5152
5253 SetReferencePaths ( ) ;
5354
54- CompilationErrors += FilteredDiagnostics . Count ( ) ;
55+ CompilationErrors += errorCount ;
5556 }
5657
5758 /// <summary>
5859 /// Logs information about the extractor, as well as the arguments to Roslyn.
5960 /// </summary>
6061 /// <param name="roslynArgs">The arguments passed to Roslyn.</param>
6162 /// <returns>A Boolean indicating whether the same arguments have been logged previously.</returns>
62- private bool LogRoslynArgs ( IEnumerable < string > roslynArgs , string extractorVersion )
63+ private bool LogRoslynArgs ( IEnumerable < string > roslynArgs )
6364 {
64- LogExtractorInfo ( extractorVersion ) ;
6565 Logger . Log ( Severity . Info , $ " Arguments to Roslyn: { string . Join ( ' ' , roslynArgs ) } ") ;
6666
6767 var tempFile = Extractor . GetCSharpArgsLogPath ( Path . GetRandomFileName ( ) ) ;
@@ -137,27 +137,27 @@ private static string GetOutputName(CSharpCompilation compilation,
137137 return Path . Combine ( commandLineArguments . OutputDirectory , commandLineArguments . OutputFileName ) ;
138138 }
139139
140- #nullable disable warnings
141-
142- /// <summary>
143- /// Logs detailed information about this invocation,
144- /// in the event that errors were detected.
145- /// </summary>
146- /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
147- private void LogDiagnostics ( )
140+ private int LogDiagnostics ( CSharpCompilation compilation )
148141 {
149- foreach ( var error in FilteredDiagnostics )
142+ var filteredDiagnostics = compilation
143+ . GetDiagnostics ( )
144+ . Where ( e => e . Severity >= DiagnosticSeverity . Error && ! errorsToIgnore . Contains ( e . Id ) )
145+ . ToList ( ) ;
146+
147+ foreach ( var error in filteredDiagnostics )
150148 {
151149 Logger . Log ( Severity . Error , " Compilation error: {0}" , error ) ;
152150 }
153151
154- if ( FilteredDiagnostics . Any ( ) )
152+ if ( filteredDiagnostics . Count != 0 )
155153 {
156154 foreach ( var reference in compilation . References )
157155 {
158156 Logger . Log ( Severity . Info , " Resolved reference {0}" , reference . Display ) ;
159157 }
160158 }
159+
160+ return filteredDiagnostics . Count ;
161161 }
162162
163163 private static readonly HashSet < string > errorsToIgnore = new HashSet < string >
@@ -166,17 +166,5 @@ private void LogDiagnostics()
166166 "CS1589" , // XML referencing not supported
167167 "CS1569" // Error writing XML documentation
168168 } ;
169-
170- private IEnumerable < Diagnostic > FilteredDiagnostics
171- {
172- get
173- {
174- return extractor is null || extractor . Mode . HasFlag ( ExtractorMode . Standalone ) || compilation is null ? Enumerable . Empty < Diagnostic > ( ) :
175- compilation .
176- GetDiagnostics ( ) .
177- Where ( e => e . Severity >= DiagnosticSeverity . Error && ! errorsToIgnore . Contains ( e . Id ) ) ;
178- }
179- }
180- #nullable restore warnings
181169 }
182170}
0 commit comments