Skip to content

Conversation

@xC0dex
Copy link

@xC0dex xC0dex commented Jan 15, 2026

Currently, the generated extension class is always public, if the enum is also public. This may not be entirely ideal in certain circumstances.

This PR adds support for controlling the accessibility of generated enum extension classes.
Extension accessibility can now be configured globally via the EnumGenerator_ForceInternal MSBuild property or per enum using the IsInternal flag on the [EnumExtensions] attribute.
By default, extensions follow the enum’s accessibility, but public enums can now explicitly generate internal extensions when needed.

This is one possible approach to implementing it. Feel free to edit or close the PR. 🙂

@xC0dex xC0dex changed the title feat: support configurable extension access modifier feat: support configurable access modifier Jan 15, 2026
@xC0dex xC0dex changed the title feat: support configurable access modifier feat: add ForceInternal configuration option Jan 15, 2026
@xC0dex xC0dex marked this pull request as ready for review January 15, 2026 11:25
@andrewlock
Copy link
Owner

andrewlock commented Jan 15, 2026

Thanks @xC0dex! I'd like to add some tests for this, but I'm happy to take it unless you'd like to 🙂 I'd like to add

  • Update the SourceGenerationSnapshotTests to test the alternative geenration
  • Add a unit tests snapshot for a forced-internal enum
  • Add an integration test to force internal
    • This is probably the biggest pain, we'll likely need to add a new enum, because forcing internal means some of the tests won't work as written

I'm going to push out a new version of the generator very shortly, and I'm going to be OOO for a couple of weeks after, so this probably won't make it in, sorry!

@ScarletKuro
Copy link

Very excited for this feature to use in MudBlazor

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.

3 participants