@@ -44,14 +44,16 @@ public class CSharpAutobuilder : Autobuilder<CSharpAutobuildOptions>
4444 public override BuildScript GetBuildScript ( )
4545 {
4646 var attempt = BuildScript . Failure ;
47- switch ( BuildStrategy )
47+ switch ( GetCSharpBuildStrategy ( ) )
4848 {
4949 case CSharpBuildStrategy . CustomBuildCommand :
5050 attempt = new BuildCommandRule ( DotNetRule . WithDotNet ) . Analyse ( this , false ) & CheckExtractorRun ( true ) ;
5151 break ;
5252 case CSharpBuildStrategy . Buildless :
5353 // No need to check that the extractor has been executed in buildless mode
54- attempt = new StandaloneBuildRule ( ) . Analyse ( this , false ) ;
54+ attempt = BuildScript . Bind (
55+ AddBuildlessStartedDiagnostic ( ) & new StandaloneBuildRule ( ) . Analyse ( this , false ) ,
56+ AddBuildlessEndedDiagnostic ) ;
5557 break ;
5658 case CSharpBuildStrategy . MSBuild :
5759 attempt = new MsBuildRule ( ) . Analyse ( this , false ) & CheckExtractorRun ( true ) ;
@@ -86,6 +88,52 @@ public BuildScript CheckExtractorRun(bool warnOnFailure) =>
8688 return 1 ;
8789 } ) ;
8890
91+ private BuildScript AddBuildlessStartedDiagnostic ( )
92+ {
93+ return BuildScript . Create ( actions =>
94+ {
95+ AddDiagnostic ( new DiagnosticMessage (
96+ Options . Language ,
97+ "buildless/mode-active" ,
98+ "C# with build-mode set to 'none'" ,
99+ visibility : new DiagnosticMessage . TspVisibility ( statusPage : true , cliSummaryTable : true , telemetry : true ) ,
100+ markdownMessage : "C# with build-mode set to 'none'. This means that all C# source in the working directory will be scanned, with build tools, such as Nuget and Dotnet CLIs, only contributing information about external dependencies." ,
101+ severity : DiagnosticMessage . TspSeverity . Note
102+ ) ) ;
103+ return 0 ;
104+ } ) ;
105+ }
106+
107+ private BuildScript AddBuildlessEndedDiagnostic ( int buildResult )
108+ {
109+ return BuildScript . Create ( actions =>
110+ {
111+ if ( buildResult == 0 )
112+ {
113+ AddDiagnostic ( new DiagnosticMessage (
114+ Options . Language ,
115+ "buildless/complete" ,
116+ "C# analysis with build-mode 'none' completed" ,
117+ visibility : new DiagnosticMessage . TspVisibility ( statusPage : false , cliSummaryTable : true , telemetry : true ) ,
118+ markdownMessage : "C# analysis with build-mode 'none' completed." ,
119+ severity : DiagnosticMessage . TspSeverity . Unknown
120+ ) ) ;
121+ }
122+ else
123+ {
124+ AddDiagnostic ( new DiagnosticMessage (
125+ Options . Language ,
126+ "buildless/failed" ,
127+ "C# analysis with build-mode 'none' failed" ,
128+ visibility : new DiagnosticMessage . TspVisibility ( statusPage : true , cliSummaryTable : true , telemetry : true ) ,
129+ markdownMessage : "C# analysis with build-mode 'none' failed." ,
130+ severity : DiagnosticMessage . TspSeverity . Error
131+ ) ) ;
132+ }
133+ return buildResult ;
134+ } ) ;
135+ }
136+
89137 protected override void AutobuildFailureDiagnostic ( )
90138 {
91139 // if `ScriptPath` is not null here, the `BuildCommandAuto` rule was
@@ -218,10 +266,6 @@ private CSharpBuildStrategy GetCSharpBuildStrategy()
218266 return CSharpBuildStrategy . Auto ;
219267 }
220268
221- private CSharpBuildStrategy ? buildStrategy = null ;
222- private CSharpBuildStrategy BuildStrategy => buildStrategy ??= GetCSharpBuildStrategy ( ) ;
223- public override bool IsBuildless => BuildStrategy == CSharpBuildStrategy . Buildless ;
224-
225269 private enum CSharpBuildStrategy
226270 {
227271 CustomBuildCommand ,
0 commit comments