I've been updating Cake to be .NET Standard 2.0 and run on netcoreapp2.0 here: https://github.com/cake-build/cake/pull/1812
There was a battery of XML tests that were full framework only that I enabled for netstandard2.0 because they now exist on that footprint. There's one problem test that works still on net46/net461 but not on netcoreapp2.0
[Fact]
public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration()
{
// Given
var xml = Resources.XmlTransformation_Xml;
var xsl = Resources.XmlTransformation_Xsl;
var settings = new XmlTransformationSettings
{
Encoding = new UTF32Encoding(false, false, true)
};
// When
var result = string.Concat(XmlTransformation.Transform(xsl, xml, settings).Take(39));
// Then
Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-32\"?>", result);
}
I can't tell if it's just an issue with UTF32Encoding (I don't believe so) or something else in the XML Transform.
Can you please isolate the test case from your infra? Make it a standalone app which compiles (incl. Resources). What is the output you get on .NET Core 2.0?
Sorry yes. It was more tied to Cake than I realized:
https://github.com/adamhathcock/utf32bug
The error I get:
utf32bug.UnitTest1.Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration
Assert.Equal() Failure
↓ (pos 0)
Expected: <?xml version="1.0" encoding="utf-32"?>
Actual: <?xml version="1.0" encoding="utf-32"?
↑ (pos 0)
at utf32bug.UnitTest1.Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration() in /Users/adam/git/personal/utf32bug/UnitTest1.cs:line 48
Actual seems to have the BOM (the error message lines up better in Rider)
Thank you for repro @adamhathcock
@adamhathcock You're right, something in the XmlWriter.Create(result, settings); call is writing the BOM to the MemoryStream, in your repro on netcoreapp2.0.
@karelz I would like to pick up this issue. I have identified the bug and have a initial fix for it. However, I'm not sure it's the most elegant fix. I'm also not sure where the test(s) should go since the bug is in CoreLib.
Great, thanks for help! Assigned to you.
I would follow pattern of other tests for sibling methods. In general, most of the CoreFX tests are in CoreFX repo, even if the code lives in CoreCLR. @krwq @pjanotti will be able to say for sure.
@clarkis117, do not worry if it is not super elegant - we can give some recommendations during the code review - correctness is more important. Thank you for investigating this! (please cc us on the code review)
Most helpful comment
Sorry yes. It was more tied to Cake than I realized:
https://github.com/adamhathcock/utf32bug
The error I get:
Actual seems to have the BOM (the error message lines up better in Rider)