Resharper声明if/else条件永远不会被击中,为什么?

Ror*_*san 0 c# resharper c#-4.0 visual-studio-2015

我有一个PushSharp示例中的代码,详细说明了如何处理异常.出于某种原因else,Resharper将所有条件都显示为灰色,并说明了这一点The expression is always false.我不知道这是怎么可能的.

// ex is an Exception passed in to the method
if (ex is NotificationException)
{
    // Deal with the failed notification
    var notification = ((NotificationException)ex).Notification;
    var logItem = new PushLog($"{typePrefix} Notification failed", $"Notification Failed: {notification}");
    _pushLogRepo.Insert(logItem);
}
else if (ex is DeviceSubscriptionExpiredException) // Resharper says this is always false
{
   // exception handling code...
}
else if (ex is RetryAfterException) // Resharper says this is always false
{
   // exception handling code...
}
else
{
    Console.WriteLine("Notification Failed for some (Unknown Reason)");
}
Run Code Online (Sandbox Code Playgroud)

有人能解释一下这是怎么回事吗?我不明白它是怎么回事.这是VS2015的屏幕截图,语法突出显示更清晰 - 忽略错误,我正在重构.

在此输入图像描述

SLa*_*aks 8

如果这些类继承NotificationException,就会发生这种情况,因为那时第一个分支总会命中.