-
-
Notifications
You must be signed in to change notification settings - Fork 0
Rules
We use tabs
Reason: because it is a more popular way for dotnet applications
Alway put cancellation token in method signature even if this operation does not need it. In this case use default keyword
For example
[HttpPost]
public async Task<IActionResult> Add(
// Other parameters...
CancellationToken ct
)
{
// Logic...
await _db.SaveChangesAsync(ct);
// or
await _db.SaveChangesAsync(default);
return Ok();
}Reason: another developer who doesn't know the original idea won't understand what you wanted to do: either you didn't specify the ct on purpose, or you simply forgot to add it. If you use the default keyword, you clearly show that you didn't forget anything.
Use braces instead of single lines
For example
// Bad
if (a)
M1();
else if (b)
M2();
else
M3();
// Good
if (a)
{
M1();
}
else if (b)
{
M2();
}
else
{
M3();
}Reason: if you add more logic to the methods, you will have to add curly brackets, and this is not very convenient, especially when solving git conflicts, and sometimes it is not very convenient to read. So saving lines does not make sense
ToDo
ToDo
ToDo