While creating a library to learn C#, I've realized that there are a lot of conventions on how to name files, variables, parameters, interfaces, etc.
Now, I am making a file that will contain extension methods, and thus was left wondering if there are any convention on how to name those files? Is there anything suggested by the community, even if non-official?
While looking at the page about extension methods and the one about how to implement them, I realized that the name of the file used are not mentioned. I don't know if it's a coincidence.
There is no defined convention (at least that I know of). It is not mentioned in the code style doc and I don't see anything in the configurable naming rules.
Usual approach I've seen is to group extension methods by type they extend (or some logical concept) and give it suffix like
Extensions/Exts/Ext:For example framework classes and Microsoft developed libraries (like EF Core) seems to favor use of the
Extensionssuffix:EntityFrameworkQueryableExtensions- Entity Framework LINQ related extension methods.EndpointRouteBuilderExtensions- Provides extension methods forIEndpointRouteBuilderto add endpoints.MemoryExtensions- Provides extension methods for the memory-related and span-related types, such asMemory<T>,ReadOnlyMemory<T>,Span<T>, andReadOnlySpan<T>.Though there are counter-examples like
EnumerableandQueryablestatic classes containing LINQ extension methods.