Skip to content

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
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
@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