When breaking out classes into files, I am wondering what the naming convention is for class files containing only enums. Should they match the enum name, like any other class, or should they be suffixed with ‘Enum’ so that the developer knows that the file contains only an enum?
For example:
namespace MyCompanyName.MyApplication
{
public enum Colors
{
Red,
Blue,
Green,
Yellow
}
}
Would you say the file containing the above code should be named ‘Colors.cs’ or ‘ColorsEnum.cs’? Alternatively, perhaps there is another accepted naming convention for such files?
First off, this is a complete personal/team preference thing.
That being said:
I personally would name it
Colors.cs. This keeps the filename corresponding to the type name. When I’m working on the API, if “Colors” are a fixed set of things represented by an enum, I’d probably know that, and there would be no confusion.