-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
XslCompiledTransform doesn't work when using TrimMode=link #45393
Comments
Tagging subscribers to this area: @buyaa-n, @krwq, @jeffhandley Issue DetailsSee the original report of this issue: #44995 (comment) Run the following code in a Blazor WASM published app. Or in a console app that is PublishTrimmed=true && TrimMode=link public static void UseXsl()
{
using (StringReader text = new StringReader(
@"<?xml version=""1.0"" encoding=""UTF-8""?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>"))
{
XPathDocument myXPathDoc = new XPathDocument(text);
XslCompiledTransform myXslTrans = new XslCompiledTransform();
string xmlStr = @"<?xml version=""1.0""?>
<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>
<xsl:for-each select = ""catalog/cd"">
<tr>
<td><xsl:value-of select = ""title"" /></td>
<td><xsl:value-of select = ""artist"" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>";
using (StringReader str = new StringReader(xmlStr))
using (var reader = System.Xml.XmlReader.Create(str))
{
myXslTrans.Load(reader);
StringWriter myWriter = new StringWriter();
myXslTrans.Transform(myXPathDoc, null, myWriter);
Console.WriteLine(myWriter.GetStringBuilder().ToString());
}
}
} Expected resultsThe code should work the same way it does in a non-trimmed app. Actual results
It looks like the following code needs to be annotated correctly for the ILLinker to preserve the constructors correctly: runtime/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs Lines 135 to 159 in aebd598
Side-note: The ILLink warnings caught this as well: runtime/src/libraries/System.Private.Xml/src/ILLink/ILLink.Suppressions.xml Lines 130 to 141 in aebd598
|
Resolve ILLinker warnings in Xml.Xsl in order to make a basic Xslt scenario work. Fix dotnet#45393
Resolve ILLinker warnings in Xml.Xsl in order to make a basic Xslt scenario work. Fix #45393
See the original report of this issue: #44995 (comment)
Run the following code in a Blazor WASM published app. Or in a console app that is PublishTrimmed=true && TrimMode=link
Expected results
The code should work the same way it does in a non-trimmed app.
Actual results
It looks like the following code needs to be annotated correctly for the ILLinker to preserve the constructors correctly:
runtime/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/GenerateHelper.cs
Lines 135 to 159 in aebd598
Side-note: The ILLink warnings caught this as well:
runtime/src/libraries/System.Private.Xml/src/ILLink/ILLink.Suppressions.xml
Lines 130 to 141 in aebd598
The text was updated successfully, but these errors were encountered: