Skip to content

Commit 18c90d9

Browse files
authored
Merge pull request #69 from EFNext/fix/diagnostics-refatoring
reordered and cleaned up existing diagnostics
2 parents a1d0138 + b0c6f61 commit 18c90d9

35 files changed

Lines changed: 526 additions & 416 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ ExpressiveSharp.EntityFrameworkCore.CodeFixers (Roslyn analyzer, netstandard2.0)
119119

120120
### Diagnostics
121121

122-
22 diagnostic codes (EXP0001–EXP0012, EXP0018 in `src/ExpressiveSharp.Generator/Infrastructure/Diagnostics.cs`, EXP0013 in CodeFixers, EXP0014–EXP0020 for `[ExpressiveFor]` validation, EXP0036/EXP0037 in `WindowFunctionLiteralArgsAnalyzer`). Key ones: EXP0001 (requires body), EXP0004 (block body requires opt-in), EXP0008 (unsupported operation, default value used), EXP0018 (unsupported operation ignored, e.g. alignment specifiers), EXP0019 (`[ExpressiveFor]` conflicts with `[Expressive]`), EXP0036 (`Ntile` non-positive literal), EXP0037 (`Lag`/`Lead` negative literal offset).
122+
34 diagnostic codes: a contiguous `EXP0001–EXP0031` plus the migration band `EXP1001–EXP1003`. Generator diagnostics live in `src/ExpressiveSharp.Generator/Infrastructure/Diagnostics.cs` (`EXP0001–EXP0012` core `[Expressive]`, `EXP0013–EXP0017` `[ExpressiveFor]`, `EXP0018–EXP0022` `[ExpressiveProperty]`, `EXP0023` ignored operation, `EXP0024` virtual member); analyzer diagnostics `EXP0025–EXP0029` in `ExpressiveSharp.CodeFixers`; window-function diagnostics `EXP0030`/`EXP0031` in `WindowFunctionLiteralArgsAnalyzer` (`EntityFrameworkCore.CodeFixers`); migration `EXP1001–EXP1003` in `MigrationAnalyzer`. The canonical reference is `docs/reference/diagnostics.md`. Key ones: EXP0001 (requires body), EXP0004 (block body requires opt-in), EXP0008 (unsupported operation, default value used), EXP0023 (unsupported operation ignored, e.g. alignment specifiers), EXP0016 (`[ExpressiveFor]` conflicts with `[Expressive]`), EXP0030 (`Ntile` non-positive literal), EXP0031 (`Lag`/`Lead` negative literal offset).
123123

124124
## Testing
125125

docs/advanced/limitations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,20 @@ static bool IsNullOrWhiteSpace(string? s)
115115

116116
Expression-tree expansion happens at **compile time** and works purely from the **static (declared) type** of each receiver. It has no runtime instance to inspect, so it cannot honor C# virtual dispatch.
117117

118-
If you mark a `virtual`, `abstract`, or `override` member `[Expressive]` (a default interface member counts too -- it is implicitly virtual), the generator reports [EXP0038](../reference/diagnostics#exp0038). When the member is expanded for a query provider (EF Core, MongoDB), the call is resolved against the declared type and the **base** body is always inlined -- an overridden body in a derived type is never used:
118+
If you mark a `virtual`, `abstract`, or `override` member `[Expressive]` (a default interface member counts too -- it is implicitly virtual), the generator reports [EXP0024](../reference/diagnostics#exp0024). When the member is expanded for a query provider (EF Core, MongoDB), the call is resolved against the declared type and the **base** body is always inlined -- an overridden body in a derived type is never used:
119119

120120
```csharp
121121
public class Animal
122122
{
123123
public string Name { get; set; } = "";
124124

125-
[Expressive] // EXP0038
125+
[Expressive] // EXP0024
126126
public virtual string Describe() => $"Animal: {Name}";
127127
}
128128

129129
public class Dog : Animal
130130
{
131-
[Expressive] // EXP0038
131+
[Expressive] // EXP0024
132132
public override string Describe() => $"Dog: {Name}";
133133
}
134134

@@ -152,7 +152,7 @@ db.Animals.AsExpressive().Select(a => a switch
152152

153153
### Recommended: use a non-virtual static/extension method
154154

155-
Move the logic into a single non-virtual `[Expressive]` method that performs the type test itself. This keeps the polymorphic shape in one place and produces no EXP0038:
155+
Move the logic into a single non-virtual `[Expressive]` method that performs the type test itself. This keeps the polymorphic shape in one place and produces no EXP0024:
156156

157157
```csharp
158158
public static class AnimalExpressions
@@ -169,7 +169,7 @@ db.Animals.AsExpressive().Select(a => a.Describe());
169169
```
170170

171171
::: tip
172-
Declaring entity members `virtual` is common in EF Core because it enables lazy-loading proxies. That remains fine for plain navigation and scalar properties -- EXP0038 only concerns members you *also* mark `[Expressive]`.
172+
Declaring entity members `virtual` is common in EF Core because it enables lazy-loading proxies. That remains fine for plain navigation and scalar properties -- EXP0024 only concerns members you *also* mark `[Expressive]`.
173173
:::
174174

175175
## Performance: First-Execution Overhead

docs/guide/window-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ The package was previously labeled experimental. Upgrading is API-compatible; th
306306

307307
- Direct invocation of a `WindowFunction.*` stub (i.e. outside an EF Core query) now throws an exception that names the method and points at this guide.
308308
- `Ntile(0)` / `Ntile(-1)`, negative literal `Lag`/`Lead` offsets, and `NthValue(0)` now throw `InvalidOperationException` at translation time. Previously these reached the database and produced a provider-specific error.
309-
- New analyzer warnings **EXP0036** (`Ntile` non-positive literal buckets) and **EXP0037** (`Lag`/`Lead` negative literal offsets) may surface on existing code.
309+
- New analyzer warnings **EXP0030** (`Ntile` non-positive literal buckets) and **EXP0031** (`Lag`/`Lead` negative literal offsets) may surface on existing code.
310310

311311
## Next Steps
312312

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ features:
5555

5656
- icon: "\U0001FA7A"
5757
title: Roslyn Analyzers & Code Fixes
58-
details: EXP0001–EXP0036 diagnostics catch projection errors at compile time. Quick-fix actions and migration fixers from Projectables included.
58+
details: EXP0001–EXP0031 diagnostics catch projection errors at compile time. Quick-fix actions and migration fixers from Projectables included.
5959
---
6060

6161
## At a Glance

docs/recipes/external-member-mapping.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Use `[ExpressiveFor]` when:
1212
- You want to override how a specific member translates to SQL
1313

1414
::: info
15-
If a member already has `[Expressive]`, adding `[ExpressiveFor]` targeting it is a compile error (EXP0019). `[ExpressiveFor]` is specifically for members that **do not** have `[Expressive]`.
15+
If a member already has `[Expressive]`, adding `[ExpressiveFor]` targeting it is a compile error (EXP0016). `[ExpressiveFor]` is specifically for members that **do not** have `[Expressive]`.
1616
:::
1717

1818
## Static Method: `Math.Clamp`
@@ -189,11 +189,11 @@ static class DateTimeMappings
189189

190190
| Code | Description |
191191
|------|-------------|
192-
| EXP0014 | `[ExpressiveFor]` target type not found |
193-
| EXP0015 | `[ExpressiveFor]` target member not found on the specified type |
194-
| EXP0017 | Return type of stub does not match target member's return type |
195-
| EXP0019 | Target member already has `[Expressive]` -- use `[Expressive]` directly instead |
196-
| EXP0020 | Duplicate `[ExpressiveFor]` mapping for the same target member |
192+
| EXP0013 | `[ExpressiveFor]` target type not found |
193+
| EXP0014 | `[ExpressiveFor]` target member not found on the specified type |
194+
| EXP0015 | Return type of stub does not match target member's return type |
195+
| EXP0016 | Target member already has `[Expressive]` -- use `[Expressive]` directly instead |
196+
| EXP0017 | Duplicate `[ExpressiveFor]` mapping for the same target member |
197197

198198
## Tips
199199

0 commit comments

Comments
 (0)