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

Deprecate the assignAnchors parameter #248

Open
aaubry opened this issue Apr 7, 2017 · 1 comment
Open

Deprecate the assignAnchors parameter #248

aaubry opened this issue Apr 7, 2017 · 1 comment

Comments

@aaubry
Copy link
Owner

aaubry commented Apr 7, 2017

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.

@gentledepp
Copy link

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!

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

No branches or pull requests

2 participants