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

Allow to Serialize with line breaks between sections #804

Closed
wants to merge 2 commits into from

Conversation

emanuel-v-r
Copy link

@emanuel-v-r emanuel-v-r commented Apr 29, 2023

This is related to the issue that I described here #803.
For my usage it's important to be able to serialize a Yaml with line breaks.
Due to yaml's nature, which is declarative and human readable I think it makes sense to support it. We often see files like docker-compose separating sections by break line.
With this PR, that would be possible, either by using YamlMemberAttribute, or by emiting the event manually.
Please let me know if there's an existing and more straightforward way of doing this, then I will abort my PR.
Thanks.

@emanuel-v-r
Copy link
Author

@EdwardCooke, would it be possible to get someone to review this?
It would be really helpful.
Thank you.

@JuergenGutsch JuergenGutsch self-assigned this May 12, 2023
@JuergenGutsch
Copy link
Collaborator

Maybe also related to #523? I will have a look

@emanuel-v-r
Copy link
Author

Maybe also related to #523? I will have a look

Actually this is more related to serialization, will update the title and description

@emanuel-v-r emanuel-v-r changed the title Supporting Break lines between Properties Allow to Serialize with line breaks between sections May 12, 2023
@EdwardCooke
Copy link
Collaborator

I’ll try and take a look this weekend.

@EdwardCooke
Copy link
Collaborator

Sorry for the long delay, was on vacation :) Anyways, what I would prefer is a way of adding any arbitrary content before it, that way it can be whatever is desired by the developer, if we did this as a string, then people could put in whatever the feel like, including something like

something:

# i like
# new lines!

  like: that

  or: just a new line

Also, you'll need to do this on a branch in your fork named something other than master. Using master in your fork breaks the build.

@emanuel-v-r
Copy link
Author

emanuel-v-r commented Jun 17, 2023

No worries, I have mixed feelings about that, I mean it would be more flexible for sure, but at the same time it would allow you to serialize an invalid yaml, while this way it would be more restricted.
Nevertheless if you prefer it that way, I have no issues, it will fit our scenario as well.
Let me know, and I will change the branch and adapt it accordingly

@EdwardCooke
Copy link
Collaborator

I’ve been thinking about this more. I really think having the ability to put whatever a person wants in there is a good thing due to flexibility. One idea I have is maybe a check in the attribute setter that makes sure every line is either empty or starts with spaces and/or pound sign. That would guarantee a valid yaml structure at compile time, in theory. I’d like that tested to make sure. But at least it would be validated at runtime at the very least.

@EdwardCooke
Copy link
Collaborator

Another issue here is that your branch shouldn't be on master, please create your own, otherwise the build will fail.

@EdwardCooke
Copy link
Collaborator

Are you going to create your own, non-master, branch? Or can I close this?

@emanuel-v-r
Copy link
Author

emanuel-v-r commented Jan 5, 2024

I am closing this PR as the approach that you want to follow is a more flexible one and I am not actually sure that those changes are as simple to implement, in the way that I am afraid of users breaking the seriaization/deserialization due to such flexibility.
In fact I am not even thinking on a good use case for this arbitrary string.
Probably that would require more extensive testing as well.

@emanuel-v-r emanuel-v-r closed this Jan 5, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants