-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Design.AvoidRefAndOutParametersRule(git)
Assembly: Gendarme.Rules.Design
Version: git
This rule fires if a method uses ref or out parameters. These are advanced features that can easily be misunderstood and misused (by the consumer). This can result in an API that is difficult to use so avoid them whenever possible. An alternative is to use one of the new generic Tuple types (FX v4 and later) as the return value. No defect will be reported if the method:
Bad example:
public bool NextJob (ref int id, out string display)
{
if (id < 0)
return false;
display = String.Format ("Job #{0}", id++);
return true;
}
Good example:
private int id = 0;
private int GetNextId ()
{
int id = this.id++;
return id;
}
public string NextJob ()
{
return String.Format ("Job #{0}", Id);
}
- This rule is available since Gendarme 2.0
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!