diff --git a/rules/S6964/csharp/rule.adoc b/rules/S6964/csharp/rule.adoc index f2f243b5a0..ed0a405ab5 100644 --- a/rules/S6964/csharp/rule.adoc +++ b/rules/S6964/csharp/rule.adoc @@ -20,10 +20,19 @@ public class ProductsController : Controller === Exceptions -This rule does not raise an issue when: +This rule does not raise an issue when properties are decorated with the following attributes: -* properties are decorated with the https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.validation.validateneverattribute[ValidateNever] attribute. -* properties are in model classes which are not in the same project as the Controller class that references them. This is due to a limitation of Roslyn (see https://github.com/SonarSource/sonar-dotnet/issues/9243[here]). +* https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.validation.validateneverattribute[ValidateNever] +* https://www.newtonsoft.com/json/help/html/JsonPropertyRequired.htm[JsonProperty(Required = Required.Always)] +* https://www.newtonsoft.com/json/help/html/JsonPropertyRequired.htm[JsonProperty(Required = Required.AllowNull)] +* https://www.newtonsoft.com/json/help/html/PropertyJsonIgnore.htm[Newtonsoft.Json.JsonIgnore] +* https://www.newtonsoft.com/json/help/html/t_newtonsoft_json_jsonrequiredattribute.htm[Newtonsoft.Json.JsonRequired] +* https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonrequiredattribute[System.Text.Json.Serialization.JsonRequired] +* https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonignoreattribute[System.Text.Json.Serialization.JsonIgnore] +* https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.rangeattribute[Range] +* https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelbinding.bindneverattribute[BindNever] + +Additionally, this rule does not raise for properties in model classes that are not in the same project as the Controller class that references them. This is due to a limitation of Roslyn (see https://github.com/SonarSource/sonar-dotnet/issues/9243[here]). == How to fix it