Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoverageFileUtility.ConvertCoverageFile is culture depended #63

Closed
martin-strecker-sonarsource opened this issue Nov 2, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@martin-strecker-sonarsource

Version used

Microsoft.CodeCoverage.IO 17.7.0 https://www.nuget.org/packages/Microsoft.CodeCoverage.IO/17.7.0

Steps to reproduce

  1. Take a binary coverage file like this one: Sample.coverage
  2. Convert on a machine with a culture that has a decimal separator different from . like "de-DE".
using Microsoft.CodeCoverage.IO;
using System.Globalization;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var culture = CultureInfo.CreateSpecificCulture("de-DE"); // change this to "en-US" to get the expected outcome
            CultureInfo.DefaultThreadCurrentCulture = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;
            new CoverageFileUtility().ConvertCoverageFile(
                path: "Sample.coverage",
                outputPath: "Sample.xmlcoverage",
                includeSkippedFunctions: false,
                includeSkippedModules: false);
        }
    }
}

Expected output

The Sample.xmlcoverage is serialized in a culture-neutral manner, e.g. block_coverage="33.33":

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results>
  <modules>
    <module block_coverage="33.33" line_coverage="25.00" blocks_covered="1" blocks_not_covered="2" lines_covered="1" lines_partially_covered="0" lines_not_covered="3" name="consoleapp2.dll" path="consoleapp2.dll" 

Actual output

The Sample.xmlcoverage contains , as decimal separator block_coverage="33,33":

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<results>
  <modules>
    <module block_coverage="33,33" line_coverage="25,00" blocks_covered="1" blocks_not_covered="2" lines_covered="1" lines_partially_covered="0" lines_not_covered="3" name="consoleapp2.dll" path="consoleapp2.dll" 
@mariam-abdulla
Copy link
Contributor

This bug has been fixed, it will be available in the upcoming release.

@costin-zaharia-sonarsource

Hi @mariam-abdulla, do you have an ETA for the next release?

@mariam-abdulla
Copy link
Contributor

Hi @costin-zaharia-sonarsource,
Visual Studio 17.9 has already been released on 13th February.

@costin-zaharia-sonarsource

Hi @mariam-abdulla, We are using https://www.nuget.org/packages/Microsoft.CodeCoverage.IO, which includes CoverageFileUtility.ConvertCoverageFile, and we're interested in its release date.

@jakubch1
Copy link
Member

@costin-zaharia-sonarsource @martin-strecker-sonarsource generally we recommend using dotnet-coverage merge to convert 1 report to another. You can find example here: https://learn.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-coverage#merge-code-coverage-reports

Microsoft.CodeCoverage.IO is deprecated.

If you want to continue using direct approach you can try to use: CoverageFileUtilityV2 in https://dev.azure.com/dnceng/public/_artifacts/feed/test-tools/NuGet/Microsoft.CodeCoverage.Core/overview/17.10.3
Keep in mind that package is internal and you are using it on your own risk. We can easily break contract in upcoming releases.

@costin-zaharia-sonarsource

Hi @jakubch1, thanks for the links. We will probably go with the internal package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants