fjoppe / Legivel

F# Yaml 1.2 parser
https://fjoppe.github.io/Legivel
The Unlicense
60 stars 5 forks source link

Cannot deserialize XML string #31

Closed johannesvp closed 4 years ago

johannesvp commented 4 years ago

I am trying to deserialize a list of XML strings, but cannot succeed.

  1. Step A I start of with XML strings like this: let xml = [ """""" """ """ """ """ """ VS2010""" """ Desktop""" """ """ """""" ]

  2. Step B Then I serialize the strings using YamlDotNet, resulting in this YAML document:

  1. Step C I deserialize the YAML document like this: Deserialize yamlDoc

I expect the original strings to be returned. But it returns an error on matching quotes. I also tried other options, like single quotes.

johannesvp commented 4 years ago

The XML string s are remove when posting the issue: let xml = [ """<XtraSerializer version="1.0" application="DockLayoutManager">""" """ <property name="#LayoutVersion" isnull="true" />""" """ <property name="$DockLayoutManager" iskey="true" value="DockLayoutManager">""" """ <property name="DockingStyle">VS2010</property>""" """ <property name="FloatingMode">Desktop</property>""" """ </property>""" """</XtraSerializer>""" ]

johannesvp commented 4 years ago

Same for the Yaml document: - "<XtraSerializer version=\"1.0\" application=\"DockLayoutManager\">" - " <property name=\"#LayoutVersion\" isnull=\"true\" />" - " <property name=\"$DockLayoutManager\" iskey=\"true\" value=\"DockLayoutManager\">" - " <property name=\"DockingStyle\">VS2010</property>" - " <property name=\"FloatingMode\">Desktop</property>" - " </property>" - "</XtraSerializer>" ...

fjoppe commented 4 years ago

There is an invisible character - chr(6) - after the first doublequote on the first line.

Compare this:

let goodYaml = "
- \"<XtraSerializer version=\\\"1.0\\\" application=\\\"DockLayoutManager\\\">\"
"

Deserialize<string list> goodYaml

With this:

let badYaml = "
- \"<XtraSerializer version=\\\"1.0\\\" application=\\\"DockLayoutManager\\\">\"
"

Deserialize<string list> badYaml

Funny thing is, with copy/paste from the web, the issue is included.

In Visual Studio, if you put the cursor between " and < and you navigate with the cursor keys left/right, you'll notice it is skipping a character. If you delete the invisible character, the full yaml will parse.

Anyhow, I'd check the source which is generating the Yaml.

johannesvp commented 4 years ago

That was the indeed the problem. Thank you very much for finding this.

Deserializing the XML strings works like a charm.