From 9ee7b8fbe4b8f5963405c47d10d7fb6eb8eb80c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20M=C3=BCller?= Date: Mon, 26 Feb 2024 08:50:34 +0100 Subject: [PATCH] Broken exclude-by-attribute feature in `coverlet.console` (#1627) --- Documentation/Changelog.md | 12 ++++++++++++ Documentation/GlobalTool.md | 8 +++++++- src/coverlet.console/Program.cs | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index 22edce12a..18851252f 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed +- Exception when multiple exclude-by-attribute filters specified [#1624](https://github.com/coverlet-coverage/coverlet/issues/1624) + +### Improvements +- More concise options to specify multiple parameters in coverlet.console [#1624](https://github.com/coverlet-coverage/coverlet/issues/1624) + +## Release date 2024-02-19 +### Packages +coverlet.msbuild 6.0.1 +coverlet.console 6.0.1 +coverlet.collector 6.0.1 + ### Fixed - Uncovered lines in .NET 8 for inheriting records [#1555](https://github.com/coverlet-coverage/coverlet/issues/1555) - Fix record constructors not covered when SkipAutoProps is true [#1561](https://github.com/coverlet-coverage/coverlet/issues/1561) diff --git a/Documentation/GlobalTool.md b/Documentation/GlobalTool.md index 4b3d2ab33..9627167d0 100644 --- a/Documentation/GlobalTool.md +++ b/Documentation/GlobalTool.md @@ -42,12 +42,18 @@ Options: -?, -h, --help Show help and usage information ``` -NB. For a [multiple value] options you have to specify values multiple times i.e. +NB. For [multiple value] options you can either specify values multiple times i.e. ```shell --exclude-by-attribute 'Obsolete' --exclude-by-attribute 'GeneratedCode' --exclude-by-attribute 'CompilerGenerated' ``` +or pass the multiple values as space separated sequence, i.e. + +```shell +--exclude-by-attribute "Obsolete" "GeneratedCode" "CompilerGenerated" +``` + For `--merge-with` [check the sample](Examples.md). ## Code Coverage diff --git a/src/coverlet.console/Program.cs b/src/coverlet.console/Program.cs index 8782747a9..2a4684244 100644 --- a/src/coverlet.console/Program.cs +++ b/src/coverlet.console/Program.cs @@ -40,7 +40,7 @@ static int Main(string[] args) var includeFilters = new Option("--include", "Filter expressions to include only specific modules and types.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; var excludedSourceFiles = new Option("--exclude-by-file", "Glob patterns specifying source files to exclude.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; var includeDirectories = new Option("--include-directory", "Include directories containing additional assemblies to be instrumented.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; - var excludeAttributes = new Option("--exclude-by-attribute", "Attributes to exclude from code coverage.") { Arity = ArgumentArity.ZeroOrOne, AllowMultipleArgumentsPerToken = true }; + var excludeAttributes = new Option("--exclude-by-attribute", "Attributes to exclude from code coverage.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true }; var includeTestAssembly = new Option("--include-test-assembly", "Specifies whether to report code coverage of the test assembly.") { Arity = ArgumentArity.Zero }; var singleHit = new Option("--single-hit", "Specifies whether to limit code coverage hit reporting to a single hit for each location") { Arity = ArgumentArity.Zero }; var skipAutoProp = new Option("--skipautoprops", "Neither track nor record auto-implemented properties.") { Arity = ArgumentArity.Zero };