Conversation
…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.
… separation hack (no longer necessary)
…mbers are normalized
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.
…igured (cherry picked from commit bc94260)
…ous that it is not the last trimmer
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.
…essor and ReapplyAffixesNameProcessor
Kinda a cop out decision, but it keeps thing simple (and thus maintainable) and implementing it fully seems overkill for what we need.
… for function pointer types are named
This is because we no longer output the separating underscore in ExtractNestedTyping
… of INameTrimmer registrations
…ed-struct-name-affixes
…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
…ot getting chosen properly
…t comments/variable names to be clearer
… 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.
This new snapshot matches the expected output that I wrote in the comments earlier. I just forgot to update the snapshot.
…penAL overrides that are now unnecessary
… update test to indicate that one level of scoping is now supported
…e verbatim value of the referenced name
…e code and config
Exanite
left a comment
There was a problem hiding this comment.
Self code review complete. The review comments I added provide additional context on the changes I made, but the code itself should make sense without them.
|
|
||
| public BufferCallbackSOFT(delegate* unmanaged<void*, void*, int, int> ptr) => Pointer = ptr; | ||
|
|
||
| public BufferCallbackSOFT(BufferCallbackDelegateSOFT proc) => |
There was a problem hiding this comment.
Changed to match my decision here: https://discord.com/channels/521092042781229087/1485943448069738608/1487577229121818766
In short, this reordering is because -Delegate is a variant or part of an existing type, similar to how inline array structs are part of their parent struct.
Notably, handle structs are named differently (BufferHandleEXT). This is because the -Handle suffix is a modification to an existing type.
This is a rule that we can consistently follow and also improves discoverability in IDEs since extensions to a type share a common prefix.
| name switch | ||
| { | ||
| nameof(ChangeNamespace) => typeof(ChangeNamespace), | ||
| nameof(AddApiProfiles) => typeof(AddApiProfiles), |
There was a problem hiding this comment.
I alphabetically sorted the names here. This should be easier to read through and cause less diff noise in the future. Even if we forget to sort it when adding new names, sorting it again won't cause as much noise as the first sort.
| /// <param name="type">The type syntax.</param> | ||
| /// <returns>The discriminator string.</returns> | ||
| public static string DiscrimStr(SyntaxTokenList? toks, TypeSyntax? type) => | ||
| public static string GetMethodDiscriminator(SyntaxTokenList? toks, TypeSyntax? type) => |
There was a problem hiding this comment.
I renamed this because I always had to read the name twice to figure out what it meant. This should help with skimming the code.
| /// <para/> | ||
| /// See <see cref="TransformHandles"/> for applying further transformations. | ||
| /// </summary> | ||
| public class ExtractHandles(ILogger<ExtractHandles> logger) : Mod |
There was a problem hiding this comment.
This mod is effectively a cut and paste from TransformHandles.
This is part of my move to separate extraction/type creation from type transformation.
Originally, this was because I thought this was needed for better nested struct handling, but it turned out unnecessary. I kept it because it makes the codebase cleaner.
There was a problem hiding this comment.
Note I removed the AssumeMissingTypesOpaque config option when moving the code to this mod. This is because the false value for the config option is equivalent to disabling the entire mod.
| } | ||
|
|
||
| var iden = $"{node.Identifier}_{match.Groups[1].Value}"; | ||
| var iden = $"{node.Identifier}{match.Groups[1].Value}"; |
There was a problem hiding this comment.
The underscore here is no longer necessary because the affix metadata lets us distinguish the two parts during prettification.
|
|
||
| namespace Silk.NET.SilkTouch.UnitTests.Naming; | ||
|
|
||
| public class NameTrimmerTests : NameTrimmer |
There was a problem hiding this comment.
Test cases in this class were ported over to the new IdentifySharedPrefixTests class.
| /// in favor of calling <see cref="NameUtils.PrefixIfStartsWithNumber"/> separately. | ||
| /// </summary> | ||
| [Theory] | ||
| // C# identifiers cannot start with numbers |
There was a problem hiding this comment.
The tests in this file were updated to match the change I made to Prettify (which now processes name fragments instead of full names).
| "PrettifyNames": { | ||
| "Affixes": { | ||
| "SharedPrefix": { | ||
| "Remove": true |
There was a problem hiding this comment.
For SharedPrefix, we can either configure it as Remove or as a Discriminator. Both have the same effect until names conflict and no other discriminators are available. Fortunately, we no names conflict in this way right now and I assume this case will be very rare, so I'm defaulting to Remove.
| "ContainerType": "GL" | ||
| }, | ||
| "ContainerType": "GL", | ||
| "SeparableTargetEXT": "GL" |
There was a problem hiding this comment.
This is new override is required since my new name underscorer/splitter handles 2D differently. It outputs 2_D instead of 2D since 2_D is arguably more consistent. I explain why here: https://discord.com/channels/521092042781229087/1485943448069738608/1489457083857506336
It's easier to handle the common case consistently while handling edge cases using overrides.
| "ALDEBUGPROCEXT": "DebugProcEXT", | ||
| "ALDEBUGPROCEXTDelegate": "DebugProcDelegateEXT", | ||
| "LPALFOLDBACKCALLBACK": "FoldbackCallback", | ||
| "LPALFOLDBACKCALLBACKDelegate": "FoldbackCallbackDelegate" |
There was a problem hiding this comment.
Most of these overrides are no longer necessary because of referenced affixes. Overrides to the referenced name automatically propagate to names that reference them.
Summary of the PR
This PR combines my 3 previous naming-related PRs into a single PR.
This is because the 3 PRs contain interdependent changes and should be merged as a single unit.
That said, each of the 3 PRs focus on different aspects of the naming system and serve as supplementary documentation for the different changes.
Related issues, Discord discussions, or proposals
PRs contained by this PR:
Discord thread where I noted down my thoughts and decisions: https://discord.com/channels/521092042781229087/1485943448069738608
Further Comments
This PR does not introduce any new changes on top of the changes made in the 3 contained PRs.
However, prefer reviewing the diff through this PR since this is the PR that is intended to be merged.