Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for macro conditions to named enums #247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

skorulis-ap
Copy link
Collaborator

@skorulis-ap skorulis-ap commented Feb 12, 2025

  • If a group of named registrations all have the same #if condition then the resolver and the enum are both wrapped in the same condition.
  • If registrations in the group have different #if conditions, the resolver will not have a condition and the enum cases will be wrapped in #if conditions from the individual registrations.

@skorulis-ap skorulis-ap force-pushed the skorulis/conditional-enums branch from 78088be to 254ac4c Compare February 12, 2025 00:28
extension DeclSyntaxProtocol {

// Wrap the declaration in an #if where needed
func maybeWithCondition(ifConfigCondition: ExprSyntax?) -> DeclSyntaxProtocol {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This helper prevents some duplication


extension NamedRegistrationGroup {
// Generate the enum for this group of named registrations
func enumSourceCode(assemblyName: String) throws -> DeclSyntaxProtocol {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this out of TypeSafetySourceFile to make this code easier to test in isolation.

@skorulis-ap skorulis-ap force-pushed the skorulis/conditional-enums branch from 254ac4c to 406686c Compare February 20, 2025 20:57
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.

1 participant