Skip to content

Commit f4f5226

Browse files
Update Copilot instructions (#37636)
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
1 parent e762fa9 commit f4f5226

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

.github/copilot-instructions.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
1212
- Use the rules defined in the .editorconfig file in the root of the repository for any ambiguous cases
1313
- Write code that is clean, maintainable, and easy to understand
1414
- Favor readability over brevity, but keep methods focused and concise
15-
- Only add comments rarely to explain why a non-intuitive solution was used. The code should be self-explanatory otherwise
15+
- **Prefer minimal comments** - The code should be self-explanatory. Add comments sparingly and only to explain *why* a non-intuitive solution was necessary, not *what* the code does. Comments are appropriate for complex logic, public APIs, or domain-specific implementations where context would otherwise be unclear
1616
- Add license header to all files:
1717
```
1818
// Licensed to the .NET Foundation under one or more agreements.
@@ -48,8 +48,9 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
4848
- Use `var` for local variables
4949
- Use expression-bodied members where appropriate
5050
- Prefer using collection expressions when possible
51-
- Use `is` pattern matching instead of `as` and null checks
51+
- Use `is` pattern matching instead of `as` followed by null checks (e.g., `if (obj is SomeType typed)` instead of `var typed = obj as SomeType; if (typed != null)`)
5252
- Prefer `switch` expressions over `switch` statements when appropriate
53+
- Prefer pattern matching with `when` clauses in switch expressions for conditional logic
5354
- Prefer field-backed property declarations using field contextual keyword instead of an explicit field.
5455
- Prefer range and index from end operators for indexer access
5556
- The projects use implicit namespaces, so do not add `using` directives for namespaces that are already imported by the project
@@ -89,6 +90,8 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
8990
- Create both unit tests and functional tests where appropriate
9091
- Fix `SQL` and `C#` baselines for tests when necessary by setting the `EF_TEST_REWRITE_BASELINES` env var to `1`
9192
- Run tests with project rebuilding enabled (don't use `--no-build`) to ensure code changes are picked up
93+
- When testing cross-platform code (e.g., file paths, path separators), verify the fix works on both Windows and Linux/macOS
94+
- When testing `dotnet-ef` tool changes, create a test project and manually run the affected commands to verify behavior
9295

9396
#### Environment Setup
9497
- **ALWAYS** run `restore.cmd` (Windows) or `. ./restore.sh` (Linux/Mac) first to restore dependencies
@@ -110,6 +113,13 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
110113
- **ALL** user-facing error messages must use string resources from the `.resx` (and the generated `.Designer.cs`) file corresponding to the project
111114
- Avoid catching exceptions without rethrowing them
112115

116+
## Dependency and Version Management
117+
118+
- **NEVER** hardcode package versions in `.csproj` files
119+
- Check `eng/Versions.props` for existing version properties (e.g., `$(SQLitePCLRawVersion)`) before adding or updating package references
120+
- Use `Directory.Packages.props` for NuGet package version management with Central Package Management (CPM)
121+
- Packages listed in `eng/Version.Details.xml` are managed by Maestro dependency flow and should not be updated manually or by Dependabot
122+
113123
## Asynchronous Programming
114124

115125
- Provide both synchronous and asynchronous versions of methods where appropriate
@@ -129,6 +139,7 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
129139

130140
- Write code that is secure by default. Avoid exposing potentially private or sensitive data
131141
- Make code NativeAOT compatible when possible. This means avoiding dynamic code generation, reflection, and other features that are not compatible with NativeAOT. If not possible, mark the code with an appropriate annotation or throw an exception
142+
- After implementing a fix, review the surrounding code for similar patterns that might need the same change
132143

133144
### Entity Framework Core Specific guidelines
134145

@@ -153,6 +164,32 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
153164
- .github/: GitHub-specific files, workflows, and Copilot instructions
154165
- .config/: AzDo pipelines configuration files
155166

167+
## Pull Request Guidelines
168+
169+
- **ALWAYS** target the `main` branch for new PRs unless explicitly instructed otherwise
170+
- For servicing PRs (fixes targeting release branches), use the following PR description template:
171+
```
172+
Fixes #{issue_number}
173+
174+
**Description**
175+
{Brief description of the issue and fix}
176+
177+
**Customer impact**
178+
{How does the reported issue affect customers? Are there workarounds?}
179+
180+
**How found**
181+
{Was it customer reported or found during verification? How many customers are affected?}
182+
183+
**Regression**
184+
{Is it a regression from a released version? Which one?}
185+
186+
**Testing**
187+
{How the changes were tested}
188+
189+
**Risk**
190+
{Low/Medium/High, with justification}
191+
```
192+
156193
## Overview of Entity Framework Core
157194

158195
Entity Framework Core (EF Core) is an object-database mapper for .NET. Below is a concise summary of its core architecture and concepts:

0 commit comments

Comments
 (0)