1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-08 03:27:04 +09:00

Update coding-style to include target-typed new() guideline (#67061)

* Update coding-style to include target-typed new guideline

Similar to `var` usage, `new()` usage is only allowed when the Type can be understood from the same line.

Fix #53369

* Fix coding style violations
This commit is contained in:
Eric Erhardt 2022-03-23 19:54:51 -05:00 committed by GitHub
parent 0e1c91b603
commit 7508080ebc
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 93 additions and 89 deletions

View file

@ -24,6 +24,7 @@ The general rule we follow is "use Visual Studio defaults".
9. If a file happens to differ in style from these guidelines (e.g. private members are named `m_member`
rather than `_member`), the existing style in that file takes precedence.
10. We only use `var` when the type is explicitly named on the right-hand side, typically due to either `new` or an explicit cast, e.g. `var stream = new FileStream(...)` not `var stream = OpenStandardInput()`.
- Similarly, target-typed `new()` can only be used when the type is explicitly named on the left-hand side, in a variable definition statement or a field definition statement. e.g. `FileStream stream = new(...);`, but not `stream = new(...);` (where the type was specified on a previous line).
11. We use language keywords instead of BCL types (e.g. `int, string, float` instead of `Int32, String, Single`, etc) for both type references as well as method calls (e.g. `int.Parse` instead of `Int32.Parse`). See issue [#13976](https://github.com/dotnet/runtime/issues/13976) for examples.
12. We use PascalCasing to name all our constant local variables and fields. The only exception is for interop code where the constant value should exactly match the name and value of the code you are calling via interop.
13. We use PascalCasing for all method names, including local functions.