Allow virtual expressive members but warn; added documentation on the restriction as well as a suggested workaround#66
Merged
Conversation
… restriction as well as a suggested workaround
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request changes ExpressiveSharp’s behavior around virtual/override [Expressive] members: virtual members are now expanded (using the receiver’s static/declared type) while emitting a new warning (EXP0038) to document the loss of polymorphic dispatch. It also adds test coverage and documentation explaining the limitation and recommended workarounds.
Changes:
- Remove the runtime “polymorphic dispatch gate” during expression replacement so virtual
[Expressive]members can still be expanded for query providers. - Add generator warning EXP0038 for virtual/abstract/override expressive members, plus new docs describing the limitation and workarounds.
- Add/adjust integration and generator tests to validate expansion behavior and the new diagnostic.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ExpressiveSharp.IntegrationTests/Tests/ExpansionEdgeCasesTests.cs | Updates virtual dispatch expansion test expectations; adds local EXP0038 suppression for test types. |
| tests/ExpressiveSharp.IntegrationTests/Scenarios/Store/Models/LineItem.cs | Adds a virtual [Expressive] property (suppressed EXP0038) to support EF Core regression coverage. |
| tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/InterfaceTests.cs | Updates default interface member test to expect EXP0038 warning. |
| tests/ExpressiveSharp.Generator.Tests/ExpressiveGenerator/DiagnosticTests.cs | Adds new tests asserting EXP0038 behavior for virtual/override vs non-virtual members. |
| tests/ExpressiveSharp.EntityFrameworkCore.IntegrationTests/Infrastructure/StoreQueryTestBase.cs | Adds EF Core regression test ensuring virtual expressive member expands and translates to SQL. |
| src/ExpressiveSharp/Services/ExpressiveReplacer.cs | Removes checks that previously skipped expansion for polymorphic members. |
| src/ExpressiveSharp.Generator/Infrastructure/Diagnostics.cs | Introduces EXP0038 diagnostic descriptor. |
| src/ExpressiveSharp.Generator/ExpressiveGenerator.cs | Emits EXP0038 when [Expressive] is applied to virtual/abstract/override members. |
| docs/reference/diagnostics.md | Documents EXP0038 in the diagnostics reference. |
| docs/advanced/limitations.md | Adds a detailed “Virtual and Polymorphic Members” limitations section with workarounds. |
| .devcontainer/devcontainer-lock.json | Adds devcontainer feature lock file for reproducible devcontainer setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -80,8 +77,7 @@ protected override Expression VisitMethodCall(MethodCallExpression node) | |||
|
|
|||
| var methodInfo = node.Object?.Type.GetConcreteMethod(node.Method) ?? node.Method; | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.