-
Notifications
You must be signed in to change notification settings - Fork 380
Check custom code when preserving enum member underscores for backcompat #11315
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
Merged
jorgerangel-msft
merged 6 commits into
main
from
copilot/check-custom-code-preserve-enum-underscores
Jul 20, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b94a32
Initial plan
Copilot d610f46
Skip underscore back-compat restoration when custom code defines member
Copilot 2f24c61
Use case-insensitive custom member match; verify Cop and tests pass
Copilot 091092a
Compute custom member names inside GetBackCompatibleName; validate vi…
Copilot 5de8932
Select custom members by provider type; early-return when no last con…
Copilot 0f7dcfd
Remove explanatory comment on CustomMemberNames helper
Copilot 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
9 changes: 9 additions & 0 deletions
9
..._ExtensibleEnumCustomCodeTakesPrecedenceOverPreservedUnderscores(Custom)/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,9 @@ | ||
| #nullable disable | ||
|
|
||
| namespace Sample.Models | ||
| { | ||
| public readonly partial struct MockInputEnum | ||
| { | ||
| public static MockInputEnum Existing_Value { get; } = ExistingValue; | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
...at_ExtensibleEnumCustomCodeTakesPrecedenceOverPreservedUnderscores(Last)/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,10 @@ | ||
| #nullable disable | ||
|
|
||
| namespace Sample.Models | ||
| { | ||
| public readonly partial struct MockInputEnum | ||
| { | ||
| public static MockInputEnum Existing_Value { get; } | ||
| public static MockInputEnum Other { get; } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
...oviderTests/BackCompat_ExtensibleEnumCustomCodeTakesPrecedenceOverPreservedUnderscores.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,46 @@ | ||
| // <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 ExistingValueValue = "existing"; | ||
| private const string OtherValue = "other"; | ||
|
|
||
| public MockInputEnum(string value) | ||
| { | ||
| global::Sample.Argument.AssertNotNull(value, nameof(value)); | ||
|
|
||
| _value = value; | ||
| } | ||
|
|
||
| public static global::Sample.Models.MockInputEnum ExistingValue { get; } = new global::Sample.Models.MockInputEnum(ExistingValueValue); | ||
|
|
||
| public static global::Sample.Models.MockInputEnum Other { get; } = new global::Sample.Models.MockInputEnum(OtherValue); | ||
|
|
||
| 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) ? 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.