Skip to content

Conversation

@pavelkouril
Copy link
Contributor

@pavelkouril pavelkouril commented Oct 5, 2025

At first I just wanted to do small cleanup (e.g. utility methods to reduce repeating code etc.), but in the end I'm opting out for a bigger changes. My goal is to split the codegen from 2 logic passes (build + generate) all happening in the *Instance classes, into 3 more separate passes.

The result should be a less hacky and less error prone generator. 🤞

High-level overview of the changes, with description of the pass splits:

  1. Parsing will parse the metal-cpp headers into the *Instance model classes and will also collect the selector definitions
  2. Linking will take the parsed model data and resolve selectors to the actually parsed definitions, type hierarchy and others and basically prepare model representing the final C# code with C# namings
  3. Codegen goes over the C# model from linking and just emits it with more generic codepaths

Naming is not final, I am open to suggestions.

Current state is nearly final, just need to cleanup the changes & finalize naming. Other than that, the changes fixed some wrong selectors and now the output is stable and does not need any manual touch-ups.

@pavelkouril pavelkouril force-pushed the codegen-cleanup branch 4 times, most recently from cde2529 to 16a0f0f Compare November 1, 2025 21:58
@pavelkouril pavelkouril marked this pull request as ready for review November 1, 2025 22:01
@pavelkouril
Copy link
Contributor Author

Please review. I'll fix any coding standard violations or naming you dislike.

If you'd like to unify some of the codegen/csharp model APIs, I can do it as well (but I wanted to keep the csharp representation on the simpler side).

Running the codegen emits 0 changes and requires zero manual touchup, meaning it can be finally considered stable.

I split the commit into two:
1/ Codegen changes
2/ Re-run the codegen to fix any whitespace inconsistencies + issues with wrong selectors in previous releases

Copy link
Owner

@IsaacMarovitz IsaacMarovitz left a comment

Choose a reason for hiding this comment

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

Lgtm apart from a few comment nitpicks. Thank you for tackling this!

@pavelkouril pavelkouril changed the title [WIP] Codegen Improvements Codegen Improvements Nov 2, 2025
@pavelkouril
Copy link
Contributor Author

I fixed the comments and rebased + force pushed.

@IsaacMarovitz IsaacMarovitz merged commit f39842d into IsaacMarovitz:master Nov 2, 2025
2 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.

2 participants