public IssueAnnotationsProvider( IIssueAnnotationFormatter formatter, IIssueAnnotationSerializer serializer) { _formatter = formatter; _serializer = serializer; }
/// <summary> /// Parses <see cref="IssueAnnotation"/> from the specified text. /// </summary> /// <param name="formatter">The formatter.</param> /// <param name="text">The text.</param> /// <returns> /// Parsed entity. /// </returns> public IssueAnnotation[] Deserialize(IIssueAnnotationFormatter formatter, string[] text) { var result = new List <IssueAnnotation>(); for (var lineIndex = 0; lineIndex < text.Length; lineIndex++) { var contentLine = text[lineIndex]; if (!formatter.DoesItStartRight(contentLine)) { continue; } var match = AnnotationRegex.Match(formatter.Deformat(contentLine)); if (!match.Success) { continue; } var line = lineIndex + 1; var additionalСontent = string.Empty; while ((lineIndex < text.Length) && formatter.DoesItStartRight(text[lineIndex + 1])) { lineIndex++; additionalСontent += "\n" + formatter.Deformat(text[lineIndex]); } IssueAnnotationState state; try { state = _stateSerializer.Deserialize(match.Groups["marker"].Value); } catch (ArgumentException) { _logger.Error( Resources.IssueAnnotationSerializer_Deserialize_Wrong_marker_found.FormatWith(match.Groups["marker"].Value)); continue; } result.Add( new IssueAnnotation { AdditionalContent = additionalСontent, Id = match.Groups["id"].Value, IssuePath = match.Groups["url"].Value, LineStart = line, LongName = match.Groups["longName"].Value, State = state, Severity = match.Groups["severity"].Value, LineEnd = lineIndex + 1 }); } return(result.ToArray()); }
public SaveToVcsPostProcessingStage( [NotNull] IIssueAnnotationFormatter issueAnnotationFormatter, [NotNull] IIssueAnnotationSerializer issueAnnotationSerializer, [NotNull] IBranchNameBuilder branchNameBuilder, [NotNull] ILog log, [NotNull] IVulnerabilityShortTypeResolver vulnerabilityShortTypeResolver, [NotNull] ITemplateProvider templateProvider, [NotNull] ITelemetryScopeProvider telemetryScopeProvider) { if (issueAnnotationFormatter == null) { throw new ArgumentNullException(nameof(issueAnnotationFormatter)); } if (issueAnnotationSerializer == null) { throw new ArgumentNullException(nameof(issueAnnotationSerializer)); } if (branchNameBuilder == null) { throw new ArgumentNullException(nameof(branchNameBuilder)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } if (vulnerabilityShortTypeResolver == null) { throw new ArgumentNullException(nameof(vulnerabilityShortTypeResolver)); } if (templateProvider == null) { throw new ArgumentNullException(nameof(templateProvider)); } if (telemetryScopeProvider == null) { throw new ArgumentNullException(nameof(telemetryScopeProvider)); } _issueAnnotationFormatter = issueAnnotationFormatter; _issueAnnotationSerializer = issueAnnotationSerializer; _branchNameBuilder = branchNameBuilder; _log = log; _vulnerabilityShortTypeResolver = vulnerabilityShortTypeResolver; _templateProvider = templateProvider; _telemetryScopeProvider = telemetryScopeProvider; }