Reporter | Petr Kadlec (Petr.Kadlec) |
---|---|
Created | Aug 19, 2011 7:26:47 PM |
Updated | Jan 24, 2012 10:11:53 PM |
Resolved | Jan 24, 2012 6:30:36 PM |
Priority | Normal |
Type | Bug |
Fix versions | Next |
State | Fixed |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | Code Analysis |
Affected versions | 6.0 |
Fixed in build | 6.5.1.3309 |
A repeated access to a (non-readonly) property cannot be assumed to return an identical value (the property getter might contain a time-dependent logic, or the property value might be changed from a different thread). ReSharper mostly knows this correctly, but this construction seems to mislead him:
ReSharper marks the inner if condition as “Expression is always false” (which it is not), and the body of the inner if as “Code is heuristically unreachable” (which it is not). This does not happen when Prop is a value type, and it does not happen if Prop is accessed directly inside the inner if (“if (Prop == null)”).
This might be related to RSRP-270453.
if (Prop != null) { var prop = Prop; if (prop == null) ... }
ReSharper marks the inner if condition as “Expression is always false” (which it is not), and the body of the inner if as “Code is heuristically unreachable” (which it is not). This does not happen when Prop is a value type, and it does not happen if Prop is accessed directly inside the inner if (“if (Prop == null)”).
This might be related to RSRP-270453.