Issue Description
See https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/349706.
When XmlReader.Create is called and a file path is passed in, it's converted to a URI under the hood. This can mangle multi-byte characters. The solution (in the link above) is to initialize the XmlReader using a stream to the file instead of the path alone.
Note this isn't an issue that we know of yet, the repro steps would fail if they were.
Steps to Reproduce
create dir with 啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵 as part of the path
dotnet new console -o proj
create transform.xslt in proj dir, copy contents from below
add foo target (below) to proj
msbuild proj
should see success
Foo target:
<Target Name="Foo" AfterTargets="Build">
<XslTransformation XslInputPath="transform.xslt" XmlInputPaths="$(MSBuildThisFileFullPath)"
OutputPaths="$(IntermediateOutputPath)output.xml"
Parameters="<Parameter Name='Parameter1' Value='$(Parameter1)'/>" />
</Target>
transform.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of select="catalog/cd/title"/></td>
<td><xsl:value-of select="catalog/cd/artist"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Build succeeds.
Analysis
This isn't an issue yet, but could be down the line.
Our code calls XmlReader.Create in two locations within the XslTransformation class which can be changed easily.
The complication comes from XmlReaderExtension, which initializes an XmlReader via new XmlTextReader(...) and a path is passed in. We should avoid this and call .Create() passing in a stream, but this comment suggests that would be a breaking change:
// Ignore loadAsReadOnly for now; using XmlReader.Create results in whitespace changes
// of attribute text, specifically newline removal.
// https://github.com/Microsoft/msbuild/issues/4210
#4210 is something @ladipro had worked on so you might have a better idea of what to do here. Thoughts?
benvillalobos@6943a55 was my proposed fix before digging into #4210
Issue Description
See https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/349706.
When XmlReader.Create is called and a file path is passed in, it's converted to a URI under the hood. This can mangle multi-byte characters. The solution (in the link above) is to initialize the XmlReader using a stream to the file instead of the path alone.
Note this isn't an issue that we know of yet, the repro steps would fail if they were.
Steps to Reproduce
create dir with
啊阿鼾齄丂丄狚狛狜狝﨨﨩ˊˋ˙–⿻〇㐀㐁䶴䶵as part of the pathdotnet new console -o projcreate transform.xslt in proj dir, copy contents from below
add foo target (below) to proj
msbuild projshould see success
Foo target:
Build succeeds.
Analysis
This isn't an issue yet, but could be down the line.
Our code calls XmlReader.Create in two locations within the XslTransformation class which can be changed easily.
The complication comes from XmlReaderExtension, which initializes an XmlReader via
new XmlTextReader(...)and a path is passed in. We should avoid this and call.Create()passing in a stream, but this comment suggests that would be a breaking change:#4210 is something @ladipro had worked on so you might have a better idea of what to do here. Thoughts?
benvillalobos@6943a55 was my proposed fix before digging into #4210