Visual Studio - IDE0044 Make field readonly

I’m new at using Visual Studio. Each time I write a private variable in a script the first letters of the name I give to it is underlined because I use lowercase letters.

The proposed fixes are:

  • make field readonly,
  • encapsulate field: “” (and use property),
  • encapsulate field: “” (but still use field),
  • suppress IDE0044 either in Source or in Suppression File.

I hesitate between:

  • ignoring the warning because it’s not code related (my default choice for now),
  • making the field readonly,
  • suppressing IDE044.

What should I do? :slight_smile:

1 Like

Be aware that marking a field readonly will make Unity unable to serialize it, so even if it may be detected by the IDE as a candidate for being marked readonly, doing so may break your code because you’ll loose serialization capabilities for it.

Thanks for the advice. :slight_smile:

Those can be ignored in 90% of cases. Visual Studio doesn’t know about all the ways Unity interacts with your source files, such as Editor serialization.