-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Design.Linq.AvoidExtensionMethodOnSystemObjectRule(git)
Sebastien Pouliot edited this page Mar 2, 2011
·
1 revision
Assembly: Gendarme.Rules.Design.Linq
Version: git
Extension methods should not be used to extend System.Object. Such extension methods cannot be consumed by some languages, like VB.NET, which use late-binding on System.Object instances.
Bad example:
public static class Extensions {
public static string ToDebugString (this object self)
{
return String.Format ("'{0}', type '{1}', hashcode: {2}",
self.ToString (), self.GetType (), self.GetHashCode ());
}
}
Good example:
public static class Extensions {
public static string ToDebugString (this DateTime self)
{
return String.Format ("'{0}', type '{1}', hashcode: {2}",
self.ToString (), self.GetType (), self.GetHashCode ());
}
}
- This rule is available since Gendarme 2.2
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!