-
Notifications
You must be signed in to change notification settings - Fork 238
Description
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.
Serializers in Unity work directly on the fields of your C# classes rather than their properties, so there are rules that your fields must conform to be serialized.
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.