Skip to content

fix(enums): skip nested StringEnum generation#31

Merged
senrecep merged 3 commits into
senrecep:mainfrom
kathelon:fix/string-enum-nested-filter
May 27, 2026
Merged

fix(enums): skip nested StringEnum generation#31
senrecep merged 3 commits into
senrecep:mainfrom
kathelon:fix/string-enum-nested-filter

Conversation

@kathelon

Copy link
Copy Markdown
Contributor

Summary

  • skip [StringEnum] generation for nested enums by requiring top-level enum symbols in the incremental pipeline
  • add a regression test that keeps a nested public enum in the test assembly and verifies no generated extensions type is emitted
  • update the README test badge count to match the added test

Why

The generator was only filtering out private enums. A nested public enum inside a type could still enter the pipeline even though the implementation assumes top-level enums when building generated type names.

Validation

  • dotnet test CSharpEssentials.Tests/CSharpEssentials.Tests.csproj --filter StringEnumGeneratorTests
  • dotnet build

Fixes #5.

@kathelon
kathelon marked this pull request as ready for review May 27, 2026 19:42
@senrecep

senrecep commented May 27, 2026

Copy link
Copy Markdown
Owner

Fix looks correct — ContainingType is null covers all nesting levels.

Two small things:

Test nameNested_Enum_Should_Not_Generate_Extensions doesn't say what's being tested. Other tests in the project follow MethodName_Should_X_When_Y, this one drifts from that.

Edge case — only class-nested is covered. A struct-nested test would be nice to confirm the same behavior holds there too.

Neither is a blocker, worth a look while the PR is open.

@senrecep
senrecep merged commit c5fa712 into senrecep:main May 27, 2026
8 checks passed
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.

feat(enums): Add StringEnum Roslyn incremental source generator

2 participants