Skip to content

Conversation

@Exanite
Copy link
Owner

@Exanite Exanite commented Jan 11, 2026

Summary of the PR

This PR contains all changes from #26 and #27, and is designed to replace those two PRs.
Reasoning is that #27 modifies a lot of code from #26 so it is easier to review the two sets of changes as a single set.

Note: All important information from the two above PRs are also present here.

This PR does the following:

  • Replace the OverzealousNameTrimming test case with 3 new test cases
    • The old test case was failing and did not reflect the intended behavior of the codebase.
    • The new test cases test the intended behavior in a more granular manner.
    • The new test cases are:
      • PrettifyNamesTests.TrimsSharedPrefix
      • PrettifyNamesTests.TrimsSharedPrefix_WhenAffixesDeclared
      • MixKhronosDataTests.IdentifiesVendorSuffixes
  • Add a few utilities to make testing easier
  • Add tests for some of the features I added to MixKhronosData
  • Rewrite/replace NameUtils.Prettify with NamePrettifier.Prettify
    • My reasoning for rewriting the entire NameUtils.Prettify method is that it was very difficult to modify and understand due to the use of regexes and Humanizer's utilities. The new NamePrettifier replaces it and is written in plain C# with the goal of being consistent, easy to understand and modify, and fully covered by tests.
  • Add a NameSplitter class for splitting names into multiple parts.
    • NOTE: This is currently only used by NamePrettifier. I'm considering using this for NameTrimmer so that the codebase is consistent and doesn't rely on Humanizer/regexes (eg: LenientUnderscore) for splitting.
  • Overall, add tests to cover as much of the naming functionality as possible.
  • Ensure that all test cases pass, fixing issues where necessary
    • Notably:
      • Prefix identification (NameTrimmer) now runs after affixes are removed
      • NameTrimmer now trims based off of the primary names (from the viewpoint of NameTrimmer, these are the names with affixes removed) instead of the original names (these are the managed names that existed in the codebase at the start of PrettifyNames)

Related issues, Discord discussions, or proposals

Discord discussion on OverzealousNameTrimming: https://discord.com/channels/521092042781229087/587346162802229298/1458562017475432480

Discord thread for this PR: https://discord.com/channels/521092042781229087/1459408120748183643

Further Comments

Todo list:

  • Fixed: OcclusionQueryParameterNameNV is currently being trimmed as QueryParameterNameNV when it is the only type being trimmed
    • I'm assuming this is unwanted behavior
    • It looks like NameTrimmer just trims the first word in this case
    • Note that I also provide gl as a prefix hint. This might be related. I need to investigate.
  • Fix failing test cases
  • When do we handle global prefix identification (NameTrimmer)? Before stripping affixes or after?
    • This affects what part of the name is visible to NameTrimmer.
    • Note that most NameAffixes will be suffixes.
    • If we run NameTrimmer after stripping affixes, the effect is less of the name is trimmed, which should fix a few cases where NameTrimmer trims too much, which can cause affix stripping to output "" or "_", which sub-sequentially errors during prettification.
    • For reference, the current process is:
      • Trim prefixes (NameTrimmer)
      • Strip affixes
      • Prettify
      • Add affixes back according to PrettifyNames' config
    • Been thinking about this for a while and my conclusion is that we do want to strip affixes first. Will keep this section here for reference.
  • Consider removing OverzealousNameTrimmingFixupIsNotOverzealousForOpenAL test case. It overlaps with my new tests, but doesn't hurt. The name might be misleading though.

Exanite added 30 commits January 7, 2026 23:05
…r to trim the primaries instead of the original name
…dCandidateNames; Replace the dictionary used with a list since it was a glorified list of tuples

I might change it back to be a dictionary later, but using a list is safer for now since it ensures that all accesses need to directly access a property of AugmentedCandidateNames.

This change was originally to fix an issue where trimming names collide after affixes are removed.
This is an issue introduced by my change to the INameTrimmer order (see f33d592) since I made it so that affixes are now removed before NameTrimmer runs.
…ffectSharedPrefixTrimming_WhenAffixesDeclared
Copy link
Owner Author

@Exanite Exanite left a comment

Choose a reason for hiding this comment

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

Partially reviewed, but submitting now so that pending comments are visible.

--exclude
_GUID
AL_CPLUSPLUS
ALC_CPLUSPLUS
Copy link
Owner Author

Choose a reason for hiding this comment

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

These aren't useful since they just provide the C++ version.

@@ -1,2 +1,3 @@
@../../remap-stdint.rsp
Copy link
Owner Author

Choose a reason for hiding this comment

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

These make generation between Windows/Linux consistent, similar to how it's being used in the Vulkan bindings.

GLclampd=double
GLhandleARB=uint
GLintptrARB=nint
GLsizeiptrARB=nuint
Copy link
Owner Author

Choose a reason for hiding this comment

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

The non-ARB versions were already remapped.
This also makes the bindings generate consistently between Linux/Windows.

/// capitals word.
/// </summary>
public int? LongAcronymThreshold { get; init; }
public int LongAcronymThreshold { get; init; } = 3; // TODO: Change default to 2 in next PR to match framework design guidelines
Copy link
Owner Author

Choose a reason for hiding this comment

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

Cleanup to make the default be specified in the config instead of later.
This is easier to understand and prevents inconsistencies.

Copy link
Owner Author

Choose a reason for hiding this comment

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

This was only used by NameTrimmer so it has been moved there (and also renamed to AugmentedCandidateNames).

Comment on lines -237 to -247
var prefix =
string prefix;
if (
container is not null
&& (prefixOverrides?.TryGetValue(container, out var @override) ?? false)
? @override
: names.Count == 1 && !string.IsNullOrWhiteSpace(containerTrimmingName)
? NameUtils.FindCommonPrefix(
[
names.Keys.First(x => !(nonDeterminant?.Contains(x) ?? false)),
containerTrimmingName,
],
true,
Copy link
Owner Author

Choose a reason for hiding this comment

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

Big diff, but only two changes:

  1. The nested ternary was replaced with if statements. Ternaries are horrible to step through using a debugger.
  2. I added the "One name. Can't determine prefix." case to fix DoesNotTrimTypeName_WhenNotMatchingHint_AndOnlyOneType (OcclusionQueryParameterNameNV was being trimmed as QueryParameterNameNV ONLY during test cases since the test cases usually only have one type)

return $"{hint}_{name[hint.Length..].Trim('_').LenientUnderscore()}";
}

return name.Trim('_').LenientUnderscore();
Copy link
Owner Author

Choose a reason for hiding this comment

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

Replaced ternary with ifs.
Added trim to what was originally the else branch to fix a bug related to the behavior of this code:
Image

The bug caused prefixes to not be trimmed.

[Test]
public void RegressionNamespacePrefixDetermination() =>
Assert.That(
NameUtils.FindCommonPrefix(["Silk.NET.SDL", "Silk.NET.SDL"], true, false, true),
Copy link
Owner Author

Choose a reason for hiding this comment

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

Moved to NameUtilsTests

);

[Test]
public void OverzealousNameTrimming()
Copy link
Owner Author

Choose a reason for hiding this comment

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

OverzealousNameTrimming has been removed since the behavior it tests for no longer exists. It has been replaced with 3 tests, but many more also test for similar behavior:
Image

}

[Test]
public void OverzealousNameTrimmingFixupIsNotOverzealousForOpenAL()
Copy link
Owner Author

Choose a reason for hiding this comment

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

This has been replaced by PrettifyNamesTests.TrimsSharedPrefix2.

Copy link

@Perksey Perksey left a comment

Choose a reason for hiding this comment

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

I'm happy notwithstanding the below comment

[NativeFunction("SDL3", EntryPoint = "SDL_LoadWAV_IO")]
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public static byte LoadWAVIO(
public static byte LoadWavIo(
Copy link

Choose a reason for hiding this comment

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

This is an interesting test case, should this be LoadWavIO?

Copy link
Owner Author

@Exanite Exanite left a comment

Choose a reason for hiding this comment

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

Need to update the commented test. Otherwise, self code review is complete.
Edit: Bug is now fixed and test is updated with correct output.

@Exanite Exanite marked this pull request as ready for review January 11, 2026 20:32
Copy link

@Perksey Perksey left a comment

Choose a reason for hiding this comment

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

happy

@Exanite Exanite merged commit ac3c0be into feature/vulkan-bindings-3.0-improvements Jan 11, 2026
@Exanite Exanite deleted the feature/prettify-rewrite branch January 11, 2026 23:46
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.

3 participants