We would like to be more focused on following the coding conventions popular in .NET community. Currently the coding style in the driver code is not very consistent, but the goal is to improve it by following coding convention rules.
Use s_
prefix + camelCase, eg. s_someVariable
.
public class ExampleClass
{
private static Something s_someVariable;
internal static Something s_someInternalVariable;
}
Use t_
prefix + camelCase, eg. t_someVariable
.
public class ExampleClass
{
[ThreadStatic]
private static Something t_someVariable;
[ThreadStatic]
internal static Something t_someInternalVariable;
}
Use PascalCase, eg. SomeVariable
.
public class ExampleClass
{
public static Something SomeVariable;
}
Use always PascalCase regardless of the modifier public/private/internal.
public class ExampleClass
{
public int SomeInteger = 1234;
private string SomeString = "abc";
internal string SomeInternalString = "xyz";
}
Use _
prefix + camelCase, eg. _someVariable
.
public class ExampleClass
{
private Something _someVariable;
internal Something _someInternalVariable;
}
Use PascalCase, eg. SomeVariable
.
public class ExampleClass
{
public Something SomeVariable;
}
Use PascalCase, eg. SomeProperty
.
public ExampleProperty
{
get;
set;
}
Use camelCase, eg. someVariable
.
{
Something someVariable;
}
Use PascalCase, eg. SomeConst
.
{
const SomeConst = 1;
}
Use PascalCase, eg. SomeMethod
for all methods (normal, object members, static members, public, internal, private).
void SomeMethod() {
}
Use PascalCase for both: enumeration name and values, eg. SomeEnumeration
with value SomeValue
.
public enum SomeEnumeration
{
SomeValue = 5,
SomeOtherValue = 7
}
Use I
prefix (without Interface
postfix), eg. IName
.
interface IName
{
}
Use Snowflake
prefix, eg. SnowflakeDbCommand
because the class extends DbCommand
abstract class and implements IDbCommand
interface.
public class SnowflakeDbCommand : DbCommand
{
}
Don't use any particular prefix if the class does not implement any standard interface.
public class FastParser
{
}
If possible split the test code into arrange
, act
and assert
blocks.
// arrange
var config = new HttpClientConfig(
true,
"snowflake.com",
"123",
"testUser",
"proxyPassword",
"localhost",
false,
false
);
// act
var handler = (HttpClientHandler) HttpUtil.Instance.SetupCustomHttpHandler(config);
// assert
Assert.IsTrue(handler.UseProxy);
Assert.IsNotNull(handler.Proxy);
Use test names in PascalCase notation (but without MS proposed underline characters between logical parts of the test name addressing 3a pattern).
[Test]
public void TestThatLoginWithInvalidPassowrdFails() {
}
[Test]
public void TestCreatingHttpClientHandlerWithProxy() {
}