-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
yaml.Documents[].RootNode is YamlScalarNode instead of YamlMappingNode in VS2022 console project #872
Comments
In your top screen shot your casting to a YamlMappingNode before checking the type. In your second screenshot regardless of the type your still casting to YamlMappingNode. My suspicion is both throw an exception. |
YamlMappingNode would come after the yamlscalar |
1st picture was from VS2022 new console application it was only example method in both solutions I'm sending you short yaml file example (included in VS2022 solution archive), which has different AllNodes in console application created in VS 2022 and in VS 2019 console application opened in VS2022 I'm sending you archive with simple VS2022 WinForms application example and snippet of yamlNode.AllNodes View (Visualizer View) on Line30 in Form1.cs There is no possibility to traverse from RootNode typed as YamlScalarNode to another node in structure of UnitDescTestShort.yaml file. VS 2022 Professional version installed on my virtual Win10 is 17.6.4 Maybe my description is little bit more clear now. |
Thanks, the version of Visual Studio shouldn't effect anything, it would be the version of .net that was being targeted by your project. I'll take a look at this tonight and let you know what I see. |
In your zip file, In the |
Really, It was StringReader instead of StreamReader, I don't know how it was written, maybe with IntelliSense. I thought, that I copied these several lines from source file, where StreamWriter is used and behaviour is proper. Thanks for your attention to this my "issue". After using of StreamReader, AllNodes contains all yaml file nodes and RootNode type is YamlMappingNode. You are doing good job to create and support YamlDotNot over YAML standard. I use it in several company projects with very good experience. |
using (StreamReader input = new StreamReader(_filePathAndName ))
{
// Load the stream
var yaml = new YamlStream();
yaml.Load(input);
...
var mapping =
(YamlMappingNode)yaml.Documents[0].RootNode;
...
generate during load of same yaml file type cponversion exception on var mapping = ... line
I found, that there is difference in RootNode type between 1. and 2. (options above)
RootNode type is in VS2022 created console application YamlScalarNode
VS2022 console application has included YamlDotNet 13.7.1
VS2019 console application has included YamlDotNet 13.0.0
I tried to remove 13.7.1 version from VS2022 app and install 13.0.0, behaviour described above stay same
I can send you part of loaded yaml file, which has different RootNode type in VS2019 crreated application and VS 2022 creaded console application.
YAML file starts with:
Lines:
Branches:
Models:
SerialNumber: 0000000000003
Unit Revision: 1
Specification: SpecName
There are attached of screen snippets:
The text was updated successfully, but these errors were encountered: