Open manuelamateo opened 2 years ago
Thanks for reporting this. 👍
I debugged into this once for another issue https://github.com/coverlet-coverage/coverlet/issues/1279 that might be related but I couldn't find the issue back then. I debugged into this issue here and ended up at the same place. I think our algorithem that detects branches still has an issue somewhere here CecilSymbolHelper.BuildPointsForConditionalBranch(...)
. Unfortunately this requires a lot of knowledge about IL and thus it's hard to find the issue.
I'm currently short on time but I will dig into this again. Also every contribution and additional information that helps to fix this bug is highly appreciated.
What I additonally found out that this issue doesn`t occur with 3 connected conditions.
When returning two logically connected conditions, then the branch and line coverages are not consistent. To reproduce this, certain conditions must be met:
I tried different implementations for this simple task and found four different code coverages. I'm not sure which one is the bug. Interestingly if instead of the first condition the second condition is never true, then the coverage of the different implementations are consistent.
See reproduction https://github.com/meggima/coverlet-reproductions TwoConditionsBranchCoverageReproduction.cs & TwoConditionsBranchCoverageReproductionFixture.cs (Version coverlet.msbuild 3.1.2)