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

RSRP-224669: Possible System.NullReferenceException

$
0
0
Reporter Chad Bentz (felickz) Chad Bentz (felickz)
Created Mar 7, 2011 6:34:36 PM
Updated Jan 25, 2012 9:12:25 PM
Resolved Jan 25, 2012 4:48:38 PM
Priority Normal
Type Meta Issue
Fix versions 6.1
State Fixed
Assignee Evgeny Pasynkov (pasynkov)
Subsystem Language - C#
Affected versions 5.1.3
Fixed in build 6.5.1.3431
In my opinion, this code would be failsafe:

if (HttpContext.Current != null)
{
HttpContext.Current.Response.Cookies["test"].Value = "test value";
}


But the realtime inspections end up leading you to putting these wrappers around the statement:


if (HttpContext.Current != null)
{
if (HttpContext.Current.Response != null)
{
if (HttpContext.Current.Response.Cookies != null)
{
HttpContext.Current.Response.Cookies["test"].Value = "test value";
}
}
}

But once you have that structure, the following inspections are given:

*HttpContext.Current.Response.Cookies != null yields "Expression is always true"

*HttpContext.Current.Response != null yields "Expression is always true"


Seems to put you in an endless loop of refactorings. I cannot verify that this happens in older versions, but it is the first i have seen it happen w/ 5.1.3

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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