coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.97k stars 386 forks source link

When using "is" with "and" in pattern matching, branch coverage is lower than normal #1313

Open Malivil opened 2 years ago

Malivil commented 2 years ago

Package: coverlet.msbuild Version: 3.1.2 Format: opencover

Combining the C#7 is with the C#9 and in a pattern-matching if, branch coverage is lower than the same check in traditional boolean logic.

I created a simple repro of this because I cannot show the actual code that caused the problem (it's from my job).

is + and: image

Traditional: image

Repro code: https://github.com/Malivil/Coverlet1313Repro

daveMueller commented 2 years ago

Thanks for reporting this.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 3 months with no activity.

Malivil commented 1 year ago

Stale, but still an issue

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 3 months with no activity.

Malivil commented 9 months ago

Stale, but still an issue

Bertk commented 7 months ago

@Malivil Please update repo.

Malivil commented 7 months ago

Done, no change

Bertk commented 7 months ago

verify branch coverage for C#9 (MSIL). Should be full coverage for and operator.

C# 9 includes new pattern matching improvements:

  • Type patterns match an object matches a particular type
  • Parenthesized patterns enforce or emphasize the precedence of pattern combinations
  • Conjunctive and patterns require both patterns to match
  • Disjunctive or patterns require either pattern to match
  • Negated not patterns require that a pattern doesn't match
  • Relational patterns require the input be less than, greater than, less than or equal, or greater than or equal to a given constant.