-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.BadPractice.AvoidNullCheckWithAsOperatorRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.BadPractice
Version: git
The rule will detect if a null check is done before using the as operator. This null check is not needed, a null instance will return null, and the code will need to deal with as returning a null value anyway.
Bad example:
public string AsString (object obj)
{
return (o == null) ? null : o as string;
}
Good example:
public string AsString (object obj)
{
return (o as string);
}
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!