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

create XML coverage file without BOM #1604

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

Bertk
Copy link
Collaborator

@Bertk Bertk commented Jan 30, 2024

UTF-8. The UTF-8 representation of the BOM is the (hexadecimal) byte sequence EF BB BF . The Unicode Standard permits the BOM in UTF-8, but does not require or recommend its use.

closes #1602

@Bertk Bertk marked this pull request as ready for review January 30, 2024 15:37
src/coverlet.collector/Utilities/FileHelper.cs Outdated Show resolved Hide resolved
src/coverlet.core/Reporters/CoberturaReporter.cs Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to add a unit test for reports without BOM? So that somebody else who might work on this knows that we do this for a reason. Sth. like:

[Fact]
public void CoberturaTestReportDoesNotContainBom()
{
  var result = new CoverageResult { Parameters = new CoverageParameters(), Identifier = Guid.NewGuid().ToString() };
  var documents = new Documents();
  var classes = new Classes { { "Class", new Methods() } };

  documents.Add(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:\doc.cs" : @"/doc.cs", classes);

  result.Modules = new Modules { { "Module", documents } };

  var reporter = new CoberturaReporter();
  string report = reporter.Report(result, new Mock<ISourceRootTranslator>().Object);

  byte[] preamble = Encoding.UTF8.GetBytes(report)[..3];
  Assert.NotEqual(Encoding.UTF8.GetPreamble(), preamble);
}

@Bertk Bertk self-assigned this Feb 1, 2024
@daveMueller daveMueller merged commit 9321d2e into coverlet-coverage:master Feb 1, 2024
8 checks passed
@Bertk Bertk deleted the xml-without-bom branch February 2, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] cobertura.XML receives an unwanted BOM
2 participants