Skip to content

fix: inline [Expressive] enum methods instead of expanding per value( - #119

Open
koenbeuk wants to merge 1 commit into
mainfrom
fix/enum-expansion-expressive-methods
Open

koenbeuk wants to merge 1 commit into
mainfrom
fix/enum-expansion-expressive-methods

Conversation

@koenbeuk

@koenbeuk koenbeuk commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

fix: inline [Expressive] enum methods instead of expanding per value

Fixes #111

@koenbeuk

Copy link
Copy Markdown
Collaborator Author

an [Expressive] enum method whose body the provider cannot translate no longer works through per-value expansion. Remove [Expressive] from such a method to restore it.

@koenbeuk

Copy link
Copy Markdown
Collaborator Author

I'm not sure how I feel about this one just yet, in my mind its the sensible approach but now things that used to just work (although less effectively) might now break

@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...veSharp.CodeFixers/AddExpressiveCodeFixProvider.cs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active moderate issue causes EXP0033 to report enum-method expansion even though extension-container methods are emitted without expansion, making the diagnostic and generated behavior inconsistent.

1 open issue
What changed in this PR

This PR changes enum method handling so methods marked [Expressive] are emitted as direct calls and subsequently inlined, avoiding unnecessary per-value CASE expressions while preserving provider-friendly predicates.

Changes:

  • Skip per-value enum expansion for [Expressive] methods.
  • Add EXP0033 diagnostics and an [Expressive] code fix for unmarked enum methods.
  • Add generator, integration, analyzer, EF SQL, snapshot, and documentation coverage.
File Description
tests/​ExpressiveSharp.IntegrationTests/​Tests/​StoreQueryTests.cs Tests nested expressive enum method evaluation in store queries.
tests/​ExpressiveSharp.IntegrationTests/​Scenarios/​Store/​Models/​OrderStatus.cs Adds an expressive enum predicate backed by a status collection.
tests/​ExpressiveSharp.IntegrationTests/​Scenarios/​Store/​Models/​Order.cs Adds a nested expressive property that uses the enum predicate.
tests/​ExpressiveSharp.Generator.Tests/​ExpressiveGenerator/​MissingExpressiveDiagnosticTests.cs Tests EXP0033 reporting and suppression behavior.
tests/​ExpressiveSharp.Generator.Tests/​ExpressiveGenerator/​EnumTests.ExpressiveEnumMethod_IsCalledDirectlyInsteadOfExpanded.verified.txt Updates the generated-code snapshot for direct expressive enum method calls.
tests/​ExpressiveSharp.Generator.Tests/​ExpressiveGenerator/​EnumTests.cs Verifies that expressive enum methods are emitted as direct calls.
tests/​ExpressiveSharp.Generator.Tests/​CodeFixers/​AddExpressiveCodeFixProviderTests.cs Tests applying the [Expressive] code fix for EXP0033.
tests/​ExpressiveSharp.EntityFrameworkCore.IntegrationTests/​Infrastructure/​ExpressiveExpansionTestBase.cs Verifies EF SQL avoids per-value enum CASE expansion.
src/​ExpressiveSharp.Generator/​Infrastructure/​Diagnostics.cs Registers EXP0033 in the generator diagnostic documentation.
src/​ExpressiveSharp.Generator/​Emitter/​ExpressionTreeEmitter.cs Bypasses per-value enum expansion for [Expressive] methods.
src/​ExpressiveSharp.CodeFixers/​MissingExpressiveAnalyzer.cs Adds EXP0033 classification and reporting for unmarked enum methods.
src/​ExpressiveSharp.CodeFixers/​AddExpressiveCodeFixProvider.cs Enables the [Expressive] code fix for EXP0033.
docs/​reference/​expressive-attribute.md Documents direct inlining behavior for expressive enum methods.
docs/​reference/​diagnostics.md Documents EXP0033, its trade-offs, and remediation options.
docs/​guide/​migration-from-projectables.md Clarifies enum method migration behavior from Projectables.
docs/​advanced/​limitations.md Updates documentation for enum method expansion limitations.
CLAUDE.md Updates the diagnostic inventory and EXP0033 architecture notes.

Review effort: Lite

Comment on lines +130 to +131
if (HasEnumReceiver(invokedMethod))
descriptor = EnumMethodExpandedPerValue;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enum method expansion turns [Expressive] enum predicates into a CASE over every value, defeating indexes

2 participants