Rider Help

Code Inspection: Member can be made private (non-private accessibility)

This is a solution-wide code inspection. It only works when the solution-wide analysis is enabled.

Rider is smart enough to determine where a particular class member is actually being used. If it isn’t used outside the type or derived types, Rider will offer to mark the member as private. If the member is used in derived classes too, Rider will offer to mark it as protected.

Please note that these recommendations need to be considered before being automatically applied. After all, you may be creating a public API, or you may be making types intended to be accessed in non-standard ways (e.g., reflection). In this case, constraining visibility might not be a good idea. If necessary, you can always suppress the inspection.

The best way to suppress Rider inspections for an implicitly used public symbol is to mark this symbol with either [UsedImplicitly] or [PublicApi] attribute from the JetBrains.Annotations namespace.
You can also suppress these inspections with any custom attribute. To do so, mark the definition of this attribute with [MeansImplicitUse] attribute.

Last modified: 11 October 2017

See Also