Skip to content

[3.0] Add generator docs - #2578

Merged
Exanite merged 97 commits into
develop/3.0from
feature/generator-docs
Jun 12, 2026
Merged

[3.0] Add generator docs#2578
Exanite merged 97 commits into
develop/3.0from
feature/generator-docs

Conversation

@Exanite

@ExaniteExanite commented May 11, 2026

Copy link
Copy Markdown
Member

Summary of the PR

This replaces my previous WIP PR for adding generator usage documentation (#2545) in favor of providing a more complete set of docs relating to both using the generator and how the generator internals work.

Related issues, Discord discussions, or proposals

Related discord thread: https://discord.com/channels/521092042781229087/1500974857079492749

  • Currently not much to see here since all my thoughts have been put into the docs instead.

Further Comments

There are sections that I left empty (marked with TODOs) since I don't have enough knowledge to fill out those sections.

Tasks

  • Write the generator docs
    • Using the Generator
    • Naming Pipeline
    • Generator Mods
  • Ensure examples have matching unit tests
  • Update unit tests to use new document verification utility
  • Fix or add tasks (see my tracking issue) for the following issues identified while writing the docs:
    • ExtractNestedTyping constant extraction does not handle nor rewrite fields that are typed as a predefined type, but are natively typed as an enum (test case: SuccessfullyExtractsCStyleEnumConstants_Field)
    • ExtractNestedTyping constant extraction does not handle nor rewrite return types that are typed as a predefined type, but are natively typed as an enum (test case: SuccessfullyExtractsCStyleEnumConstants_ReturnType)
    • ExtractNestedTyping does not annotate extracted enums with the [NativeName] attribute. Eg: SDL_BlendMode.
    • Consider making it so that handle types implement the IEquatable<T> interface.
    • These are fixed by [3.0] Split up ExtractNestedTyping and add tests for TransformHandles #2587

From my tracking issue:

@ExaniteExanite left a comment

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Self review completed. I didn't deeply review the docs I wrote, but I skimmed through each of them a couple of times. My goal is to get the information out there first, then refine the docs in the future. There's also a few sections I left as TODOs because I don't have enough knowledge to fill them out.

Comment threadsources/SilkTouch/SilkTouch/Mods/ExtractNestedTyping.cs
@Exanite

Copy link
Copy Markdown
MemberAuthor

I'll mark this PR as ready for review once #2587 has been merged.

@curincurin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks really good, thanks for tackling this

…#2587)
* Start of generator fixes and polish branch
* Add stubs for ExtractEnumConstants and ExtractFunctionPointers
* Fix invalid interface implementation
* Work on splitting ExtractNestedTyping into 3 separate mods
* Continue to move code to their new locations
* Further cleanup
* Rename ExtractNestedTyping to ExtractNestedTypes
This is be more consistent with C#'s terminology now that ExtractNestedTypes strictly only handles NestedTypes and not other forms of "nested typing".
* Split ExtractNestedTypes tests into 3 sets of tests and ensure project is compilable (if not correct)
This is so I can start testing for expected behavior.
* Get ExtractNestedTypes working
* Update test snapshot names
* Get ExtractFunctionPointers working
* Fix subtly incorrect behavior and remove dependency on Mod for ExtractFunctionPointers/NestedTypes
* Move GetNativeTypeNameForPredefinedType to ExtractEnumConstants and cleanup
* Fix incorrect file name
* Prefer IMod over Mod where possible
This also means free performance since Mod sneakily creates a compilation and walks through it
* Document where ExtractFunctionPointers and ExtractNestedTypes output their extracted files
Also add todo for doing the same in ExtractEnumConstants
* Get ExtractEnumConstants working
* Update config
* Add remark comment on ExtractNestedTypes only handling ClangScraper's special structs
* Generate on Windows (apparently accidentally fixed a namespace bug)
* Remove unused code
* Cleanup GetNativeTypeNameForPredefinedType
* Use constructor and avoid nullable properties
We always allocate these so this is strictly a readability and performance improvement.
* Refactor code to use record structs
* Work on deciphering tuple usages
* Figure out what _numericTypeNames does
* Add support for requiredTargetSpecifier to TryParseNativeTypeName
* Handle method return types properly and fix SuccessfullyExtractsCStyleEnumConstants_ReturnType
* Cleanup todos
* Handle fields properly and fix SuccessfullyExtractsCStyleEnumConstants_Field
* Generate on Windows
* Cleanup
* Annotate extracted enums with [NativeName]
* Generate on Windows
* Add IEquatable to transformed handle types
These already implemented all the required members for IEquatable, so I found it weird that they didn't also implement the interface.
* Generate on Windows for IEquatable handles change
* Add TransformHandlesTests
* Reorder code for clarity
* Update docs with sections for the 3 mods ExtractNestedTyping was split into
* Change Sdl in ExtractEnumConstantsTests to be a class, not a struct
This is more representative of the actual bindings even though it doesn't affect the tests.
* Fix incorrect variable name and type name
@Exanite
Exanite marked this pull request as ready for review June 12, 2026 06:27
@Exanite
Exanite requested a review from a team as a code ownerJune 12, 2026 06:27
@Exanite
Exanite merged commit 89841e7 into develop/3.0Jun 12, 2026
18 checks passed
@Exanite
Exanite deleted the feature/generator-docs branch June 12, 2026 07:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants

@Exanite@curin