Code Inspection: Member can be made private (private accessibility)
ReSharper 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, ReSharper will offer to mark the member as
If the member is used in derived classes too, ReSharper will offer to mark it as
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.
In contrast to the similar solution-wide inspection that also detects unused public members in non-nested types, this local inspection will only notify you about public members in non-public nested types, which are not used in the parent type. This can indicate one of the two problems:
- The public member is intended to be private. In this case, you can simply apply the quick-fix that ReSharper suggests.
- The public member is intended to be used in the parent class but not used there. In this case, the member cannot be a part of a public API and probably hides some not implemented functionality.