Under very particular cirsumstances, the coverage statistics reported by NCover v3.0.22 and earlier can be incorrect. However, the circumstances are very particular, and they do not apply to most coverage situations. Moreover, only the Symbol Coverage and Branch Coverage metrics were affected, the Method Coverage and Cyclomatic Complexity statistics were not affected. For NCover v3.0.22 and eariler, the Symbol Coverage and Branch Coverage statistics can be incorrect when
- An assembly is loaded and instrumented multiple times. This most likely happens because it was loaded by multiple processes, which can happen when the //pm argument is used.
- A symbol coverage point and a branch coverage point are at the same location in a method's Intermediate Language. This isn't terribly common, but can happen if you have code that looks like
{ // some code here { // more code here }
{` Whether the points are at the same location or not also depends on how complicated the boolean expression in the if-else is and how the compiler decides to optimize the generated IL, so the points are more likely to be at the same location in Release builds than they are in Debug builds.
If all of the above is true and a Symbol Coverage point and a Branch Coverage point are at the same location, then the visit count for one of them will be incorrect after NCover finishes gathering and processing the coverage data from all covered processes. Which point's visit count is incorrect is unpredictable, so there is no way to go back and fix the data after it has been persisted to disk. However, the problem has been fixed in version after NCover v3.0.22, and tests were written to prevent it from happening again.