Skip to content

Commit 89b27fa

Browse files
authored
Create copilot-instructions.md (dotnet#62005)
1 parent 795e202 commit 89b27fa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

.github/copilot-instructions.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## General
2+
3+
* Make only high confidence suggestions when reviewing code changes.
4+
* Always use the latest version C#, currently C# 13 features.
5+
* Never change global.json unless explicitly asked to.
6+
7+
## Formatting
8+
9+
* Apply code-formatting style defined in `.editorconfig`.
10+
* Prefer file-scoped namespace declarations and single-line using directives.
11+
* Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.).
12+
* Ensure that the final return statement of a method is on its own line.
13+
* Use pattern matching and switch expressions wherever possible.
14+
* Use `nameof` instead of string literals when referring to member names.
15+
* Ensure that XML doc comments are created for any public APIs. When applicable, include <example> and <code> documentation in the comments.
16+
17+
### Nullable Reference Types
18+
19+
* Declare variables non-nullable, and check for `null` at entry points.
20+
* Always use `is null` or `is not null` instead of `== null` or `!= null`.
21+
* Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.
22+
23+
### Testing
24+
25+
* We use xUnit SDK v3 for tests.
26+
* Do not emit "Act", "Arrange" or "Assert" comments.
27+
* Use Moq for mocking in tests.
28+
* Copy existing style in nearby files for test method names and capitalization.
29+
30+
## Running tests
31+
32+
* To build and run tests in the repo, use the `build.sh` script that is located in each subdirectory within the `src` folder. For example, to run the build with tests in the `src/Http` directory, run `./src/Http/build.sh -test`.

0 commit comments

Comments
 (0)