When to use class naming convention for extension methods?
As pointed out in Reed Copsey’s answer, very ( very) seldom will client code reference the containing class directly as the very point of extension methods is to emulate reference methods. They won’t see the classes, so your class naming convention choice should have insignificant impact.
How are extension methods defined in a language?
Extension methods are a language feature that allows static methods to be called using instance method call syntax. These methods must take at least one parameter, which represents the instance the method is to operate on. The class that defines such extension methods is referred to as the “sponsor” class, and it must be declared as static.
Why do we use naming conventions in MakeCode?
Naming conventions provide a consistant and expected style of usage across all namespaces used by MakeCode. This allows the coding user to make general assumptions about name forms used for functions, methods, properties, and enumerations.
Where does an extension go in the namespace?
Any extension methods I create always go in their own namespace and are usually ‘hungarianed’ with ‘Ext’ at the end so I can clearly see its an extension (never want to spend time trying to figure out which class a method belongs to only to find it doesn’t belong to any class!
What should be the name of an extension?
To minimize the risk of conflicts, the name should include a term, abbreviation, or infix that distinguishes the extension from other extensions to the same element in other models. Include either the name of the model where the extension element resides or the prefix that the extension is associated with.
Why do you name an extension class ithingextensions?
It also makes the extension class be sorted away from the interface it extends, when viewing files alphabetically. On the other hand, naming it IThingExtensions makes it look like it is an interface itself, instead of an extension class for an interface.
Why is an extension not named inventlocation?
For example, an extension of the InventLocation table must not be named InventLocation.Extension, because the risk of conflicts is too high. Extension classes that are used to augment the logic on tables, classes, or other elements must have a name that is unique across all types in all models.