-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config option: strip-enum-member-type-name #527
Merged
tannergooding
merged 6 commits into
dotnet:main
from
fredrikhr:strip-enum-member-type-name
May 24, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1eed29
Add strip-enum-member-type-name config option.
fredrikhr da4255f
Match enum type name case insensitively
fredrikhr 44af162
Contain StripEnumMemberTypeName config option logic in a single location
fredrikhr fa6653d
Move Regex using next to related usings
fredrikhr 6703d6a
Simplify prefix stripping logic and consolidate
fredrikhr c246b41
Automatic Whitespace fixup made by Visual Studio
fredrikhr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, was busy at Microsoft Build.
The rest of the changes look good, but
trimChar: '_'
is going to cause some problems and needs an extra handler. In particular we know that there exist enums of the formDXGI_FORMAT_420_OPAQUE
and so removing the prefixDXGI_FORMAT
+_
will cause an invalid member name to be generated.I'm going to merge this as is given that these are rare and there is a trivial workaround where devs can simply remap that specific member. However, if you have time it'd be great to at least add in a diagnostic when such a member is encountered and possibly add back the leading
_
to ensure we still get "valid" codegen.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, Looks like we first need a check for leading digits (i think that's the only problem from the subset of what's valid in C/C++ and C# at that point) and then another call to EscapeName in case we ended up with a keyword after stripping.
I'll make the changes.
In case of leading digits it's fine to just prepend with @ like EscapeName does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no,
@
only works on valid identifiers and is really just to remove ambiguity with respect to language keywords. You'd have to reinsert a leading_
to make it valid if the first character triggers thechar.IsDigit
check.