feat|fix: adding attribute to skip null properties #329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #320
Before the change?
All attributes in the RuleParametersInput were serialized regardless of their
null
value. This caused the GitHub calls to fail as GitHub incorrectly assumed we were specifying multiple rules at once.After the change?
Adding the
[SerializeIfNotNull]
attribute which can be applied to properties serialized by the QuerySerializer to indicate they should never be serialized whennull
.As a proof of concept and bug fix, the RuleParameterInput used in the creation of rulesets for the repository was failing due to
null
properties being serialized into the final output. This code now functions as expected.I did not make a global change to no longer serialized all
null
values as I anticipate that there are "side effects" we depend on where there are expectednull
serializations that will break if such a change is made. This is contrary to the changes proposed in #319 which do not serialize allnull
properties passed in.This is an "opt-in" feature that does not disturb the greater ecosystem that may depend on these "side effects". It is also backwards compatible as the rulesets are the only code using this and it was completely failing at the time of creating this PR.
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!