为什么 ReSharper 在内联函数中声明 "Expression is always true" 而不是方法中?

Why does ReSharper claim "Expression is always true" in inlined function but not in method?

代码在Rider 2020.2及之前没有错误 我将 Rider 升级到 2020.3.1 以及 ReSharper 命令行工具。现在我在 Xamarin C# 项目中收到这个奇怪的警告:

var controller = new UIActivityViewController(items.ToArray(), null);
controller.CompletionWithItemsHandler = (activityType, completed, returnedItems, error) =>
{
    // here: Expression is always true
    if (error != null)
    {
        logger.Error("Error: {0}", error.Description);
    }
};

当我将内联处理程序更改为方法时,错误消失了。我在这里错过了什么?

private void CompletionWithItemsHandler(NSString activityType, bool completed, NSExtensionItem[] returnedItems, NSError error)
{
    if (error != null)
    {
        logger.Error("Error: {0}", error.Description);
    }
}

事实证明代码完全没问题。

Xamarin.iOS 的开发者启用了 Nullable 引用类型,但没有完全正确地标记所有可为 null 的参数。它似乎已经存在了很长一段时间,但新版本的 Rider 现在还检查了以前显然没有的库代码。