JetBrains Rider 2025.3 Help

Code inspection: Possible incorrect application of attribute to multiple fields

This inspection will warn if the [FormerlySerializedAs] attribute is applied to multiple fields, in the following syntax:

[FormerlySerializedAs("value")] public int value1, value2, value3;

When an attribute is applied to a field declaration that is declaring multiple fields, the attribute is applied to each field, and is equivalent to:

[FormerlySerializedAs("value")] public int value1; [FormerlySerializedAs("value")] public int value2; [FormerlySerializedAs("value")] public int value3;

The [FormerlySerializedAs] attribute is not intended to be used in this manner, and should only be applied to a single field declaration.

The inspection provides a quick fix to split the declarations, so that the [FormerlySerializedAs] attribute can be explicitly set on the required fields.

See the documentation for more details on the intended usage of the [FormerlySerializedAs] attribute.

24 March 2026