Fix S1104 FP: Do not report in Unity serializable classes #7522
Labels
Area: C#
C# rules related issues.
Sprint: Hardening
Fix FPs/FNs/improvements
Type: False Positive
Rule IS triggered when it shouldn't be.
Milestone
Derived from this discuss post.
S1104 raises in all contexts, including in Unity scripts derived from MonoBehavior. The rule should not report in that context, however, due to how Unity works.
Using public properties would break core features of Unity such as YAML serialization and UI editing.
Unity requires using public fields, and using public properties would break core features of Unity such as serialization and UI editing.
Unity has specific rules for serialization, detailed here.
Notice that there are ways of conforming to S1104 in Unity: as shown in the “Serialization of properties” section of the documentation, user-implemented properties with a backing field marked as SerializeField would be supported by the Unity Editor.
Regardless, those are corner cases that are rarely encountered in practice.
The text was updated successfully, but these errors were encountered: