Reporter | 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
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