mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Add compilation errors to the debug log in BMN.
This commit is contained in:
@@ -360,5 +360,22 @@ namespace Semmle.Extraction.CSharp
|
|||||||
return versionString.InformationalVersion;
|
return versionString.InformationalVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly HashSet<string> errorsToIgnore = new HashSet<string>
|
||||||
|
{
|
||||||
|
"CS7027", // Code signing failure
|
||||||
|
"CS1589", // XML referencing not supported
|
||||||
|
"CS1569" // Error writing XML documentation
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the diagnostics from the compilation, filtering out those that should be ignored.
|
||||||
|
/// </summary>
|
||||||
|
protected List<Diagnostic> GetFilteredDiagnostics() =>
|
||||||
|
compilation is not null
|
||||||
|
? compilation.GetDiagnostics()
|
||||||
|
.Where(e => e.Severity >= DiagnosticSeverity.Error && !errorsToIgnore.Contains(e.Id))
|
||||||
|
.ToList()
|
||||||
|
: [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ namespace Semmle.Extraction.CSharp
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LogDiagnostics()
|
||||||
|
{
|
||||||
|
foreach (var error in GetFilteredDiagnostics())
|
||||||
|
{
|
||||||
|
Logger.LogDebug($" Compilation error: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialize(string outputPath, IEnumerable<(string, string)> compilationInfos, CSharpCompilation compilationIn, CommonOptions options)
|
public void Initialize(string outputPath, IEnumerable<(string, string)> compilationInfos, CSharpCompilation compilationIn, CommonOptions options)
|
||||||
{
|
{
|
||||||
compilation = compilationIn;
|
compilation = compilationIn;
|
||||||
@@ -20,6 +28,7 @@ namespace Semmle.Extraction.CSharp
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
LogExtractorInfo();
|
LogExtractorInfo();
|
||||||
SetReferencePaths();
|
SetReferencePaths();
|
||||||
|
LogDiagnostics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,7 @@ namespace Semmle.Extraction.CSharp
|
|||||||
|
|
||||||
private int LogDiagnostics()
|
private int LogDiagnostics()
|
||||||
{
|
{
|
||||||
var filteredDiagnostics = compilation!
|
var filteredDiagnostics = GetFilteredDiagnostics();
|
||||||
.GetDiagnostics()
|
|
||||||
.Where(e => e.Severity >= DiagnosticSeverity.Error && !errorsToIgnore.Contains(e.Id))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var error in filteredDiagnostics)
|
foreach (var error in filteredDiagnostics)
|
||||||
{
|
{
|
||||||
Logger.LogError($" Compilation error: {error}");
|
Logger.LogError($" Compilation error: {error}");
|
||||||
@@ -148,7 +144,7 @@ namespace Semmle.Extraction.CSharp
|
|||||||
|
|
||||||
if (filteredDiagnostics.Count != 0)
|
if (filteredDiagnostics.Count != 0)
|
||||||
{
|
{
|
||||||
foreach (var reference in compilation.References)
|
foreach (var reference in compilation!.References)
|
||||||
{
|
{
|
||||||
Logger.LogInfo($" Resolved reference {reference.Display}");
|
Logger.LogInfo($" Resolved reference {reference.Display}");
|
||||||
}
|
}
|
||||||
@@ -156,12 +152,5 @@ namespace Semmle.Extraction.CSharp
|
|||||||
|
|
||||||
return filteredDiagnostics.Count;
|
return filteredDiagnostics.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly HashSet<string> errorsToIgnore = new HashSet<string>
|
|
||||||
{
|
|
||||||
"CS7027", // Code signing failure
|
|
||||||
"CS1589", // XML referencing not supported
|
|
||||||
"CS1569" // Error writing XML documentation
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user