public SarifErrorListItem(Run run, int runIndex, Notification notification, string logFilePath, ProjectNameCache projectNameCache) : this() { ThreadHelper.ThrowIfNotOnUIThread(); this.RunIndex = runIndex; string ruleId = null; if (notification.AssociatedRule != null) { ruleId = notification.AssociatedRule.Id; } else if (notification.Descriptor != null) { ruleId = notification.Descriptor.Id; } run.TryGetRule(ruleId, out ReportingDescriptor rule); this.RawMessage = notification.Message.Text?.Trim() ?? string.Empty; (this.ShortMessage, this.Message) = SdkUIUtilities.SplitResultMessage(this.RawMessage, MaxConcisedTextLength); this.Level = notification.Level; this.LogFilePath = logFilePath; this.FileName = SdkUIUtilities.GetFileLocationPath(notification.Locations?[0]?.PhysicalLocation?.ArtifactLocation, this.RunIndex) ?? string.Empty; this.ProjectName = projectNameCache.GetName(this.FileName); this.Locations.Add(new LocationModel(resultId: this.ResultId, runIndex: this.RunIndex) { FilePath = FileName }); this.Tool = run.Tool.ToToolModel(); this.Rule = rule.ToRuleModel(ruleId); this.Invocation = run.Invocations?[0]?.ToInvocationModel(); this.WorkingDirectory = Path.Combine(Path.GetTempPath(), this.RunIndex.ToString()); this.HelpLink = this.Rule?.HelpUri; }
public SarifErrorListItem(Run run, int runIndex, Result result, string logFilePath, ProjectNameCache projectNameCache) : this() { if (!SarifViewerPackage.IsUnitTesting) { #pragma warning disable VSTHRD108 // Assert thread affinity unconditionally ThreadHelper.ThrowIfNotOnUIThread(); #pragma warning restore VSTHRD108 } bool runHasSuppressions = run.HasSuppressedResults(); bool runHasAbsentResults = run.HasAbsentResults(); this.RunIndex = runIndex; this.ResultId = Interlocked.Increment(ref currentResultId); this.SarifResult = result; ReportingDescriptor rule = result.GetRule(run); this.Tool = run.Tool.ToToolModel(); this.Rule = rule.ToRuleModel(result.RuleId); this.Invocation = run.Invocations?[0]?.ToInvocationModel(); this.WorkingDirectory = Path.Combine(Path.GetTempPath(), this.RunIndex.ToString()); this.HelpLink = this.Rule?.HelpUri; this.RawMessage = result.GetMessageText(rule, concise: false).Trim(); (this.ShortMessage, this.Message) = SdkUIUtilities.SplitResultMessage(this.RawMessage, MaxConcisedTextLength); string xamlContent = null; if (this.SarifResult?.Message?.TryGetProperty(XamlPropertyName, out xamlContent) == true) { this.XamlMessage = Regex.Unescape(xamlContent); } this.FileName = result.GetPrimaryTargetFile(run); this.ProjectName = projectNameCache.GetName(this.FileName); this.Category = runHasAbsentResults ? result.GetCategory() : nameof(BaselineState.None); this.Region = result.GetPrimaryTargetRegion(); this.Level = this.GetEffectiveLevel(result); this.VSSuppressionState = runHasSuppressions && result.IsSuppressed() ? VSSuppressionState.Suppressed : VSSuppressionState.Active; this.LogFilePath = logFilePath; if (this.Region != null) { this.LineNumber = this.Region.StartLine; this.ColumnNumber = this.Region.StartColumn; } }