Repository navigation
Use PascalCase for generated C# extensible enum members #12623
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
Open
Jorge Rangel (jorgerangel-msft)
wants to merge
11
commits into
main
Choose a base branch
from
copilot/ensure-enum-members-naming-guidelines
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
de4edf2
Initial plan
jorgerangel-msft 939435b
fix(csharp): Pascal-case extensible enum members
jorgerangel-msft 31e5020
refactor(csharp): scope enum member casing to extensible views
jorgerangel-msft d728689
refactor(csharp): pass the extensible enum casing guard inline
jorgerangel-msft 45ed1c0
fix(csharp): simplify extensible enum member naming
jorgerangel-msft e072b7b
test(csharp): cover underscored URL enum compatibility
jorgerangel-msft ba2b2b1
fix(csharp): normalize numeric-suffixed extensible enum names
jorgerangel-msft 048aa3f
refactor(csharp): guard extensible enum name normalization
jorgerangel-msft dce1b5e
fix(csharp): only normalize whole uppercase enum words
jorgerangel-msft 0601a2a
test(csharp): validate enum casing with TestData baseline
jorgerangel-msft f1d7fb2
fix(csharp): normalize numeric suffixes on two-letter enum names
jorgerangel-msft 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 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
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
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
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
7 changes: 7 additions & 0 deletions
7
...ProviderTests/BackCompat_ExtensibleEnumUrlSuffixPreservesUnderscoredName/MockInputEnum.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace Sample.Models | ||
| { | ||
| public readonly partial struct MockInputEnum | ||
| { | ||
| public static MockInputEnum Callback_Url { get; } | ||
| } | ||
| } |
109 changes: 109 additions & 0 deletions
109
...umProviders/TestData/EnumProviderTests/BuildEnumType_ExtensibleStringEnum_MemberCasing.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // <auto-generated/> | ||
|
|
||
| #nullable disable | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
| using Sample; | ||
|
|
||
| namespace Sample.Models | ||
| { | ||
| public readonly partial struct MockInputEnum : global::System.IEquatable<global::Sample.Models.MockInputEnum> | ||
| { | ||
| private readonly string _value; | ||
| private const string AndValue = "AND"; | ||
| private const string OrValue = "OR"; | ||
| private const string NotFoundValue = "NOT_FOUND"; | ||
| private const string FooORValue = "FooOR"; | ||
| private const string ORfooValue = "ORfoo"; | ||
| private const string FooOrValue = "Foo_OR"; | ||
| private const string OrFooValue = "OR_foo"; | ||
| private const string ORFooValue = "ORFoo"; | ||
| private const string FooHTTPValue = "FooHTTP"; | ||
| private const string HTTPStatusValue = "HTTPStatus"; | ||
| private const string Http2Value = "HTTP2"; | ||
| private const string Utf8Value = "UTF8"; | ||
| private const string Vm2Value = "VM2"; | ||
| private const string Io2Value = "IO2"; | ||
| private const string IPV4Value = "IPV4"; | ||
| private const string IPV6Value = "IPV6"; | ||
| private const string HTTP2fooValue = "HTTP2foo"; | ||
| private const string HTTP2Value = "HTTP2"; | ||
| private const string IOStreamValue = "IOStream"; | ||
| private const string CallbackURLValue = "CallbackURL"; | ||
| private const string CallbackurlValue = "CALLBACKURL"; | ||
| private const string CallbackUriValue = "CALLBACK_URL"; | ||
| private const string ANDValue = "AND"; | ||
|
|
||
| public MockInputEnum(string value) | ||
| { | ||
| global::Sample.Argument.AssertNotNull(value, nameof(value)); | ||
|
|
||
| _value = value; | ||
| } | ||
|
|
||
| public static global::Sample.Models.MockInputEnum And { get; } = new global::Sample.Models.MockInputEnum(AndValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Or { get; } = new global::Sample.Models.MockInputEnum(OrValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum NotFound { get; } = new global::Sample.Models.MockInputEnum(NotFoundValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum FooOR { get; } = new global::Sample.Models.MockInputEnum(FooORValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum ORfoo { get; } = new global::Sample.Models.MockInputEnum(ORfooValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum FooOr { get; } = new global::Sample.Models.MockInputEnum(FooOrValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum OrFoo { get; } = new global::Sample.Models.MockInputEnum(OrFooValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum ORFoo { get; } = new global::Sample.Models.MockInputEnum(ORFooValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum FooHTTP { get; } = new global::Sample.Models.MockInputEnum(FooHTTPValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum HTTPStatus { get; } = new global::Sample.Models.MockInputEnum(HTTPStatusValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Http2 { get; } = new global::Sample.Models.MockInputEnum(Http2Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Utf8 { get; } = new global::Sample.Models.MockInputEnum(Utf8Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Vm2 { get; } = new global::Sample.Models.MockInputEnum(Vm2Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Io2 { get; } = new global::Sample.Models.MockInputEnum(Io2Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum IPV4 { get; } = new global::Sample.Models.MockInputEnum(IPV4Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum IPV6 { get; } = new global::Sample.Models.MockInputEnum(IPV6Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum HTTP2foo { get; } = new global::Sample.Models.MockInputEnum(HTTP2fooValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum HTTP2 { get; } = new global::Sample.Models.MockInputEnum(HTTP2Value); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum IOStream { get; } = new global::Sample.Models.MockInputEnum(IOStreamValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum CallbackURL { get; } = new global::Sample.Models.MockInputEnum(CallbackURLValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Callbackurl { get; } = new global::Sample.Models.MockInputEnum(CallbackurlValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum CallbackUri { get; } = new global::Sample.Models.MockInputEnum(CallbackUriValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum AND { get; } = new global::Sample.Models.MockInputEnum(ANDValue); | ||
|
jorgerangel-msft marked this conversation as resolved.
Resolved
|
||
|
|
||
| public static bool operator ==(global::Sample.Models.MockInputEnum left, global::Sample.Models.MockInputEnum right) => left.Equals(right); | ||
|
|
||
| public static bool operator !=(global::Sample.Models.MockInputEnum left, global::Sample.Models.MockInputEnum right) => !left.Equals(right); | ||
|
|
||
| public static implicit operator global::Sample.Models.MockInputEnum(string value) => new global::Sample.Models.MockInputEnum(value); | ||
|
|
||
| public static implicit operator global::Sample.Models.MockInputEnum?(string value) => (value == null) ? ((global::Sample.Models.MockInputEnum?)null) : new global::Sample.Models.MockInputEnum(value); | ||
|
|
||
| [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
| public override bool Equals(object obj) => ((obj is global::Sample.Models.MockInputEnum other) && this.Equals(other)); | ||
|
|
||
| public bool Equals(global::Sample.Models.MockInputEnum other) => string.Equals(_value, other._value, global::System.StringComparison.InvariantCultureIgnoreCase); | ||
|
|
||
| [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
| public override int GetHashCode() => (_value != null) ? global::System.StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; | ||
|
|
||
| public override string ToString() => _value; | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.