-
Notifications
You must be signed in to change notification settings - Fork 221
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
VB -> C#: XmlElement conversion not implemented for non-literals #253
Comments
Handling embedded XML is one of the reasons for using VB over C# so converting such code makes it easier to move on. |
Thanks both for raising this, and especially for the example with expected output. My apologies for not commenting sooner. Looking at the docs this could easily be a big task to implement, but hopefully it'll be possible in stages, starting with simple literal support then later handling various inline replacements, and the query/modify/insert syntax. Ideally every possible operation doesn't need to be a hardcoded syntax transformation - there will hopefully be a way to generalize our approach, by making use of the semantic model and other parts of the API. The first step of that is to put a few examples into the converter and see what level of information is available from the semantic model. |
At a quick look, there are 21 syntax constructs to convert. If we can't find a consistent way to convert them (especially one that keeps roughly in line with the currently parsed structure), then that will be rather tedious to implement fully. An example of part of this that (at least on the surface) looks consistent and easy because the structure is the same, and thus the existing per-node visiting conversion works very naturally: For Each book In From element In catalog.<Catalog>.<Book>
book.<Price>.Value = book.<Price>.Value * 1.05
Next foreach (var book in catalog.Elements("Catalog").Elements("Book"))
{
book.Element("Price").Value = Conversions.ToDecimal(book.Element("Price").Value) * (decimal) 1.05;
} |
Also, if I understand the rules correctly
becomes
|
Description edit: I've updated the erroneous output for the current release. I was going to add an alternative expected output: XElement element = XElement.Parse($"<SetAttribute XPath="{entry.Code}"></SetAttribute>"); But I think in the general case the |
I am starting on this issue now. |
as an FYI {} by itself was not enough -- you need to do the proper escape codes. String interpolation in C# has a feature similar to tagged strings in JavaScript -- you can say htmlescape |
Input code
Erroneous output
Expected output
Details
Product in use: e.g. web converter
Version in use: newest
Any other relevant information to the issue, or your interest in contributing a fix.
The text was updated successfully, but these errors were encountered: