Reporter | Nathan Baulch (nathan_baulch) |
---|---|
Created | Jan 5, 2012 9:11:40 AM |
Updated | Jan 5, 2012 9:11:40 AM |
Priority | Normal |
Type | Bug |
Fix versions | No Fix versions |
State | Submitted |
Assignee | Evgeny Pasynkov (pasynkov) |
Subsystem | Code Analysis - Find Code Issues |
Affected versions | 6.1 |
Fixed in build | No Fixed in build |
The following example demonstrates a false positive for the "Code is heuristically unreachable" code issue.
Set a breakpoint on the highlighted line and it will be hit if anything other than a string is passed to the Convert method.
Set a breakpoint on the highlighted line and it will be hit if anything other than a string is passed to the Convert method.
object Convert(object obj) { var str = obj as string; if (str != null) { return str; } if (TryConvert(ref obj)) { str = obj as string; if (str != null) { return str; // FALSE POSITIVE: "Code is heuristically unreachable" } } return null; } bool TryConvert(ref object obj) { obj = "NOT NULL"; return true; }