ReSharper is claiming that my null check against serviceProvider is always true, which is odd. I figured that serviceProvider very well might be null. Am I wrong here, or is this a ReSharper bug?
public override object ProvideValue(IServiceProvider serviceProvider)
{
switch (Mode)
{
case BindingMode.TwoWay:
throw new InvalidOperationException("Invalid binding mode.");
case BindingMode.OneWayToSource:
throw new InvalidOperationException("Invalid binding mode.");
case BindingMode.OneWay:
case BindingMode.OneTime:
break;
case BindingMode.Default:
if (serviceProvider != null) // Expression is always true?? O.o
{
// Returns something possibly...
}
throw new InvalidOperationException("Invalid binding mode.");
default:
throw new InvalidOperationException("Unexpected binding mode.");
}
return base.ProvideValue(serviceProvider);
}
Update:
I created a console application, and the following code gives a warning as well (from ReSharper) Possible null assignment to entity marked with 'NotNull' attribute.
var binding = new CustomBinding();
binding.ProvideValue(null);