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:
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.
UsedImplicitly
attribute in addition to Inject
. The warning will be suppressed, but I need to add this Attribute to so many places. You can configure Ninject to look for a custom attribute other than [Inject]
by having the Kernel be passed a NinjectSettings
with a different InjectAttribute
. You should be able to inherit this custom attribute from UsedImplicitly
to suppress the Resharper warning.
需要在JetBrains的外部注释包中为“ Ninject.InjectAttribute”添加“ MeansImplicitUse”注释: https : //github.com/JetBrains/ExternalAnnotations/issues/161
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.