-
-
Notifications
You must be signed in to change notification settings - Fork 484
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 omitting empty collections via DefaultValuesHandling
#608
Conversation
DefaultValuesHandling.OmitDefaultsOrEmpty
DefaultValuesHandling
@aaubry would it be possible to get this looked at? It would help my other project a lot to have this capability |
This is a temporary workaround before aaubry/YamlDotNet#608 gets merged. This makes the YAML not contain bunch of rows like this: ``` variables: [] ```
**Makes the project use the pipeline defined using Sharpliner inside the `Sharpliner.CI` project!** Adds an AzDO task that will verify whether you have published and commited all changes into YAML files. (resolves #3) The many empty arrays in the YAML will be gone once we check in aaubry/YamlDotNet#608
I'm sorry, I wasn't able to look at this until today. I'm reviewing the PR now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this feature is interesting, but requires some small design changes so that we don't get stuck in the future.
YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs
Outdated
Show resolved
Hide resolved
YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs
Outdated
Show resolved
Hide resolved
YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs
Outdated
Show resolved
Hide resolved
Thanks and sorry about the slow response time. |
This feature has been released in version 11.2.0. |
Thanks @aaubry!! |
@tjstjsgt we have made these options into So you could set the policy to Or is there a problem? |
Motivation
Sometimes, you cannot cannot afford to null your enumerables but you don't want them in your YAML.
This default value handling policy allows to prevent serialization of empty arrays/lists/dictionaries into
Change
Added 2 new options:
DefaultValuesHandling.OmitDefaultsOrEmpty
DefaultValuesHandling.OmitNullOrEmpty
which turns on omitting of empty collections.