resharper-unity icon indicating copy to clipboard operation
resharper-unity copied to clipboard

Validate correct constructor for Unity serialised types

Open citizenmatt opened this issue 5 years ago • 1 comments

Figure out the rules for constructors and Unity serialised types (MonoBehaviour or [Serializable]). Do these types require a default constructor? If a user creates a non-default constructor, should we add a highlight to also add a default constructor?

citizenmatt avatar Jul 01 '20 08:07 citizenmatt

Should definitely highlight non-default constructor, because this can cause field initialisers to not run - the compiler rewrites these to be part of the constructor, and Unity will only invoke a non-default constructor.

citizenmatt avatar Nov 23 '21 11:11 citizenmatt