ReSharper is flagging a constructor parameter with a warning, suggesting that I change the parameter to it's inherited interface type. However I need the specific implementation as the parameter type for dependency injection reasons.
I can't seem to disable this individual suggestion. // ReSharper disable All
+ // ReSharper restore All
did not appear to work and none of the drop down options let me ignore it.
My code is arranged somewhat like this:
// 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();
}
I realize that I could use a more generic binding and bind "IShape" to "Square" when injected in to the "SquareConsumer", but in the context of my application it makes more sense to have a single instance of "Square" available to any class that needs to use it explicitly.
I am using ReSharper 8.2 and Visual Studio 2013 (Professional).
How can I disable this instance of the warning?
要专门禁止显示“可以使用基本类型声明参数”警告,请使用
// ReSharper disable once SuggestBaseTypeForParameter
如果只想忽略此警告,请单击代码的构造函数行左侧的齿轮图标,然后选择“检查”-“禁用带有注释的一次”。
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.