internal static async Task ProcessSarifLogAsync(SarifLog sarifLog, string logFilePath, bool cleanErrors, bool openInEditor) { // The creation of the data models must be done on the UI thread (for now). // VS's table data source constructs are indeed thread safe. // The object model (which is eventually handed to WPF\XAML) could also // be constructed on any thread as well. // However the current implementation of the data model and // the "run data cache" have not been augmented to support this // and are not thread safe. // This work could be done in the future to do even less work on the UI // thread if needed. if (!SarifViewerPackage.IsUnitTesting) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); } // Clear previous data if (cleanErrors) { CleanAllErrors(); } bool hasResults = false; foreach (Run run in sarifLog.Runs) { // run.tool is required, add one if it's missing if (run.Tool == null) { run.Tool = new Tool { Driver = new ToolComponent { Name = Resources.UnknownToolName, }, }; } if (Instance.WriteRunToErrorList(run, logFilePath, sarifLog) > 0) { hasResults = true; } } if (openInEditor && !SarifViewerPackage.IsUnitTesting) { SdkUIUtilities.OpenDocument(ServiceProvider.GlobalProvider, logFilePath, usePreviewPane: false); } if (hasResults) { if (!SarifViewerPackage.IsUnitTesting) { // We cannot show UI during unit-tests. SdkUIUtilities.ShowToolWindowAsync(new Guid(ToolWindowGuids80.ErrorList), activate: false).FileAndForget(Constants.FileAndForgetFaultEventNames.ShowErrorList); } } RaiseLogProcessed(ExceptionalConditionsCalculator.Calculate(sarifLog)); }
internal static void ProcessSarifLog(SarifLog sarifLog, string logFilePath, Solution solution) { // Clear previous data SarifTableDataSource.Instance.CleanAllErrors(); CodeAnalysisResultManager.Instance.SarifErrors.Clear(); CodeAnalysisResultManager.Instance.FileDetails.Clear(); foreach (Run run in sarifLog.Runs) { Instance.WriteRunToErrorList(run, logFilePath, solution); } }
internal static void ProcessSarifLog(SarifLog sarifLog, string logFilePath, Solution solution) { // Clear previous data SarifTableDataSource.Instance.CleanAllErrors(); CodeAnalysisResultManager.Instance.SarifErrors.Clear(); CodeAnalysisResultManager.Instance.FileDetails.Clear(); foreach (Run run in sarifLog.Runs) { TelemetryProvider.WriteEvent(TelemetryEvent.LogFileRunCreatedByToolName, TelemetryProvider.CreateKeyValuePair("ToolName", run.Tool.Name)); Instance.WriteRunToErrorList(run, logFilePath, solution); } }
internal static void ProcessSarifLog(SarifLog sarifLog, string logFilePath, Solution solution, bool showMessageOnNoResults) { // Clear previous data CodeAnalysisResultManager.Instance.ClearCurrentMarkers(); SarifTableDataSource.Instance.CleanAllErrors(); CodeAnalysisResultManager.Instance.RunDataCaches.Clear(); bool hasResults = false; foreach (Run run in sarifLog.Runs) { // run.tool is required, add one if it's missing if (run.Tool == null) { run.Tool = new Tool { Driver = new ToolComponent { Name = Resources.UnknownToolName } }; } TelemetryProvider.WriteEvent(TelemetryEvent.LogFileRunCreatedByToolName, TelemetryProvider.CreateKeyValuePair("ToolName", run.Tool.Driver.Name)); if (Instance.WriteRunToErrorList(run, logFilePath, solution) > 0) { hasResults = true; } } // We are finished processing the runs, so make this property inavalid. CodeAnalysisResultManager.Instance.CurrentRunId = -1; if (!hasResults && showMessageOnNoResults) { VsShellUtilities.ShowMessageBox(SarifViewerPackage.ServiceProvider, string.Format(Resources.NoResults_DialogMessage, logFilePath), null, // title OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }
internal static void ProcessSarifLog(SarifLog sarifLog, string logFilePath, Solution solution) { // Clear previous data SarifTableDataSource.Instance.CleanAllErrors(); CodeAnalysisResultManager.Instance.SarifErrors.Clear(); CodeAnalysisResultManager.Instance.FileDetails.Clear(); bool hasResults = false; foreach (Run run in sarifLog.Runs) { // run.tool is required, add one if it's missing if (run.Tool == null) { run.Tool = new Tool { Name = Resources.UnknownToolName }; } TelemetryProvider.WriteEvent(TelemetryEvent.LogFileRunCreatedByToolName, TelemetryProvider.CreateKeyValuePair("ToolName", run.Tool.Name)); if (Instance.WriteRunToErrorList(run, logFilePath, solution) > 0) { hasResults = true; } } if (!hasResults) { VsShellUtilities.ShowMessageBox(SarifViewerPackage.ServiceProvider, string.Format(Resources.NoResults_DialogMessage, logFilePath), null, // title OLEMSGICON.OLEMSGICON_INFO, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }