feat: support abstract intermediate base classes in generator#4
feat: support abstract intermediate base classes in generator#4ncipollina merged 3 commits intomainfrom
Conversation
Skip abstract classes in EnumSyntaxProvider so that CRTP-style abstract base classes (e.g. DomainEnum<TSelf> : OptimizedEnum<TSelf, int>) no longer trigger spurious OE0004 diagnostics. Concrete subclasses are still processed normally with TEnum correctly resolved to the concrete type via the full inheritance chain walk. Add two tests: - AbstractBase_WithCRTP: verifies exactly one tree is generated for the concrete subclass with no diagnostics from the abstract base - AbstractBase_Alone_ProducesNoOutput: verifies a standalone abstract base produces zero output and zero diagnostics Bump version to 1.1.1. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6ce1618ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/LayeredCraft.OptimizedEnums.Generator/Providers/EnumSyntaxProvider.cs
Outdated
Show resolved
Hide resolved
Abstract classes that declare members (e.g. abstract enums with concrete nested implementations) should still generate normally. The IsAbstract guard now lives inside the `validMembers.Count == 0` block, so only memberless abstract base classes are skipped silently. Adds AbstractEnum_WithMembers_StillGenerates regression test and updates assertion messages for AbstractBase_Alone_ProducesNoOutput. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eef4cb0e15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/LayeredCraft.OptimizedEnums.Generator/Providers/EnumSyntaxProvider.cs
Outdated
Show resolved
Hide resolved
- OE0101 (non-private constructor) is now suppressed for abstract classes since a protected constructor is idiomatic and required so concrete subclasses can invoke base(...) - Abstract classes with no valid members but collected diagnostics (e.g. OE0102 on non-readonly fields) now return an EnumInfo so those diagnostics are reported; only truly clean abstract bases (no diagnostics) are silently skipped - Removes the now-unnecessary DiagnosticsToSuppress for OE0101 in AbstractEnum_WithMembers_StillGenerates test - Adds Warning_AbstractBase_WithOnlyInvalidMembers_StillSurfacesDiagnostics regression test verifying OE0102 is emitted for abstract types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@codex review |
|
@claude review |
|
Codex Review: Didn't find any major issues. Swish! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds support for CRTP-style abstract base classes that sit between a concrete enum and
OptimizedEnum<TEnum, TValue>. Previously, the abstract base class itself would be processed by the generator and emit a spurious OE0004 (no members found) diagnostic, blocking the pattern entirely.Changes
src/LayeredCraft.OptimizedEnums.Generator/Providers/EnumSyntaxProvider.csif (classSymbol.IsAbstract) return nullguard after theFindOptimizedEnumBasecheck — abstract classes are skipped silently, as they are intermediate base classes rather than concrete enumstests/.../GeneratorVerifyTests.csAbstractBase_WithCRTP— verifies the CRTP pattern generates exactly one tree (for the concrete subclass) with no spurious diagnostics from the abstract baseAbstractBase_Alone_ProducesNoOutput— verifies a standalone abstract base produces zero output and zero diagnosticsDirectory.Build.props— version bumped1.1.0→1.1.1Validation
Release Notes
1.1.1— Abstract intermediate base classes using the CRTP pattern are now silently skipped by the generator. Concrete subclasses continue to generate correctly withTEnumresolved to the concrete type.🤖 Generated with Claude Code