ReSharper 正在使用警告标记构造函数参数,建议我将参数更改为其继承的接口类型。但是,出于依赖注入的原因,我需要特定的实现作为参数类型。
我似乎无法禁用这个单独的建议。// ReSharper disable All
+// ReSharper restore All
似乎不起作用,并且没有一个下拉选项让我忽略它。
我的代码安排得有点像这样:
// Constructor with the ReSharper warning.
IShape _shape;
public SquareConsumer(Square square){
_shape = square;
}
// Class where I set up dependency injection using Ninject.
public void SetupBindings(IKernel kernel){
kernel.Bind<Square>.ToSelf();
kernel.Bind<SquareConsumer>.ToSelf();
}
我意识到当注入到“SquareConsumer”时,我可以使用更通用的绑定并将“IShape”绑定到“Square”,但在我的应用程序的上下文中,让“Square”的单个实例可用于任何需要显式使用它的类。
我正在使用 ReSharper 8.2 和 Visual Studio 2013(专业版)。
如何禁用此警告实例?