Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-292349: Debug.Fail marked Heuristically unreachable incorrectly

$
0
0
Reporter Christopher Theberge (Christopher.Theberge) Christopher Theberge (Christopher.Theberge)
Created Mar 30, 2012 11:55:49 PM
Updated Mar 31, 2012 12:21:31 AM
Priority Normal
Type Bug
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem Code Analysis
Affected versions 6.1.1
Fixed in build No Fixed in build
Using ReSharper v6.1.1 I've found the following code to erroneously produce a message about some code being heuristically unreachable. I think this is a false positive on the part of your analysis.

Code
private string DoSomething(object someObject)
        {
            if (someObject == null)
            {
                Debug.Fail("DoSomething must be properly sent a sender.");
                return string.Empty;
            }
            else
            {
                return someObject.ToString();
            }
        }
}


Following guidance by ReSharper could cause code to either not compile (Due to missing return statements in the removal region) or, in other cases, create a bug because additional logic would have been removed.

Seeing as Debug.Fail generates a message which allows the user to ignore the message and continue, this issue can be annoying when developing code which that is designed to help track down issues.

Likewise, Debug.Assert generates a different set of heuristic issues assuming that any checks after that point will not be null, where it actually could be null if the user selected ignore on the assertion dialog.

Code
private string DoSomethingElse(object someObject)
{
     Debug.Assert(someObject != null, "Some object cannot be null.");

            if (someObject == null)
            {
                return string.Empty;
            }
            else
            {
                return someObject.ToString();
            }
        }
}


Using a 'Relase' configuration causes Resharper's Analysis to no longer produce these warnings.

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>