mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
C#: Add high level diagnostic messages for buildless extraction (start, success)
This commit is contained in:
@@ -44,7 +44,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
public override BuildScript GetBuildScript()
|
||||
{
|
||||
var attempt = BuildScript.Failure;
|
||||
switch (GetCSharpBuildStrategy())
|
||||
switch (BuildStrategy)
|
||||
{
|
||||
case CSharpBuildStrategy.CustomBuildCommand:
|
||||
attempt = new BuildCommandRule(DotNetRule.WithDotNet).Analyse(this, false) & CheckExtractorRun(true);
|
||||
@@ -218,6 +218,10 @@ namespace Semmle.Autobuild.CSharp
|
||||
return CSharpBuildStrategy.Auto;
|
||||
}
|
||||
|
||||
private CSharpBuildStrategy? buildStrategy = null;
|
||||
private CSharpBuildStrategy BuildStrategy => buildStrategy ??= GetCSharpBuildStrategy();
|
||||
public override bool IsBuildless => BuildStrategy == CSharpBuildStrategy.Buildless;
|
||||
|
||||
private enum CSharpBuildStrategy
|
||||
{
|
||||
CustomBuildCommand,
|
||||
|
||||
@@ -301,6 +301,18 @@ namespace Semmle.Autobuild.Shared
|
||||
var onOutput = BuildOutputHandler(Console.Out);
|
||||
var onError = BuildOutputHandler(Console.Error);
|
||||
|
||||
if (IsBuildless)
|
||||
{
|
||||
AddDiagnostic(new DiagnosticMessage(
|
||||
Options.Language,
|
||||
"buildless/mode-active",
|
||||
"C# was extracted in buildless mode",
|
||||
visibility: new DiagnosticMessage.TspVisibility(statusPage: true, cliSummaryTable: true, telemetry: true),
|
||||
markdownMessage: "C# was extracted in buildless mode. 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.",
|
||||
severity: DiagnosticMessage.TspSeverity.Note
|
||||
));
|
||||
}
|
||||
|
||||
var buildResult = script.Run(Actions, startCallback, exitCallback, onOutput, onError);
|
||||
|
||||
// if the build succeeded, all diagnostics we captured from the build output should be warnings;
|
||||
@@ -310,6 +322,18 @@ namespace Semmle.Autobuild.Shared
|
||||
.Select(result => result.ToDiagnosticMessage(this, diagSeverity))
|
||||
.ForEach(AddDiagnostic);
|
||||
|
||||
if (buildResult == 0 && IsBuildless)
|
||||
{
|
||||
AddDiagnostic(new DiagnosticMessage(
|
||||
Options.Language,
|
||||
"buildless/complete",
|
||||
"C# buildless extraction completed",
|
||||
visibility: new DiagnosticMessage.TspVisibility(statusPage: false, cliSummaryTable: true, telemetry: true),
|
||||
markdownMessage: "C# buildless extraction has completed.",
|
||||
severity: DiagnosticMessage.TspSeverity.Unknown
|
||||
));
|
||||
}
|
||||
|
||||
return buildResult;
|
||||
}
|
||||
|
||||
@@ -318,6 +342,8 @@ namespace Semmle.Autobuild.Shared
|
||||
/// </summary>
|
||||
public abstract BuildScript GetBuildScript();
|
||||
|
||||
public virtual bool IsBuildless { get; } = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Produces a diagnostic for the tool status page that we were unable to automatically
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Semmle.Util
|
||||
[JsonConverter(typeof(StringEnumConverter), typeof(CamelCaseNamingStrategy))]
|
||||
public enum TspSeverity
|
||||
{
|
||||
Unknown,
|
||||
Note,
|
||||
Warning,
|
||||
Error
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"markdownMessage": "C# buildless extraction has completed.",
|
||||
"severity": "unknown",
|
||||
"source": {
|
||||
"extractorName": "csharp",
|
||||
"id": "csharp/autobuilder/buildless/complete",
|
||||
"name": "C# buildless extraction completed"
|
||||
},
|
||||
"visibility": {
|
||||
"cliSummaryTable": true,
|
||||
"statusPage": false,
|
||||
"telemetry": true
|
||||
}
|
||||
}
|
||||
{
|
||||
"markdownMessage": "C# was extracted in buildless mode. 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.",
|
||||
"severity": "note",
|
||||
"source": {
|
||||
"extractorName": "csharp",
|
||||
"id": "csharp/autobuilder/buildless/mode-active",
|
||||
"name": "C# was extracted in buildless mode"
|
||||
},
|
||||
"visibility": {
|
||||
"cliSummaryTable": true,
|
||||
"statusPage": true,
|
||||
"telemetry": true
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
check_diagnostics()
|
||||
Reference in New Issue
Block a user