CodeConverter icon indicating copy to clipboard operation
CodeConverter copied to clipboard

VB -> C#: XML literals should be XML-decoded

Open HeinziAT opened this issue 2 years ago • 3 comments

VB.Net input code

Dim v = <xml>&lt;</xml>.Value

Erroneous output

string v = new XElement("xml", "&lt;").Value;

Expected output

string v = new XElement("xml", "<").Value;

Details

HeinziAT avatar Dec 02 '22 13:12 HeinziAT

Thanks, good context on likelihood there too. Looks reasonably straightforward to fix. Wherever the code that creates the xmlelement is just needs to xml decode first. In the case of a literal that can be done at conversion time but presumably needs a runtime call in other cases?

GrahamTheCoder avatar Dec 03 '22 00:12 GrahamTheCoder

Unless I missed something, I think the issue only exist for literals, so I don't see (yet) where a runtime call would be needed. Dim x = <xml>a <%= "<" %></xml>, for example, gets converted correctly.

HeinziAT avatar Dec 05 '22 08:12 HeinziAT

Ah good, I wasn't sure what would happen if you referenced a variable containing "&lt;" and stuff like that. I don't remember what is possible in vb's xml syntax

GrahamTheCoder avatar Dec 05 '22 14:12 GrahamTheCoder