public SarifErrorListItem(Run run, Notification notification, string logFilePath, ProjectNameCache projectNameCache) : this() { IRule rule; string ruleId = notification.RuleId ?? notification.Id; run.TryGetRule(ruleId, notification.RuleKey, out rule); Message = notification.Message; ShortMessage = notification.Message; LogFilePath = logFilePath; FileName = notification.PhysicalLocation?.Uri.LocalPath ?? run.Tool.FullName; ProjectName = projectNameCache.GetName(FileName); Locations.Add(new AnnotatedCodeLocationModel() { FilePath = FileName }); Tool = run.Tool.ToToolModel(); Rule = rule.ToRuleModel(ruleId); Rule.DefaultLevel = notification.Level.ToString(); Invocation = run.Invocation.ToInvocationModel(); if (string.IsNullOrWhiteSpace(run.Id)) { WorkingDirectory = Path.Combine(Path.GetTempPath(), run.GetHashCode().ToString()); } else { WorkingDirectory = Path.Combine(Path.GetTempPath(), run.Id); } }
public SarifErrorListItem(Run run, Result result, string logFilePath, ProjectNameCache projectNameCache) : this() { IRule rule; run.TryGetRule(result.RuleId, result.RuleKey, out rule); Message = result.GetMessageText(rule, concise: false); ShortMessage = result.GetMessageText(rule, concise: true); FileName = result.GetPrimaryTargetFile(); ProjectName = projectNameCache.GetName(FileName); Category = result.GetCategory(); Region = result.GetPrimaryTargetRegion(); Level = result.Level; SuppressionStates = result.SuppressionStates; LogFilePath = logFilePath; if (Region != null) { LineNumber = Region.StartLine; ColumnNumber = Region.StartColumn; } Tool = run.Tool.ToToolModel(); Rule = rule.ToRuleModel(result.RuleId); Invocation = run.Invocation.ToInvocationModel(); if (string.IsNullOrWhiteSpace(run.Id)) { WorkingDirectory = Path.Combine(Path.GetTempPath(), run.GetHashCode().ToString()); } else { WorkingDirectory = Path.Combine(Path.GetTempPath(), run.Id); } if (result.Locations != null) { foreach (Location location in result.Locations) { Locations.Add(location.ToAnnotatedCodeLocationModel()); } } if (result.RelatedLocations != null) { foreach (AnnotatedCodeLocation annotatedCodeLocation in result.RelatedLocations) { RelatedLocations.Add(annotatedCodeLocation.ToAnnotatedCodeLocationModel()); } } if (result.CodeFlows != null) { foreach (CodeFlow codeFlow in result.CodeFlows) { CallTrees.Add(codeFlow.ToCallTree()); } CallTrees.Verbosity = 100; CallTrees.IntelligentExpand(); } if (result.Stacks != null) { foreach (Stack stack in result.Stacks) { Stacks.Add(stack.ToStackCollection()); } } if (result.Fixes != null) { foreach (Fix fix in result.Fixes) { Fixes.Add(fix.ToFixModel()); } } }
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.ShortMessage, this.Message) = this.SplitMessageText(result.GetMessageText(rule)); if (!this.Message.EndsWith(".")) { this.ShortMessage = this.ShortMessage.TrimEnd('.'); } 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; } 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()); if (result.Locations?.Any() == true) { // Adding in reverse order will make them display in the correct order in the UI. for (int i = result.Locations.Count - 1; i >= 0; --i) { this.Locations.Add(result.Locations[i].ToLocationModel(run, resultId: this.ResultId, runIndex: this.RunIndex)); } } if (result.RelatedLocations?.Any() == true) { for (int i = result.RelatedLocations.Count - 1; i >= 0; --i) { this.RelatedLocations.Add(result.RelatedLocations[i].ToLocationModel(run, resultId: this.ResultId, runIndex: this.RunIndex)); } } if (result.CodeFlows != null) { foreach (CodeFlow codeFlow in result.CodeFlows) { var analysisStep = codeFlow.ToAnalysisStep(run, resultId: this.ResultId, runIndex: this.RunIndex); if (analysisStep != null) { this.AnalysisSteps.Add(analysisStep); } } this.AnalysisSteps.Verbosity = 100; this.AnalysisSteps.IntelligentExpand(); } if (result.Stacks != null) { foreach (Stack stack in result.Stacks) { this.Stacks.Add(stack.ToStackCollection(resultId: this.ResultId, runIndex: this.RunIndex)); } } if (result.Fixes != null) { foreach (Fix fix in result.Fixes) { var fixModel = fix.ToFixModel(run.OriginalUriBaseIds, FileRegionsCache.Instance); this.Fixes.Add(fixModel); } } }
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.ShortMessage, this.Message) = this.SplitMessageText(notification.Message.Text?.Trim() ?? string.Empty); // This is not locale friendly. if (!this.Message.EndsWith(".")) { this.ShortMessage = this.ShortMessage.TrimEnd('.'); } 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()); }
public SarifErrorListItem(Run run, Result result, string logFilePath, ProjectNameCache projectNameCache) : this() { if (!SarifViewerPackage.IsUnitTesting) { #pragma warning disable VSTHRD108 // Assert thread affinity unconditionally ThreadHelper.ThrowIfNotOnUIThread(); #pragma warning restore VSTHRD108 // Assert thread affinity unconditionally } _runId = CodeAnalysisResultManager.Instance.CurrentRunId; ReportingDescriptor rule = result.GetRule(run); Tool = run.Tool.ToToolModel(); Rule = rule.ToRuleModel(result.RuleId); Invocation = run.Invocations?[0]?.ToInvocationModel(); Message = result.GetMessageText(rule, concise: false).Trim(); ShortMessage = result.GetMessageText(rule, concise: true).Trim(); if (!Message.EndsWith(".")) { ShortMessage = ShortMessage.TrimEnd('.'); } FileName = result.GetPrimaryTargetFile(run); ProjectName = projectNameCache.GetName(FileName); Category = result.GetCategory(); Region = result.GetPrimaryTargetRegion(); Level = result.Level != FailureLevel.Warning ? result.Level : Rule.FailureLevel; if (result.Suppressions?.Count > 0) { VSSuppressionState = VSSuppressionState.Suppressed; } LogFilePath = logFilePath; if (Region != null) { LineNumber = Region.StartLine; ColumnNumber = Region.StartColumn; } Tool = run.Tool.ToToolModel(); Rule = rule.ToRuleModel(result.RuleId); Invocation = run.Invocations?[0]?.ToInvocationModel(); WorkingDirectory = Path.Combine(Path.GetTempPath(), _runId.ToString()); if (result.Locations?.Any() == true) { // Adding in reverse order will make them display in the correct order in the UI. for (int i = result.Locations.Count - 1; i >= 0; --i) { Locations.Add(result.Locations[i].ToLocationModel(run)); } } if (result.RelatedLocations?.Any() == true) { for (int i = result.RelatedLocations.Count - 1; i >= 0; --i) { RelatedLocations.Add(result.RelatedLocations[i].ToLocationModel(run)); } } if (result.CodeFlows != null) { foreach (CodeFlow codeFlow in result.CodeFlows) { CallTree callTree = codeFlow.ToCallTree(run); if (callTree != null) { CallTrees.Add(callTree); } } CallTrees.Verbosity = 100; CallTrees.IntelligentExpand(); } if (result.Stacks != null) { foreach (Stack stack in result.Stacks) { Stacks.Add(stack.ToStackCollection()); } } if (result.Fixes != null) { foreach (Fix fix in result.Fixes) { Fixes.Add(fix.ToFixModel()); } } }
public SarifErrorListItem(Run run, Notification notification, string logFilePath, ProjectNameCache projectNameCache) : this() { ThreadHelper.ThrowIfNotOnUIThread(); _runId = CodeAnalysisResultManager.Instance.CurrentRunId; ReportingDescriptor rule; string ruleId = null; if (notification.AssociatedRule != null) { ruleId = notification.AssociatedRule.Id; } else if (notification.Descriptor != null) { ruleId = notification.Descriptor.Id; } run.TryGetRule(ruleId, out rule); Message = notification.Message.Text.Trim(); ShortMessage = ExtensionMethods.GetFirstSentence(notification.Message.Text); if (!Message.EndsWith(".")) { ShortMessage = ShortMessage.TrimEnd('.'); } Level = notification.Level; LogFilePath = logFilePath; FileName = SdkUIUtilities.GetFileLocationPath(notification.Locations?[0]?.PhysicalLocation?.ArtifactLocation, _runId) ?? ""; ProjectName = projectNameCache.GetName(FileName); Locations.Add(new LocationModel() { FilePath = FileName }); Tool = run.Tool.ToToolModel(); Rule = rule.ToRuleModel(ruleId); Invocation = run.Invocations?[0]?.ToInvocationModel(); WorkingDirectory = Path.Combine(Path.GetTempPath(), _runId.ToString()); }
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; } }