Resharper 表达式始终为 false
Resharper expression is always false
给定以下代码块..
if (HttpContext.Current == null) return null;
if (HttpContext.Current.User == null) return null;
if (HttpContext.Current.User.Identity == null) return null;
return HttpContext.Current.User.Identity.Name;
Resharper 告诉我第三行总是错误的。考虑到 Identity 是一个引用类型,Resharper 如何保证?
ReSharper 附带所谓的 "External Annotations"。
使用这些注解 R# 假定特定属性/参数/...永远不会是 null
。 (在 Identity
属性 上按 Crtl+Shift+F1 后,您应该会看到 [NotNull]
属性注释。)
但是:这个特定的注释似乎是一个错误(参见 RSRP-398551)并且已经在当前版本的外部注释中得到修复。
给定以下代码块..
if (HttpContext.Current == null) return null;
if (HttpContext.Current.User == null) return null;
if (HttpContext.Current.User.Identity == null) return null;
return HttpContext.Current.User.Identity.Name;
Resharper 告诉我第三行总是错误的。考虑到 Identity 是一个引用类型,Resharper 如何保证?
ReSharper 附带所谓的 "External Annotations"。
使用这些注解 R# 假定特定属性/参数/...永远不会是 null
。 (在 Identity
属性 上按 Crtl+Shift+F1 后,您应该会看到 [NotNull]
属性注释。)
但是:这个特定的注释似乎是一个错误(参见 RSRP-398551)并且已经在当前版本的外部注释中得到修复。