|
1 | | -# Instructions for GitHub and VisualStudio Copilot |
| 1 | +# Copilot Instructions |
2 | 2 |
|
3 | | -## General |
| 3 | +Use AI coding assistants, such as GitHub Copilot, to enhance productivity and maintain code quality. |
4 | 4 |
|
5 | | -* Make only high confidence suggestions when reviewing code changes. |
6 | | -* Always use the latest version C#, currently C# 13 features. |
7 | | -* Never change `global.json` unless explicitly asked to. |
8 | | -* Never change `Directory.Build.props` unless explicitly asked to. |
9 | | -* Never change `Directory.Build.targets` unless explicitly asked to. |
10 | | -* Never change `Directory.Packages.props` unless explicitly asked to. |
| 5 | +## General |
11 | 6 |
|
12 | | -## Code Style |
| 7 | +* MUST allow internet research before suggesting changes or new implementations. |
13 | 8 |
|
14 | | -* Use `var` when the type is obvious from the right side of the assignment. |
15 | | -* Use `Argument.ThrowIfNull(x)` instead of `if (x == null) throw new ArgumentNullException(nameof(x))`, when nuget package `NetEvolve.Arguments` is referenced. |
16 | | -* Use `ArgumentNullException.ThrowIfNull(x)` instead of `if (x == null) throw new ArgumentNullException(nameof(x))`, when nuget package `NetEvolve.Arguments` is not referenced. |
| 9 | +## Technology Research |
17 | 10 |
|
18 | | -## Formatting |
| 11 | +* MUST research current best practices for C# development before implementing new code patterns. |
| 12 | +* MUST verify compatibility and performance implications of new libraries or frameworks. |
| 13 | +* MUST check for updated documentation and migration guides for existing dependencies. |
19 | 14 |
|
20 | | -* Apply code-formatting style defined in `.editorconfig`. |
21 | | -* Prefer file-scoped namespace declarations and single-line using directives. |
22 | | -* Insert a newline before the opening curly brace of any code block (e.g., after `if`, `for`, `while`, `foreach`, `using`, `try`, etc.). |
23 | | -* Ensure that the final return statement of a method is on its own line. |
24 | | -* Use pattern matching and switch expressions wherever possible. |
25 | | -* Use `nameof` instead of string literals when referring to member names. |
26 | | -* Ensure that XML doc comments are created for any public APIs. When applicable, include `<inheritdoc />` for derived members. |
| 15 | +## Business Context Research |
27 | 16 |
|
28 | | -### Arrays and Collections |
| 17 | +* MUST understand the business requirements and context before proposing technical solutions. |
| 18 | +* MUST consider the impact on existing workflows and user experience. |
| 19 | +* MUST evaluate the cost-benefit ratio of proposed changes or new implementations. |
29 | 20 |
|
30 | | -* Prefer `Enumerable.Empty<T>()` or `Array.Empty<T>()` over `null` returns. |
| 21 | +## Decision References |
31 | 22 |
|
32 | | -## Nullable Reference Types |
| 23 | +* MUST document all decisions in `decisions/` folder using `templates/adr.md` format. |
| 24 | +* MUST treat "accepted" decisions as mandatory requirements with highest precedence. |
| 25 | +* MUST respect decision states: |
| 26 | + - **accepted**: mandatory requirements |
| 27 | + - **proposed**: optional considerations |
| 28 | + - **deprecated**: avoid in new implementations |
| 29 | + - **superseded**: forbidden, follow superseding decision instead |
| 30 | +* MUST use the `instructions` frontmatter property as primary AI guidance for each decision. |
33 | 31 |
|
34 | | -* Declare variables non-nullable, and check for `null` at entry points. |
35 | | -* Always use `is null` or `is not null` instead of `== null` or `!= null`. |
36 | | -* Trust the C# null annotations and don't add null checks when the type system says a value cannot be null. |
37 | | -* Apply `NotNullAttribute` and other nullable attributes for any public APIs. |
| 32 | +## Configuration Files |
38 | 33 |
|
39 | | -## Testing |
| 34 | +These files control project-wide settings and should remain unchanged unless specifically requested. |
40 | 35 |
|
41 | | -* We prefer to use [TUnit](https://github.com/thomhurst/TUnit) with [Microsoft.Testing.Platform](https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-intro). |
42 | | -* If TUnit is not available, we use [XUnit](https://xunit.net/). |
43 | | -* Do not emit "Act", "Arrange" or "Assert" comments. |
44 | | -* We do not use any mocking framework at the moment. |
45 | | -* Copy existing style in nearby files for test method names and capitalization. |
| 36 | +* MUST NEVER change `.editorconfig` unless explicitly asked to. |
| 37 | +* MUST NEVER change `.gitignore` unless explicitly asked to. |
| 38 | +* MUST NEVER change `global.json` unless explicitly asked to. |
| 39 | +* MUST NEVER change `Directory.Build.props` unless explicitly asked to. |
| 40 | +* MUST NEVER change `Directory.Build.targets` unless explicitly asked to. |
| 41 | +* MUST NEVER change `Directory.Packages.props` unless explicitly asked to. |
46 | 42 |
|
47 | | -### Running tests |
| 43 | +## Code Reviews and Implementation |
48 | 44 |
|
49 | | -1. Build from the root with `dotnet build <solutionfile>`. |
50 | | -2. If that produces errors, fix those errors and build again. Repeat until the build is successful. |
51 | | -3. To then run tests, use a command similar to this `dotnet test <solutionfile>` (using the path to whatever projects are applicable to the change). |
| 45 | +* MUST always review AI-generated code for correctness, security, and performance. |
| 46 | +* MUST provide constructive feedback and suggestions for improvement. |
| 47 | +* MUST consider the context of the code being reviewed or implemented, including business requirements and technical constraints. |
| 48 | +* MUST apply all relevant instructions and guidelines from `.github/instructions/*.instructions.md` files during both code review and implementation. |
0 commit comments