Skip to content

Fix S6964 FP: Add more attributes to the exclusions #9337

@denis-troller

Description

@denis-troller

Description

Rule S6964 raises on members that are defined with the [JSonProperty(Require = Always)] attribute.
Since a missing value will cause a deserialization error, the rule should not raise.
Please also consider [JSonProperty(Require = DisallowNull)]

Repro steps

Please provide a minimal code snippet that compiles which reproduces the problem. Alternatively, you can share a link to the SonarCloud public project where the issue appears. If the issue requires some specific project configuration to reproduce, you can create a minimal reproducible project and share its git repository or attach it as a ZIP file.

Example:

/// <summary>This class defines a GetPartnerSubscriptionRequest model.</summary>
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class GetPartnerSubscriptionRequest
{
    /// <summary>Gets or sets the ClientSiteId.</summary>
    [ValidateNever] // Prevents sonar error/warning S6964
    [JsonProperty(Required = Required.Always)]
    public Guid ClientSiteId { get; set; }

    /// <summary>Gets or sets the PartnerId.</summary>
    [ValidateNever] // Prevents sonar error/warning S6964
    [JsonProperty(Required = Required.Always)]
    public Guid PartnerId { get; set; }
}

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions