Skip to content

Commit 3cd1e84

Browse files
committed
Clarify some of the Copilot instructions
1 parent 0b27eb0 commit 3cd1e84

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

.github/copilot-instructions.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
1919
// The .NET Foundation licenses this file to you under the MIT license.
2020
```
2121
- Don't add the UTF-8 BOM to files unless they have non-ASCII characters
22-
- All types should be public. Types in .Internal namespaces should have this comment on all members:
23-
```
22+
- Avoid breaking public APIs. If you need to break a public API, add a new API instead and mark the old one as obsolete. Use `ObsoleteAttribute` with the message pointing to the new API
23+
- All types should be public by default
24+
- Types in `.Internal` namespaces or annotated with `[EntityFrameworkInternal]` require this XML doc comment on ALL members:
25+
```csharp
2426
/// <summary>
2527
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
2628
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
2729
/// any release. You should only use it directly in your code with extreme caution and knowing that
2830
/// doing so can result in application failures when updating to a new Entity Framework Core release.
2931
/// </summary>
3032
```
31-
- Avoid breaking public APIs. If you need to break a public API, add a new API instead and mark the old one as obsolete. Use `ObsoleteAttribute` with the message pointing to the new API
3233

3334
### Formatting
3435

@@ -87,8 +88,12 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
8788
- Follow the existing test patterns in the corresponding test projects
8889
- Create both unit tests and functional tests where appropriate
8990
- Fix `SQL` and `C#` baselines for tests when necessary by setting the `EF_TEST_REWRITE_BASELINES` env var to `1`
90-
- Before building or running the tests execute `restore.cmd` or `restore.sh` and `activate.ps1` or `activate.sh` to set up the environment
91-
- When running the tests specify the test project and let it be rebuilt by not adding `--no-build`
91+
- Run tests with project rebuilding enabled (don't use `--no-build`) to ensure code changes are picked up
92+
93+
#### Environment Setup
94+
- **ALWAYS** run `restore.cmd` (Windows) or `. ./restore.sh` (Linux/Mac) first to restore dependencies
95+
- **ALWAYS** run `. .\activate.ps1` (PowerShell) or `. ./activate.sh` (Bash) to set up the development environment with correct SDK versions before building or running the tests
96+
- These scripts set `DOTNET_ROOT`, `DOTNET_MULTILEVEL_LOOKUP`, and PATH for the project's specific .NET SDK version
9297

9398
## Documentation
9499

@@ -102,7 +107,7 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
102107
## Error Handling
103108

104109
- Use appropriate exception types.
105-
- Include helpful error messages stored in the .resx file corresponding to the project
110+
- **ALL** user-facing error messages must use string resources from the `.resx` (and the generated `.Designer.cs`) file corresponding to the project
106111
- Avoid catching exceptions without rethrowing them
107112

108113
## Asynchronous Programming
@@ -127,18 +132,15 @@ If you are not sure, do not guess, just tell that you don't know or ask clarifyi
127132

128133
### Entity Framework Core Specific guidelines
129134

130-
- Follow the provider pattern when extending EF Core's capabilities for specific databases
131-
- Follow the existing model building design patterns
132-
- Add corresponding methods to the `*Builder`, `*Configuration`, `*Extensions`, `IConvention*Builder`, `IReadOnly*`, `IMutable*`and `IConvention*` types as needed
133-
- Make corresponding changes to the `Runtime*` types as needed.
134-
- For Relational-specific model changes also modify the `RelationalModel` and `*AnnotationProvider` types.
135-
- Make corresponding changes to the `CSharpRuntimeModelCodeGenerator`, `*CSharpRuntimeAnnotationCodeGenerator` and `CSharpDbContextGenerator` types as needed
136-
- Use the logging infrastructure for diagnostics
135+
- Use the logging infrastructure for diagnostics and interception
137136
- Prefer using `Check.DebugAssert` instead of `Debug.Assert` or comments
138137
- Use `Check.NotNull` and `Check.NotEmpty` for preconditions in public APIs
138+
- The methods in `Check` class use `[CallerArgumentExpression]` to automatically capture parameter names
139139
- Unit tests should build the model using the corresponding `*TestHelpers.Instance.CreateConventionBuilder()` model and finalizing it
140-
- The services should be resolved from the `IServiceProvider` returned by `*TestHelpers.Instance.CreateContextServices`, note that it has overloads allowing to specify the model and mock services
140+
- The services in unit tests should be resolved from the `IServiceProvider` returned by `*TestHelpers.Instance.CreateContextServices`, note that it has overloads allowing to specify the model and mock services
141141
- For functional tests, create tests in projects corresponding to the database providers that derive from the appropriate test base classes in the `EFCore.*Specification.Tests` projects
142+
- Each provider has its own project structure: `EFCore.{Provider}`, `EFCore.{Provider}.Tests`, `EFCore.{Provider}.FunctionalTests`
143+
- Specification tests (`EFCore.*.Specification.Tests`) define provider-agnostic functional tests
142144

143145
## Repository Structure
144146

@@ -191,8 +193,12 @@ Entity Framework Core (EF Core) is an object-database mapper for .NET. Below is
191193
### Model Building & Conventions
192194
- The model defines entities, properties, keys, relationships, and mappings.
193195
- Built via conventions, data annotations, and the fluent API (`OnModelCreating`).
194-
- Pre-convention configuration allows global rules.
196+
- Pre-convention configuration allows specifying model-wide rules and change used conventions.
197+
- API follows the pattern: `*Builder``IConvention*Builder`, `IReadOnly*``IMutable*``IConvention*``IRuntime*`
198+
- The interfaces are implemented by mutable and runtime models that provide the same behavior, but different perf characteristics
195199
- Model is cached for performance.
200+
- Compiled model is generated by `CSharpRuntimeModelCodeGenerator`, `*CSharpRuntimeAnnotationCodeGenerator` and `CSharpDbContextGenerator`
201+
- Relational providers also use `RelationalModel` and `*AnnotationProvider`
196202

197203
### Model Components
198204
- Entity Types: .NET classes mapped to tables/collections.

0 commit comments

Comments
 (0)