What naming conventions are you using for namespaces and sponsor classes? (i.e. the classes that hold extension method definitions)
Is there a standard/recommended .NET Framework naming convention? (the "Framework Design Guidelines, 2nd Edition" book only gives guidance on what namespaces not to use).
The class that defines such extension methods is referred to as the "sponsor" class, and it must be declared as static. To use extension methods, one must import the namespace defining the sponsor class.
Naming extension classes Preferably, the extension class should include the name of the type that is being extended. However, the name must also include a term, abbreviation, or prefix that distinguishes the class from other types.
The naming convention would be StringExtensions for string, or simply the type name plus "Extensions".
To define and call the extension methodDefine a static class to contain the extension method. The class must be visible to client code. For more information about accessibility rules, see Access Modifiers. Implement the extension method as a static method with at least the same visibility as the containing class.
I haven't seen any official recommendations, but I've been organizing my extension classes like [NameSpace].[ClassName]Extensions:
ProjectName.Web.Util.ControlExtensions
ProjectName.Data.Util.CollectionExtensions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With