A repository to contain IntelliTect's tools for coding conventions. https://intellitect.github.io/CodingGuidelines/
Fields should be specified in _PascalCase. Always with a leading underscore, regardless of visibility modifier.
Allowed
class SomeClass
{
public string _MyField;
}
Disallowed
class SomeClass
{
public string _myField;
public string myField;
}
Fields should be PascalCase
Allowed
class SomeClass
{
public string MyProperty { get; set; }
}
Disallowed
class SomeClass
{
public string myProperty { get; set; }
public string _MyProperty { get; set; }
}
Methods, including local functions, should be PascalCase
Allowed
class SomeClass
{
public string GetEmpty() {
var output = LocalFunction();
string LocalFunction() {
return string.Empty();
}
return output;
}
}
Disallowed
class SomeClass
{
public string getEmpty() {
var output = localFunction();
string localFunction() {
return string.Empty();
}
return output;
}
}
All attributes should be on separate lines and be wrapped in their own braces.
Allowed
[FooClass]
[BarClass]
class SomeClass
{
[Foo]
[Bar]
public string MyProperty { get; set; }
}
Disallowed
[FooClass, BarClass]
class SomeClass
{
[Foo][Bar]
public string MyProperty { get; set; }
}
When using the System.IO.Directory
class, it is suggested to use the EnumerateFiles
static method
instead of the GetFiles
method. In the remarks section of the documentation, it is stated that using the EnumerateFiles
method is more efficient because you can start enumerating the collection before all the results are returned:
The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. The returned collection is not cached; each call to the GetEnumerator on the collection will start a new enumeration.
When using the System.IO.Directory
class, it is suggested to use the EnumerateDirectories
static method
instead of the GetDirectories
method. In the remarks section of the documentation, it is stated that using the EnumerateDirectories
method is more efficient because you can start enumerating the collection before all the results are returned:
The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. The returned collection is not cached; each call to the GetEnumerator on the collection will start a new enumeration.