Skip to content

Commit 7b02f61

Browse files
fabiocavCopilot
andauthored
Initial copilot-instructions.md with C# guidelines (#11328)
* Initial copilot-instructions.md with C# guidelines * Update .github/copilot-instructions.md Co-authored-by: Copilot <[email protected]> * Update .github/copilot-instructions.md Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 9922e35 commit 7b02f61

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/copilot-instructions.md

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

0 commit comments

Comments
 (0)