Skip to content

Commit 1a89fdb

Browse files
authored
Add copilot instructions (#907)
1 parent db9b9f3 commit 1a89fdb

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.github/copilot-instructions.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
**Any code you commit SHOULD compile, and new and existing tests related to the change SHOULD pass.**
2+
3+
You MUST make your best effort to ensure your changes satisfy those criteria before committing. If for any reason you were unable to build or test the changes, you MUST report that. You MUST NOT claim success unless all builds and tests pass as described above.
4+
5+
Do not complete without checking the relevant code builds and relevant tests still pass after the last edits you make. Do not simply assume that your changes fix test failures you see, actually build and run those tests again to confirm.
6+
7+
You MUST follow all code-formatting and naming conventions defined in [`.editorconfig`](/.editorconfig).
8+
9+
In addition to the rules enforced by `.editorconfig`, you SHOULD:
10+
11+
- Prefer file-scoped namespace declarations and single-line using directives.
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+
- Always use `is null` or `is not null` instead of `== null` or `!= null`.
16+
- Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.
17+
- Prefer `?.` if applicable (e.g. `scope?.Dispose()`).
18+
- Use `ObjectDisposedException.ThrowIf` where applicable.
19+
- When adding new unit tests, strongly prefer to add them to existing test code files rather than creating new code files.
20+
- When running tests, if possible use filters and check test run counts, or look at test logs, to ensure they actually ran.
21+
- Do not finish work with any tests commented out or disabled that were not previously commented out or disabled.
22+
- Do not update `global.json` file
23+
- When writing tests, do not emit "Act", "Arrange" or "Assert" comments.
24+
- There should be no trailing whitespace in any lines.
25+
- There should be an empty line before the beginning of XML documentation comments if there is code before them.
26+
27+
## Implementing Roslyn analyzers
28+
29+
- When creating a new rule, create a new constant in `src/Meziantou.Analyzer/RuleIdentifiers.cs` using the name of the new rule. The value must be unique and incremented from the last rule.
30+
- The analyzers must be under `src/Meziantou.Analyzer/Rules/`
31+
- The code fixers must be under `src/Meziantou.Analyzer.CodeFixers/Rules`
32+
- The tests must be under `tests/Meziantou.Analyzer.Test/Rules`
33+
34+
The analyzer must use `IOperation` or `ISymbol` to analyze the content. Only fallback to `SyntaxNode` when the other ways are not supported.
35+
36+
The tests must indicates which part of the snippet must report a diagnostic using the `[|code|]` syntax or `{|id:code|}` syntax. Do not explicitly indicates lines or columns.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See https://docs.github.com/en/copilot/customizing-copilot/customizing-the-development-environment-for-copilot-coding-agent
2+
name: "Copilot Setup Steps"
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
13+
jobs:
14+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
15+
copilot-setup-steps:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
21+
steps:
22+
- uses: actions/checkout@v5
23+
- uses: actions/setup-dotnet@v5
24+
with:
25+
global-json-file: './global.json'
26+
27+
- name: Restore solution
28+
run: dotnet restore

0 commit comments

Comments
 (0)