diff --git a/CodeConverter/CSharp/XmlExpressionConverter.cs b/CodeConverter/CSharp/XmlExpressionConverter.cs index a906d46b..fb847558 100644 --- a/CodeConverter/CSharp/XmlExpressionConverter.cs +++ b/CodeConverter/CSharp/XmlExpressionConverter.cs @@ -64,10 +64,10 @@ public async Task ConvertXmlAttributeAsync(VBasic.Syntax.XmlAt } public async Task ConvertXmlStringAsync(VBasic.Syntax.XmlStringSyntax node) => - CommonConversions.Literal(string.Join("", node.TextTokens.Select(b => b.Text))); + CommonConversions.Literal(string.Join("", node.TextTokens.Select(b => b.ValueText))); public async Task ConvertXmlTextAsync(VBSyntax.XmlTextSyntax node) => - CommonConversions.Literal(string.Join("", node.TextTokens.Select(b => b.Text))); + CommonConversions.Literal(string.Join("", node.TextTokens.Select(b => b.ValueText))); public async Task ConvertXmlCDataSectionAsync(VBSyntax.XmlCDataSectionSyntax node) { diff --git a/Tests/CSharp/ExpressionTests/XmlExpressionTests.cs b/Tests/CSharp/ExpressionTests/XmlExpressionTests.cs index d059ca7c..4df33592 100644 --- a/Tests/CSharp/ExpressionTests/XmlExpressionTests.cs +++ b/Tests/CSharp/ExpressionTests/XmlExpressionTests.cs @@ -120,26 +120,13 @@ private void TestMethod() new XElement(""Author"", ""Garghentini, Davide""), new XElement(""Title"", ""XML Developer's Guide""), new XElement(""Price"", ""44.95""), - new XElement(""Description"", @"" - An in-depth look at creating applications - with "", new XElement(""technology"", ""XML""), @"". For - "", new XElement(""audience"", ""beginners""), @"" or - "", new XElement(""audience"", ""advanced""), @"" developers. - "") + new XElement(""Description"", ""\n An in-depth look at creating applications\n with "", new XElement(""technology"", ""XML""), "". For\n "", new XElement(""audience"", ""beginners""), "" or\n "", new XElement(""audience"", ""advanced""), "" developers.\n "") ), new XElement(""Book"", new XAttribute(""id"", ""bk331""), new XElement(""Author"", ""Spencer, Phil""), new XElement(""Title"", ""Developing Applications with Visual Basic .NET""), new XElement(""Price"", ""45.95""), - new XElement(""Description"", @"" - Get the expert insights, practical code samples, - and best practices you need - to advance your expertise with "", new XElement(""technology"", @""Visual - Basic .NET""), @"". - Learn how to create faster, more reliable applications - based on professional, - pragmatic guidance by today's top "", new XElement(""audience"", ""developers""), @"". - "") + new XElement(""Description"", ""\n Get the expert insights, practical code samples,\n and best practices you need\n to advance your expertise with "", new XElement(""technology"", ""Visual\n Basic .NET""), "".\n Learn how to create faster, more reliable applications\n based on professional,\n pragmatic guidance by today's top "", new XElement(""audience"", ""developers""), "".\n "") ) ) @@ -373,19 +360,9 @@ internal partial class TestClass { private void TestMethod() { - string processedHtml = new XCData(@"" - - - - - </head> - <body> - <p class=""""cs95E872D0""""><span class=""""cs9D249CCB""""> Regards,</span></p> - </body> -</html> - "").Value; + string processedHtml = new XCData(""\n<!DOCTYPE html PUBLIC \""-//W3C//DTD XHTML 1.0 Transitional//EN\"" \""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"">\n<html xmlns=\""http://www.w3.org/1999/xhtml\"">\n\t<head>\n\t\t<meta http-equiv=\""Content-Type\"" content=\""text/html; charset=utf-8\"" /><title>\n\t</head>\n\t<body>\n\t\t<p class=\""cs95E872D0\""><span class=\""cs9D249CCB\""> Regards,</span></p>\n </body>\n</html>\n "").Value; } -}"); +}", incompatibleWithAutomatedCommentTesting: true); } } \ No newline at end of file diff --git a/Tests/CSharp/ExpressionTests/XmlExpressionTestsLocal.cs b/Tests/CSharp/ExpressionTests/XmlExpressionTestsLocal.cs new file mode 100644 index 00000000..90a5605d --- /dev/null +++ b/Tests/CSharp/ExpressionTests/XmlExpressionTestsLocal.cs @@ -0,0 +1,26 @@ +using ICSharpCode.CodeConverter.Tests.TestRunners; +using Xunit; +using System.Threading.Tasks; + +namespace ICSharpCode.CodeConverter.Tests.CSharp.ExpressionTests; + +public class XmlExpressionTestsLocal : ConverterTestBase +{ + [Fact] + public async Task XmlLiteralDecodingAsync() + { + await TestConversionVisualBasicToCSharpAsync(@"Class TestClass + Private Sub TestMethod() + Dim v = <xml><</xml>.Value + End Sub +End Class", @"using System.Xml.Linq; + +internal partial class TestClass +{ + private void TestMethod() + { + string v = new XElement(""xml"", ""<"").Value; + } +}"); + } +}