예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MsBuildIssuesProvider"/> class.
        /// </summary>
        /// <param name="log">The Cake log context.</param>
        /// <param name="settings">Settings for reading the log file.</param>
        public MsBuildIssuesProvider(ICakeLog log, MsBuildIssuesSettings settings)
            : base(log)
        {
            settings.NotNull(nameof(settings));

            this.msBuildIssuesSettings = settings;
        }
예제 #2
0
        public static IIssueProvider MsBuildIssues(
            this ICakeContext context,
            MsBuildIssuesSettings settings)
        {
            context.NotNull(nameof(context));
            settings.NotNull(nameof(settings));

            return(new MsBuildIssuesProvider(context.Log, settings));
        }
예제 #3
0
        /// <inheritdoc/>
        public override IEnumerable <IIssue> ReadIssues(
            RepositorySettings repositorySettings,
            MsBuildIssuesSettings msBuildIssuesSettings)
        {
            repositorySettings.NotNull(nameof(repositorySettings));
            msBuildIssuesSettings.NotNull(nameof(msBuildIssuesSettings));

            var result = new List <IIssue>();

            var logDocument = XDocument.Parse(msBuildIssuesSettings.LogFileContent);

            // Loop through all warning tags.
            foreach (var warning in logDocument.Descendants("warning"))
            {
                // Read affected file from the warning.
                if (!this.TryGetFile(warning, repositorySettings, out string fileName))
                {
                    continue;
                }

                // Read affected line from the warning.
                if (!TryGetLine(warning, out var line))
                {
                    continue;
                }

                // Read rule code from the warning.
                if (!TryGetRule(warning, out string rule))
                {
                    continue;
                }

                result.Add(new Issue <MsBuildIssuesProvider>(
                               fileName,
                               line,
                               warning.Value,
                               0,
                               rule,
                               MsBuildRuleUrlResolver.Instance.ResolveRuleUrl(rule)));
            }

            return(result);
        }