Skip to content
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

YamlStream.Save inserts odd character string before mapping value #567

Closed
BigBallard opened this issue Jan 20, 2021 · 2 comments
Closed

Comments

@BigBallard
Copy link

I am dynamically loading and saving yaml files to conform to a dynamic schema of locales that I am building. With that, I use YamlStream and the Yaml*Node's to construct and read from the loaded documents.

I got to the saving portion of the code and I am experiencing some weird behavior where the first value of a mapping inserts some string integers preceded by a &.

common_fr:
  help_l: &1722725615 ''
  help_u: ''
...

Note that is only occurs when creating a new file and saving the schema to it. When I save to an already existing file to update it, the string does not appear. The file is able to be read in correctly even with the string but I have a feeling it shouldn't be there.

Here is the portion of code I use to do the writing:

...
var entryMappings = new YamlMappingNode();
foreach (var entry in entries)
{
    entryMappings.Children[new YamlScalarNode(entry.Key.Item3)] = new YamlScalarNode(entry.Value);
}
var rootNode = new YamlMappingNode();
rootNode.Children[new YamlScalarNode(localeSpecificContext)] = entryMappings;
var document = new YamlDocument(rootNode);
var stream = new YamlStream();
stream.Documents.Add(document);
TextWriter fileStream = File.CreateText(contextFile);
stream.Save(fileStream);
fileStream.Close();
@BigBallard
Copy link
Author

Looking to the code base a bit, and eventually to some other documentation, I can see that it is inserting anchors. I need to call Save(TextWriter, Bool) where bool needs to be false for 'assignAnchors'.

@EdwardCooke
Copy link
Collaborator

Closing this as it’s a non issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants