If the field is initialized in the constructor, it suggests initializing it at the declaration point instead. The code fix would remove the initialization from the constructor.
private static readonly object name = new object();
private readonly object name = new object();
If the field is not initialized in the constructor, it suggests initializing it at the declaration point but with a message indicating the variable is not initialized.
This dotnet/roslyn-specific analyzer would identify fields of the following form:
And support two diagnostics:
If the field is initialized in the constructor, it suggests initializing it at the declaration point instead. The code fix would remove the initialization from the constructor.
If the field is not initialized in the constructor, it suggests initializing it at the declaration point but with a message indicating the variable is not initialized.