in src/Sarif.Viewer.VisualStudio.Core/ErrorList/ErrorListService.cs [561:636]
private int WriteRunToErrorList(Run run, string logFilePath, SarifLog sarifLog)
{
if (!SarifViewerPackage.IsUnitTesting)
{
#pragma warning disable VSTHRD108 // Assert thread affinity unconditionally
ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD108
}
int runIndex = CodeAnalysisResultManager.Instance.GetNextRunIndex();
var dataCache = new RunDataCache(runIndex, logFilePath, sarifLog);
CodeAnalysisResultManager.Instance.RunIndexToRunDataCache.Add(runIndex, dataCache);
CodeAnalysisResultManager.Instance.CacheUriBasePaths(run);
var sarifErrors = new List<SarifErrorListItem>();
var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
var projectNameCache = new ProjectNameCache(dte?.Solution);
this.StoreFileDetails(run.Artifacts);
if (run.Results != null)
{
foreach (Result result in run.Results)
{
result.Run = run;
var sarifError = new SarifErrorListItem(run, runIndex, result, logFilePath, projectNameCache);
sarifErrors.Add(sarifError);
}
}
if (run.Invocations != null)
{
foreach (Invocation invocation in run.Invocations)
{
if (invocation.ToolConfigurationNotifications != null)
{
foreach (Notification configurationNotification in invocation.ToolConfigurationNotifications)
{
var sarifError = new SarifErrorListItem(run, runIndex, configurationNotification, logFilePath, projectNameCache);
sarifErrors.Add(sarifError);
}
}
if (invocation.ToolExecutionNotifications != null)
{
foreach (Notification toolNotification in invocation.ToolExecutionNotifications)
{
if (toolNotification.Level != FailureLevel.Note)
{
var sarifError = new SarifErrorListItem(run, runIndex, toolNotification, logFilePath, projectNameCache);
sarifErrors.Add(sarifError);
}
}
}
}
}
if (run.HasAbsentResults())
{
this.ShowFilteredCategoryColumn();
}
if (run.HasSuppressedResults())
{
this.ShowFilteredSuppressionStateColumn();
}
(dataCache.SarifErrors as List<SarifErrorListItem>).AddRange(sarifErrors);
SarifTableDataSource.Instance.AddErrors(sarifErrors);
// This causes already open "text views" to be tagged when SARIF logs are processed after a view is opened.
SarifLocationTagHelpers.RefreshTags();
return sarifErrors.Count;
}