You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
False positive on a contant value when using GeneratedCodeAttribute #479
[System.CodeDom.Compiler.GeneratedCodeAttribute("","")]
public class GeneratedClass
{
}
public class Test
{
private GeneratedClass _cachedItem;
public GeneratedClass Item
{
get
{
if( this._cachedItem == null )
{
this._cachedItem = new GeneratedClass();
}
return this._cachedItem;
}
}
}
Produces the error:
CodeContracts: warning: The Boolean condition this._cachedItem == null always evaluates to a constant value. If it (or its negation) appear in the source code, you may have some dead code or redundant check
When the GeneratedCodeAttribute attribute is removed, the error no longer occurs. The attribute gets added by the xsd tool in our case, so it is generated code and we'd rather not have to remove the attribute,
Activity