@@ -36,40 +36,40 @@ public Analyser(IProgressMonitor pm, ILogger logger)
3636 CSharpCompilation compilation ;
3737 Layout layout ;
3838
39+ private bool init ;
3940 /// <summary>
40- /// Initialize the analyser.
41+ /// Start initialization of the analyser.
4142 /// </summary>
42- /// <param name="commandLineArguments">Arguments passed to csc.</param>
43- /// <param name="options">Extractor options.</param>
4443 /// <param name="roslynArgs">The arguments passed to Roslyn.</param>
45- /// <param name="finalizeInit">A continuation for finalizing initialization based on a Roslyn compilation.</param>
4644 /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
47- public bool Initialize (
48- CSharpCommandLineArguments commandLineArguments ,
49- Options options ,
50- string [ ] roslynArgs ,
51- out Action < CSharpCompilation > finalizeInit )
45+ public bool BeginInitialize ( string [ ] roslynArgs )
5246 {
53- if ( ! LogRoslynArgs ( roslynArgs , Extraction . Extractor . Version ) )
54- {
55- finalizeInit = null ;
56- return false ;
57- }
47+ return init = LogRoslynArgs ( roslynArgs , Extraction . Extractor . Version ) ;
48+ }
5849
50+ /// <summary>
51+ /// End initialization of the analyser.
52+ /// </summary>
53+ /// <param name="commandLineArguments">Arguments passed to csc.</param>
54+ /// <param name="options">Extractor options.</param>
55+ /// <param name="compilation">The Roslyn compilation.</param>
56+ /// <returns>A Boolean indicating whether to proceed with extraction.</returns>
57+ public void EndInitialize (
58+ CSharpCommandLineArguments commandLineArguments ,
59+ Options options ,
60+ CSharpCompilation compilation )
61+ {
62+ if ( ! init )
63+ throw new InternalError ( "EndInitialize called without BeginInitialize returning true" ) ;
5964 layout = new Layout ( ) ;
6065 this . options = options ;
66+ this . compilation = compilation ;
67+ extractor = new Extraction . Extractor ( false , GetOutputName ( compilation , commandLineArguments ) , Logger ) ;
68+ LogDiagnostics ( ) ;
6169
62- finalizeInit = comp =>
63- {
64- compilation = comp ;
65- extractor = new Extraction . Extractor ( false , GetOutputName ( comp , commandLineArguments ) , Logger ) ;
66- LogDiagnostics ( ) ;
67-
68- SetReferencePaths ( ) ;
70+ SetReferencePaths ( ) ;
6971
70- CompilationErrors += FilteredDiagnostics . Count ( ) ;
71- } ;
72- return true ;
72+ CompilationErrors += FilteredDiagnostics . Count ( ) ;
7373 }
7474
7575 /// <summary>
@@ -444,7 +444,7 @@ public void LogExtractorInfo(string extractorVersion)
444444 /// Logs information about the extractor, as well as the arguments to Roslyn.
445445 /// </summary>
446446 /// <param name="roslynArgs">The arguments passed to Roslyn.</param>
447- /// <returns>A Boolean indicating whether to proceed with extraction .</returns>
447+ /// <returns>A Boolean indicating whether the same arguments have been logged previously .</returns>
448448 public bool LogRoslynArgs ( string [ ] roslynArgs , string extractorVersion )
449449 {
450450 LogExtractorInfo ( extractorVersion ) ;
@@ -456,7 +456,7 @@ public bool LogRoslynArgs(string[] roslynArgs, string extractorVersion)
456456 bool argsWritten ;
457457 using ( var streamWriter = new StreamWriter ( new FileStream ( tempFile , FileMode . Append , FileAccess . Write ) ) )
458458 {
459- streamWriter . WriteLine ( $ "Arguments to Roslyn: { string . Join ( ' ' , roslynArgs ) } ") ;
459+ streamWriter . WriteLine ( $ "# Arguments to Roslyn: { string . Join ( ' ' , roslynArgs ) } ") ;
460460 argsWritten = roslynArgs . WriteCommandLine ( streamWriter ) ;
461461 }
462462
0 commit comments