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

Support [DataMember] IsRequired in NewtonsoftDataContractResolver #2644

Merged
merged 3 commits into from
Aug 1, 2024

Commits on Aug 1, 2024

  1. ✅ Add non-regression tests for DataMember required

    As DataMember implementation comes after the implementation for [JsonProperty] and [JsonObject], we want to be sure that the current behavior is not bypassed.
    ouvreboite authored and jb.muscat committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    3d17511 View commit details
    Browse the repository at this point in the history
  2. ✨Add support for [DataMember(IsRequired)]

    Add test cases for DataMember (IsRequired and Name).
    It seems that NewtonSoft's ResolveContract correctly set the Required, using [DataMember], [JsonProperpty] and [JsonRequired] so we can directly use it instead of the IsRequiredSpecifed extension method.
    ouvreboite authored and jb.muscat committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    5ec8ff2 View commit details
    Browse the repository at this point in the history
  3. ✨ Keep IsRequiredSpecified() but use JsonProperty.Required internally

    Newtonsoft do all the work for us, handling [JsonProperty(Required = Required.Always)] or [JsonRequired] or [DataMember(IsRequired = true)] and filling the JsonProperty.Required field.
    ouvreboite committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    77994ee View commit details
    Browse the repository at this point in the history