USP0007 Don't flag fields decorated with serialization attributes (like SerializeField, SerializeReference or OdinSerialize) as never assigned
June 17, 2025 ยท View on GitHub
Fields with the SerializeField, SerializeReference or OdinSerialize attributes should not be marked as unassigned.
Suppressed Diagnostic ID
CS0649 - Field is never assigned to, and will always be null
Examples of code that produces a suppressed diagnostic
using UnityEngine;
class Camera : MonoBehaviour
{
[SerializeField]
private string someField;
}
Why is the diagnostic reported?
The compiler detected an uninitialized private field declaration that is never assigned a value.
Why do we suppress this diagnostic?
A field with the SerializeField, SerializeReference or OdinSerialize attributes are exposed to Unity and can be assigned in the Unity Inspector.