@@ -36,40 +36,40 @@ public Analyser(IProgressMonitor pm, ILogger logger)
36
36
CSharpCompilation compilation ;
37
37
Layout layout ;
38
38
39
+ private bool init ;
39
40
/// <summary>
40
- /// Initialize the analyser.
41
+ /// Start initialization of the analyser.
41
42
/// </summary>
42
- /// <param name="commandLineArguments">Arguments passed to csc.</param>
43
- /// <param name="options">Extractor options.</param>
44
43
/// <param name="roslynArgs">The arguments passed to Roslyn.</param>
45
- /// <param name="finalizeInit">A continuation for finalizing initialization based on a Roslyn compilation.</param>
46
44
/// <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 )
52
46
{
53
- if ( ! LogRoslynArgs ( roslynArgs , Extraction . Extractor . Version ) )
54
- {
55
- finalizeInit = null ;
56
- return false ;
57
- }
47
+ return init = LogRoslynArgs ( roslynArgs , Extraction . Extractor . Version ) ;
48
+ }
58
49
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" ) ;
59
64
layout = new Layout ( ) ;
60
65
this . options = options ;
66
+ this . compilation = compilation ;
67
+ extractor = new Extraction . Extractor ( false , GetOutputName ( compilation , commandLineArguments ) , Logger ) ;
68
+ LogDiagnostics ( ) ;
61
69
62
- finalizeInit = comp =>
63
- {
64
- compilation = comp ;
65
- extractor = new Extraction . Extractor ( false , GetOutputName ( comp , commandLineArguments ) , Logger ) ;
66
- LogDiagnostics ( ) ;
67
-
68
- SetReferencePaths ( ) ;
70
+ SetReferencePaths ( ) ;
69
71
70
- CompilationErrors += FilteredDiagnostics . Count ( ) ;
71
- } ;
72
- return true ;
72
+ CompilationErrors += FilteredDiagnostics . Count ( ) ;
73
73
}
74
74
75
75
/// <summary>
@@ -444,7 +444,7 @@ public void LogExtractorInfo(string extractorVersion)
444
444
/// Logs information about the extractor, as well as the arguments to Roslyn.
445
445
/// </summary>
446
446
/// <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>
448
448
public bool LogRoslynArgs ( string [ ] roslynArgs , string extractorVersion )
449
449
{
450
450
LogExtractorInfo ( extractorVersion ) ;
@@ -456,7 +456,7 @@ public bool LogRoslynArgs(string[] roslynArgs, string extractorVersion)
456
456
bool argsWritten ;
457
457
using ( var streamWriter = new StreamWriter ( new FileStream ( tempFile , FileMode . Append , FileAccess . Write ) ) )
458
458
{
459
- streamWriter . WriteLine ( $ "Arguments to Roslyn: { string . Join ( ' ' , roslynArgs ) } ") ;
459
+ streamWriter . WriteLine ( $ "# Arguments to Roslyn: { string . Join ( ' ' , roslynArgs ) } ") ;
460
460
argsWritten = roslynArgs . WriteCommandLine ( streamWriter ) ;
461
461
}
462
462
0 commit comments