-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Maintainability.RemoveDependenceOnObsoleteCodeRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Maintainability
Version: git
This rule will warn you if your code depends on (e.g. inherit, implement, call...) code that is decorated with the Obsolete attribute. Note that the rule does not report Obsolete types, methods... but only their use by your code.
Bad example:
[Obsolete ("Limited to In32.MaxValue, use new Int64 ReportAll method")]
abstract int Report (IList list);
abstract long ReportAll (IList list);
public int GetCount ()
{
// this method is not ok since it use an obsolete method
return Report (list);
}
Good example (dependency removed):
[Obsolete ("Limited to In32.MaxValue, use new Int64 ReportAll method")]
abstract int Report (IList list);
abstract long ReportAll (IList list);
// this method is correct but this changed the public API
public long GetCount ()
{
return ReportAll (list);
}
Good example (decorated as [Obsolete]):
[Obsolete ("Limited to In32.MaxValue, use new Int64 ReportAll method")]
abstract int Report (IList list);
abstract long ReportAll (IList list);
[Obsolete ("Limited to In32.MaxValue, use new Int64 GetLongCount method")]
public int GetCount ()
{
// this method is now correct since it is decorated with [Obsolete]
return Report (list);
}
public long GetLongCount ()
{
return ReportAll (list);
}
- This rule is available since Gendarme 2.8
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!