diff --git a/README.md b/README.md index 06b586b..7ef3169 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,11 @@ and for general information about the Cake build automation system see the [Cake ## Quick Links - [Documentation](https://cakeissues.net) +## Discussion -## Chat Room +For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category. -Come join in the conversation about this addin in our Gitter Chat Room. - -[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions) ## Contributing diff --git a/nuspec/nuget/Cake.Issues.MsBuild.nuspec b/nuspec/nuget/Cake.Issues.MsBuild.nuspec index 25940d5..1cc9205 100644 --- a/nuspec/nuget/Cake.Issues.MsBuild.nuspec +++ b/nuspec/nuget/Cake.Issues.MsBuild.nuspec @@ -23,8 +23,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin false Copyright © BBT Software AG and contributors - Cake Script Cake-Issues Cake-IssueProvider CodeAnalysis Linting MsBuild - https://github.com/cake-contrib/Cake.Issues.MsBuild/releases/tag/0.9.1 + cake cake-addin cake-issues cake-issueprovider code-analysis linting msbuild + https://github.com/cake-contrib/Cake.Issues.MsBuild/releases/tag/1.0.0 diff --git a/nuspec/nuget/icon.png b/nuspec/nuget/icon.png index 9881edc..84c2a82 100644 Binary files a/nuspec/nuget/icon.png and b/nuspec/nuget/icon.png differ diff --git a/recipe.cake b/recipe.cake index 2bac329..96a0965 100644 --- a/recipe.cake +++ b/recipe.cake @@ -20,7 +20,7 @@ BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings( context: Context, dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.MsBuild.Tests/**/*.cs", BuildParameters.RootDirectoryPath + "/src/Cake.Issues.MsBuild*/**/*.AssemblyInfo.cs" }, - testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Shouldly]* -[Microsoft.Build*]* -[StructuredLogger]*", + testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Shouldly]* -[Microsoft.Build*]* -[StructuredLogger]* -[DiffEngine]* -[EmptyFiles]*", testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); diff --git a/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj b/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj index 4b7f17e..cdc681a 100644 --- a/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj +++ b/src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj @@ -24,12 +24,12 @@ - - - - - - + + + + + + diff --git a/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj b/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj index 1281692..0af0f07 100644 --- a/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj +++ b/src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj @@ -12,6 +12,7 @@ full true + AllEnabledByDefault ..\Cake.Issues.MsBuild.ruleset true @@ -25,9 +26,12 @@ - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs b/src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs index 72c323c..0642180 100644 --- a/src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs +++ b/src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs @@ -108,6 +108,8 @@ private IIssue GetIssue( MsBuildIssuesProvider issueProvider, IRepositorySettings repositorySettings) { + this.Log.Verbose("Process error '{0}'...", buildError.Message); + return this.GetIssue( IssuePriority.Error, @@ -135,6 +137,8 @@ private IIssue GetIssue( MsBuildIssuesProvider issueProvider, IRepositorySettings repositorySettings) { + this.Log.Verbose("Process warning '{0}'...", buildWarning.Message); + return this.GetIssue( IssuePriority.Warning, @@ -181,6 +185,7 @@ private IIssue GetIssue( // Ignore warnings or errors without a message. if (string.IsNullOrWhiteSpace(message)) { + this.Log.Verbose("Skip element since it doesn't contain a message"); return null; } @@ -190,6 +195,7 @@ private IIssue GetIssue( var (result, fileName) = this.TryGetFile(file, projectFile, repositorySettings); if (!result) { + this.Log.Information("Skip element since file path could not be parsed"); return null; } diff --git a/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs b/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs index cd0a808..fa750cc 100644 --- a/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs +++ b/src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs @@ -50,39 +50,47 @@ public override IEnumerable ReadIssues( foreach (var element in elements) { + this.Log.Verbose("Process element '{0}'...", element); + // Ignore warnings or errors without a message. if (string.IsNullOrWhiteSpace(element.Value)) { + this.Log.Verbose("Skip element since it doesn't contain a message"); continue; } // Read affected project from the warning or error. if (!this.TryGetProject(element, repositorySettings, out string projectFileRelativePath)) { + this.Log.Information("Skip element since project could not be parsed"); continue; } // Read affected file from the warning or error. if (!this.TryGetFile(element, repositorySettings, out string fileName)) { + this.Log.Information("Skip element since file path could not be parsed"); continue; } // Read affected line from the warning or error. - if (!TryGetLine(element, out var line)) + if (!this.TryGetLine(element, out var line)) { + this.Log.Information("Skip element since line could not be parsed"); continue; } // Read affected column from the warning or error. - if (!TryGetColumn(element, out var column)) + if (!this.TryGetColumn(element, out var column)) { + this.Log.Information("Skip element since column could not be parsed"); continue; } // Read rule code from the warning or error. - if (!TryGetRule(element, out string rule)) + if (!this.TryGetRule(element, out string rule)) { + this.Log.Information("Skip element since rule could not be parsed"); continue; } @@ -109,83 +117,6 @@ public override IEnumerable ReadIssues( return result; } - /// - /// Reads the affected line from a warning or error logged in a MsBuild log. - /// - /// Warning or error element from MsBuild log. - /// Returns line. - /// True if the line could be parsed. - private static bool TryGetLine(XElement element, out int? line) - { - line = null; - - var lineAttr = element.Attribute("line"); - - var lineValue = lineAttr?.Value; - if (string.IsNullOrWhiteSpace(lineValue)) - { - return false; - } - - line = int.Parse(lineValue, CultureInfo.InvariantCulture); - - // Convert negative line numbers or line number 0 to null - if (line <= 0) - { - line = null; - } - - return true; - } - - /// - /// Reads the affected column from a warning or error logged in a MsBuild log. - /// - /// Warning or error element from MsBuild log. - /// Returns column. - /// True if the column could be parsed. - private static bool TryGetColumn(XElement element, out int? column) - { - column = null; - - var columnAttr = element.Attribute("column"); - - var columnValue = columnAttr?.Value; - if (string.IsNullOrWhiteSpace(columnValue)) - { - return false; - } - - column = int.Parse(columnValue, CultureInfo.InvariantCulture); - - // Convert negative column numbers or column number 0 to null - if (column <= 0) - { - column = null; - } - - return true; - } - - /// - /// Reads the rule code from a warning or error logged in a MsBuild log. - /// - /// Warning or error element from MsBuild log. - /// Returns the code of the rule. - /// True if the rule code could be parsed. - private static bool TryGetRule(XElement error, out string rule) - { - var codeAttr = error.Attribute("code"); - if (codeAttr == null) - { - rule = null; - return true; - } - - rule = codeAttr.Value; - return !string.IsNullOrWhiteSpace(rule); - } - /// /// Determines the project for a warning or error logged in a MsBuild log. /// @@ -203,18 +134,21 @@ private bool TryGetProject( var projectNode = element.Ancestors("project").FirstOrDefault(); if (projectNode == null) { + this.Log.Information("Project not found for element '{0}'", element); return true; } var projectAttr = projectNode.Attribute("file"); if (projectAttr == null) { + this.Log.Information("File not found for element '{0}'", element); return true; } project = projectAttr.Value; if (string.IsNullOrWhiteSpace(project)) { + this.Log.Information("Project path not found for element '{0}'", element); return true; } @@ -241,12 +175,14 @@ private bool TryGetFile( var fileAttr = element.Attribute("file"); if (fileAttr == null) { + this.Log.Verbose("File attribute not found for element '{0}'", element); return true; } fileName = fileAttr.Value; if (string.IsNullOrWhiteSpace(fileName)) { + this.Log.Information("File path not found for element '{0}'", element); return true; } @@ -270,5 +206,85 @@ private bool TryGetFile( (result, fileName) = this.ValidateFilePath(fileName, repositorySettings); return result; } + + /// + /// Reads the affected line from a warning or error logged in a MsBuild log. + /// + /// Warning or error element from MsBuild log. + /// Returns line. + /// True if the line could be parsed. + private bool TryGetLine(XElement element, out int? line) + { + line = null; + + var lineAttr = element.Attribute("line"); + + var lineValue = lineAttr?.Value; + if (string.IsNullOrWhiteSpace(lineValue)) + { + return false; + } + + line = int.Parse(lineValue, CultureInfo.InvariantCulture); + + // Convert negative line numbers or line number 0 to null + if (line <= 0) + { + this.Log.Information("Ignore value {0} since it is outside of the allowed range for line property.", line); + line = null; + } + + return true; + } + + /// + /// Reads the affected column from a warning or error logged in a MsBuild log. + /// + /// Warning or error element from MsBuild log. + /// Returns column. + /// True if the column could be parsed. + private bool TryGetColumn(XElement element, out int? column) + { + column = null; + + var columnAttr = element.Attribute("column"); + + var columnValue = columnAttr?.Value; + if (string.IsNullOrWhiteSpace(columnValue)) + { + return false; + } + + column = int.Parse(columnValue, CultureInfo.InvariantCulture); + + // Convert negative column numbers or column number 0 to null + if (column <= 0) + { + this.Log.Information("Ignore value {0} since it is outside of the allowed range for column property.", column); + column = null; + } + + return true; + } + + /// + /// Reads the rule code from a warning or error logged in a MsBuild log. + /// + /// Warning or error element from MsBuild log. + /// Returns the code of the rule. + /// True if the rule code could be parsed. + private bool TryGetRule(XElement element, out string rule) + { + var codeAttr = element.Attribute("code"); + if (codeAttr == null) + { + this.Log.Verbose("code attribute not found for element '{0}'", element); + rule = null; + return true; + } + + rule = codeAttr.Value; + return !string.IsNullOrWhiteSpace(rule); + } } }