C# 为什么resharper认为asp.net请求[";abc";]永远不能为空?

C# 为什么resharper认为asp.net请求[";abc";]永远不能为空?,c#,resharper,C#,Resharper,我正在使用ASP.NET web表单,我有一个片段如下: string errorId = Request["errorid"]; if (errorId != null) ... string errorId = Request["errorid"]; log.Debug(HttpUtility.HtmlEncode(errorId)); if (errorId != null) ... Resharper对第二行说“表达式始终为真”,并希望删除该条件 文档明确指出,如果找不到指定的密钥,

我正在使用ASP.NET web表单,我有一个片段如下:

string errorId = Request["errorid"];
if (errorId != null) ...
string errorId = Request["errorid"];
log.Debug(HttpUtility.HtmlEncode(errorId));
if (errorId != null) ...
Resharper对第二行说“表达式始终为真”,并希望删除该条件

文档明确指出,如果找不到指定的密钥,则返回NULL

为什么R#认为索引器永远不能返回null?除了忽略警告之外,我还能做些什么来修复它吗


我在撰写本文时使用的是最新版本(2017.3.1)

好的,多亏了一位同事,我发现这一直都是我的错。我把我的答案放在这里,以防对其他人有用,但我想版主可能会删除整个内容

我发布的代码片段不完整;实际代码更像这样:

string errorId = Request["errorid"];
if (errorId != null) ...
string errorId = Request["errorid"];
log.Debug(HttpUtility.HtmlEncode(errorId));
if (errorId != null) ...

R#正确地计算出的是,如果errorId为null,“log”行将抛出一个异常,因此当它到达“if”行时,errorId不能为null。

看看这个so。@BWA so总结一下我的理解,JetBrains的一些人手动搜索了大量的.NETAPI,记录了哪些API永远不能返回null,并将其硬编码到Resharper中,但他们在这种情况下犯了一个错误?