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;
        }
Exemple #2
0
        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());
        }