Skip to content

[3.0] Refactor PrettifyNames and finalize naming features#2564

Draft
Exanite wants to merge 151 commits intodotnet:develop/3.0from
Exanite:feature/prettify-names-simplification
Draft

[3.0] Refactor PrettifyNames and finalize naming features#2564
Exanite wants to merge 151 commits intodotnet:develop/3.0from
Exanite:feature/prettify-names-simplification

Conversation

@Exanite
Copy link
Copy Markdown
Member

@Exanite Exanite commented Apr 7, 2026

Summary of the PR

Context

This PR chains off of #2557 and completes the final tasks noted in the PR.
This is a separate PR since this PR has a fundamentally different focus than #2557: this PR focuses on PrettifyNames itself while #2557 focuses on moving the prefix trimming code out of PrettifyNames.

What the PR does

The core goal of this PR is to make PrettifyNames easier to understand and maintain.

This PR rewrites the core PrettifyNames logic to be done by "INameProcessors", apply sequential transformations to the names in the generated bindings.

INameProcessor replaces the old INameTrimmer interface.
INameProcessor is private to PrettifyNames unlike INameTrimmer.

INameTrimmer used to be an external extension point for the PrettifyNames logic and was registered to the DI container.
This is no longer necessary because there are other ways to configure and extend the PrettifyNames logic now.

This PR also does the following:

  • Refactor how names are stored by the visitor and name processors
  • Change symbol retrieval before naming to use a symbol visitor instead of GetSymbolsWithName and LINQ
  • Slightly adjust the name conflict resolution logic to handle non-methods and methods better
  • Finish a few features planned during previous PRs
    • Referenced affixes now work with name overrides
    • Referenced affixes now can resolve names from the parent scope (currently limited to 2 levels since PrettifyNames itself does not support nesting)
    • Affixes can now be prettified

Related issues, Discord discussions, or proposals

The "parent" PR: #2557

Further Comments

Tasks

  • Optimize/refactor name overrides in PrettifyNames
    • This was a task noted down during an earlier PR that was naturally implemented during this PR.
  • Rewrite rest of trimming+prettify pipeline as sequential INameProcessors
    • This should include the name conflict resolution code, since that's currently done as a step right after the name processors run.
    • This will act as the main and only code path. Currently we have two code paths (which technically was 3 before I removed another one during [3.0] Add referenced affix system to improve handling of nested struct names and similar names #2555).
    • Remove the name container isolation and just provide all names together. If name processors need the isolation, we still provide the container names and container members separately and can implement the old behavior as needed, but restricting access to all names is unnecessary and can actually lead to incorrect behavior.
  • Ensure global scope is consistently represented (prefer empty string)
  • Update OpenAL name overrides
    • About half of the overrides can now be removed since they are now handled automatically by the name affix system.
    • (Copied from [3.0] Add referenced affix system to improve handling of nested struct names and similar names #2555) Edit: Hmm, the override system actually conflicts here. The current name processing system can't see overridden names since they get removed from the name container at the very start.
      • This means that overrides are not properly taken into account by referenced affixes.
      • Eg: ALBUFFERCALLBACKTYPESOFTDelegate uses the native name of BufferCallbackSOFT (native name ALBUFFERCALLBACKTYPESOFT) as a prefix. This should allow PrettifyNames to replace ALBUFFERCALLBACKTYPESOFT in ALBUFFERCALLBACKTYPESOFTDelegate with BufferCallbackSOFT, thus resulting in BufferCallbackSOFTDelegate. However, this is not currently the case because the name lookup fails.
      • Fix the conflicting override implementation
        • This was done as part of the INameProcessor rewrite task above
      • Handle this by preferring the value from the current name container and falling back to the "final" names dictionary
  • Add unit test for affix referencing an overridden name
  • Add the option to prettify affixes
  • Regenerate all bindings using Windows and ensure no changes to output

Exanite added 30 commits March 24, 2026 05:59
…ld used by other bindings

The default acronym threshold was changed during #29, which was merged as part of dotnet#2503.
Considering we decided to follow Microsoft's Framework Design Guidelines (acronym threshold of 2) for the bindings and rest of the API, might as well be consistent here.
This lets us handle prefixing and prettification separately, which notably is important if we add prefixes after prettification.
We want to prefix the final name, not the intermediate name in this case.
This no longer makes sense to keep and enabling features by baseline version seems fiddly.
If we need to toggle features for newer versions, we can explicitly add a boolean config option.
Kinda a cop out decision, but it keeps thing simple (and thus maintainable) and implementing it fully seems overkill for what we need.
This is because we no longer output the separating underscore in ExtractNestedTyping
…nvention

Note that the goal is to eventually remove the name overrides for the `EFXEAXREVERBPROPERTIESflLateReverbPan` and `-Delegate` cases entirely.
This is because these are theoretically possible to handle automatically and the reason it doesn't work is due to an edge case interaction with the name override system.

See the "Tasks" section here for more info: dotnet#2555
Exanite added 12 commits April 7, 2026 04:27
This wasn't an actual observed issue, but is a possible edge case I noticed when I was reading the code.

The underlying data collection is a hashset or dictionary, both of which have non-deterministic iteration order.
This commit adds a tie-breaker to prevent this issue from possibly happening.
…inatorAffixes_ReversedPriority and add more comments on why the tests exist
… and update test cases to reflect expected behavior
I expected this to be an issue *eventually*, but apparently it also affects the SDL output already.
This is probably because SDL has multiple overloads of the SDL_main method, which my test case does not test for.
@Exanite Exanite changed the title [3.0] Rework the structure of PrettifyNames [3.0] Refactor PrettifyNames and finalize naming features Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant