YamlDotNet
YamlDotNet copied to clipboard
Deprecate the assignAnchors parameter
The assignAnchors parameter of YamlStream.Save is buggy and should be deprecated. It causes anchors to be assigned to scalars that happen to have the same value (usually mapping keys). This functionality would be better handled by letting the programmer assign an anchor manually when desired.
Yes this would be awesome! I am currently trying to figure out, how exactly we could implement this: We - in our object model - also want to know, which properties are actually "inherited" or "copied" from another object.
Unfortunately, even when using the representation model (YamlStream) it seems that all anchors are resolved already and we do not know where an anchor was used!
Let's consider an example from atlassian
definitions:
steps:
- step: &build-test
name: Build and test
script:
- mvn package
artifacts:
- target/**
pipelines:
branches:
develop:
- step: *build-test
master:
<<: *build-test
name: Testing on Master
In our case, we would like to give the user a UI to edit this. Therefore, however, we'd need to know which properties were "inherited" such as the develop step and the master step, and which properties were overridden.
In the end, if the user changes nothing and saves the object tree, the resulting YAML file should look exactly the same.
Is there any way to achieve this today? Maybe even with an object tree? (I was thinking about something like Json.NET's JsonExtensionDataAttribute
The greatest solution would allow us to develop a custom anchor lookup mechanism to
- e.g. parse only a part of a large yaml and provide anchors outside of that region on demand
- or even better (even if YAML spec does not officially support this), support referencing an anchor in another file!