Enforce that all readonly variables are initialized in every constructor

Viewed 138

Context: I sometimes end up in the scenario where i have a class that contains multiple readonly fields and multiple constructors. It can then be hard to remember to initialize every variable that needs to be initialized in the constructor. Resharper can warn if a field is never initialized but not if its only initialized by some constructor(s).

Question: Is there anyway i can get IDE warnings or compilation errors for a constructor that doesn't initialize all readonly fields or get only auto-properties of a class?

0 Answers
Related