- Summary
Rule csharpsquid:S6964 says to use attributes, but does not recognise the attribute from the (Microsoft) documentation that it links to.
- What language is this for?
C#
- Which rule?
csharpsquid:S6964
- Why do you believe it’s a false-positive/false-negative?
“Property should be annotated .. to avoid under-posting” - gives some suggestions of which annotations, such as [JsonProperty] but does not consider the [Required] attribute.
The [more info] tab for the rule
https://sonarqube.bu-uk.co.uk/coding_rules?open=csharpsquid%3AS6964&rule_key=csharpsquid%3AS6964
links to “Model Validation in ASP.Net 4.x” which explains how to use the [Required] attribute to stop under-posting.
- Are you using
- SonarQube Server / Community Build - which version?
Probably 2025.4 but can’t see a definitive version page. Got this by linking via the [i] to documentation.
- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
Example code, c# .net 8:
public class MyRequest
{
[Required]
public int MyId { get; set; }