coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.93k stars 385 forks source link

[BUG] Parameter : threshold-stat triggered error #1634

Closed zy8008 closed 3 months ago

zy8008 commented 4 months ago

when build found the following errors with ver 6.0.1 and. netcore6.0:

Unhandled exception. System.ArgumentException: Type Coverlet.Core.Enums.ThresholdStatistic cannot be created without a custom binder.
   at System.CommandLine.Binding.ArgumentConverter.CreateEnumerable(Type type, Type itemType, Int32 capacity)
   at System.CommandLine.Binding.ArgumentConverter.ConvertTokens(Argument argument, Type type, IReadOnlyList`1 tokens, LocalizationResources localizationResources, ArgumentResult argumentResult)
   at System.CommandLine.Binding.ArgumentConverter.TryConvertArgument(ArgumentResult argumentResult, Object& value)
   at System.CommandLine.Parsing.ArgumentResult.Convert(Argument argument)
   at System.CommandLine.Parsing.ArgumentResult.GetArgumentConversionResult()
   at System.CommandLine.Parsing.ParseResultVisitor.ValidateAndConvertArgumentResult(ArgumentResult argumentResult)
   at System.CommandLine.Parsing.ParseResultVisitor.ValidateAndConvertOptionResult(OptionResult optionResult)
   at System.CommandLine.Parsing.ParseResultVisitor.Stop()
   at System.CommandLine.Parsing.ParseResultVisitor.Visit(SyntaxNode node)
   at System.CommandLine.Parsing.Parser.Parse(IReadOnlyList`1 arguments, String rawInput)
   at System.CommandLine.CommandExtensions.GetDefaultInvocationPipeline(Command command, String[] args)
   at System.CommandLine.CommandExtensions.Invoke(Command command, String[] args, IConsole console)
   at Coverlet.Console.Program.Main(String[] args) in /_/src/coverlet.console/Program.cs:line 134

After checking, I found that the reason is due to the following parameters: --threshold-stat total , Restore normal after removing this parameter

Following is full command: coverlet xxxx.Test.dll --target "dotnet" --targetargs "test ./ --no-build" --threshold 80 --threshold-type line --threshold-stat total --format opencover

daveMueller commented 4 months ago

I can confirm the bug. Easy to reproduce just use the command --threshold-stat total.

daveMueller commented 4 months ago

I'll work on it as I already nearly have the PR ready.

daveMueller commented 3 months ago

Hi guys, we finally merged everything we broke with the last release including this issue. We would really appreciate if someone could give it a try. Here is how to consume the nightly: https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md

daveMueller commented 3 months ago

We now have a new official release 6.0.2 that can be consumed from nuget.org.

zy8008 commented 3 months ago

It's work ok on 6.0.2, thanks alot!