Add --typePrefixStrip for stripping a prefix from type and enum member names#768
Merged
tannergooding merged 2 commits intoJul 14, 2026
Conversation
…r names Strips a library-wide prefix from enum, struct, and union type names and their enum member names, at both the declaration and every reference, reusing the existing PrefixAndStrip plumbing that backs --prefixStrip for methods. A result that would leave a leading digit keeps an underscore and an empty result is skipped so the name stays a valid C# identifier. Composes with strip-enum-member-type-name so members collapse fully to their leaf name. Addresses dotnet#333 and dotnet#461. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Covers dotnet#333 (prefix stripped from enum/struct type declarations and references, leading-digit guard, methods left untouched) and dotnet#461 (enum members stripped, and collapsed to their leaf name when combined with strip-enum-member-type-name). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
tannergooding
deleted the
tannergooding-prefix-strip-types-and-enum-members
branch
July 14, 2026 16:10
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.
Adds a new
--typePrefixStrip(-tp) value option, the type-side analog of the existing--prefixStripfor methods. It strips a library-wide prefix fromenum/struct/uniontype names, at both the declaration and every reference, reusing the existingPrefixAndStripplumbing rather than adding a parallel path. It also strips the prefix from enum member names and composes with--config strip-enum-member-type-name.Given:
with
--typePrefixStrip abc_:Adding
--config strip-enum-member-type-namecollapses the members further tokey1/key2(the library prefix is stripped first, then the already-stripped enum type name).The stripping is applied at the two consistent tag-type naming choke points --
GetRemappedCursorNamefor declarations andApplyTagTypeNameOverridesfor references -- plusEscapeAndStripEnumMemberNamefor members, so declarations and every reference resolve to the same C# name.Edge cases:
abc_2d_point->_2d_point) so it stays a valid C# identifier.--remap/--remap-typealways wins over stripping.NativeTypeNameattributes and theEntryPoint/mangled name keep the original C spelling.--remap.This is the explicit-prefix form only; auto-detecting a non-obvious common prefix (or a common postfix) per enum is intentionally left out and can be a follow-up. As a reminder, one of the best existing ways to consume these is simply
using static abc_some_enum;, after whichabc_some_enum_key1works unqualified.Addresses #333 and #461.
Build is clean (0 warnings) and
dotnet test -c Releasepasses (3772 passed, 0 failed). AddsTypePrefixStripTestwith golden baselines covering both the types-only and combined cases.