Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何禁用单个重拾器“;参数的类型可以是;建议?_C#_Resharper_Ninject_Resharper 8.0 - Fatal编程技术网

C# 如何禁用单个重拾器“;参数的类型可以是;建议?

C# 如何禁用单个重拾器“;参数的类型可以是;建议?,c#,resharper,ninject,resharper-8.0,C#,Resharper,Ninject,Resharper 8.0,ReSharper正在用警告标记构造函数参数,建议我将该参数更改为其继承的接口类型。但是,出于依赖项注入的原因,我需要特定的实现作为参数类型 我似乎无法阻止这一个人的建议//ReSharper disable All+//ReSharper restore All似乎不起作用,并且任何下拉选项都不允许我忽略它 我的代码是这样安排的: // Constructor with the ReSharper warning. IShape _shape; public SquareConsumer(Sq

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();
}
//带有ReSharper警告的构造函数。
IShape_形;
公众广场(广场){
_形状=正方形;
}
//类,我在其中使用Ninject设置依赖项注入。
公共void设置绑定(IKernel内核){
kernel.Bind.ToSelf();
kernel.Bind.ToSelf();
}
我意识到,当注入到“SquareConsumer”中时,我可以使用更通用的绑定并将“IShape”绑定到“Square”,但在我的应用程序上下文中,让任何需要显式使用它的类都可以使用“Square”的单个实例更有意义

我正在使用ReSharper 8.2和Visual Studio 2013(专业版)


如何禁用此警告实例?

如果您只想忽略此警告,请单击构造函数代码行左侧的齿轮图标,然后选择“检查”-“禁用一次并添加注释”。

要特别禁止“参数可以用基类型声明”警告,请使用

// ReSharper disable once SuggestBaseTypeForParameter

实际上,您应该创建一个从IShape继承的ISquare接口,并将其注入。我想这就是我将采用的解决方案,谢谢。对不起,我可能在描述中对此不是很清楚。“检查”子菜单未显示在该菜单中。