Implement an internal generator for FiggleFonts class#41
Merged
drewnoakes merged 5 commits intomasterfrom Jun 7, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements an internal source generator to dynamically generate the font accessor properties in the FiggleFonts class, using the Aliases.csv file and bundled font files. Key changes include:
- Converting the FiggleFonts class to a partial class and removing hard-coded property accessors.
- Introducing the Figgle.Fonts.Generator project to generate font properties and sample documentation.
- Updating project files and adding AdditionalFiles support for CSV and font files.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Figgle.sln | Added a project reference for the internal generator. |
| Figgle.Fonts/FiggleFonts.cs | Made the FiggleFonts class partial and removed hardcoded accessors. |
| Figgle.Fonts/Figgle.Fonts.csproj | Configured AdditionalFiles and analyzer project references. |
| Figgle.Fonts/Aliases.csv | Added CSV mappings for font names to member names. |
| Figgle.Fonts.Generator/FiggleFontGenerator.cs | Added the source generator logic to generate font property accessors. |
| Figgle.Fonts.Generator/Figgle.Fonts.Generator.csproj | Introduced the new generator project with necessary dependencies. |
drewnoakes
reviewed
Jun 7, 2025
drewnoakes
approved these changes
Jun 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To make it easier to maintain more built-in fonts, #39 was created to auto-generate the font accessor properties using T4. However, as mentioned in the PR, T4 generation is Visual Studio-only and makes implementing #38 difficult.
As an alternative, we can create an internal-only source generator specifically for
FiggleFontsclass. We can continue to useAliases.csvintroduced in #39, and use the information to generate the property accessors for each built-in font.In addition, with a source generator we can easily grab all the font files and parse their content into a
FiggleFont. The parsed fonts can then be used to render a sample text to be included in the property's documentation.Implementation
Figgle.Fonts.Generatorproject that is referenced as an analyzer byFiggle.Fonts.FiggleFontsclasspartialand remove the existing hardcoded property accessors.Figgle.Fonts.csprojto includeAliases.csvand all of the font files asAdditionalFilesso that our new source generator can access it.Testing