Code coverage for dotnet records without primary constructors

We are seeing that c# records that do not use a primary constructor are being shown as receiving no code coverage, when the rest of the record is clearly used and tested.


I can’t work out what sort of test would stop this line from being uncovered. Other tools that show coverage do not even look for that line to be covered.

Hey there.

SonarCloud relies on the coverage report being imported to decide whether or not that code can be covered by tests.

If you look at the raw test report you’re importing to SonarCloud, is that line being referenced as uncovered?

Thanks, I’d assumed it was sonarcloud because the in IDE code coverage wasn’t showing the line as a problem but you are right it’s the xml.

I’ve tracked the problem down to this ticket for anyone else interested, Treat records equal to classes · Issue #1576 · coverlet-coverage/coverlet · GitHub, hopefully it’s resolved soon.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.