Search code examples
c#resharperninjectstatic-analysis

How to suppress Resharper wide-analysis warning of properties with Inject attribute?


We use dependency injector Ninject in our C# project. The usual way of implementing it looks like this:

[Inject]
public UsersRepositoryInterface UsersRepository { private get; set; }

In addition to this, I enabled Resharper Wide Analysis for the solution, and it shows me to warnings in this line:

  • Property 'VrtSystemsFlatRepository' can be made private
  • Auto-property accessor is never used

enter image description here

My inner perfectionist suffers when he sees it, and I don't know how to avoid this warning.

I know about two ways, but I don't like both of them.

  1. Add UsedImplicitly attribute in addition to Inject. The warning will be suppressed, but I need to add this Attribute to so many places.
  2. Suppress the warning globally for the solution, for the project or file.

Solution

  • Need to add "MeansImplicitUse" annotation for "Ninject.InjectAttribute" in JetBrains's External annotations package: https://github.com/JetBrains/ExternalAnnotations/issues/161