Handle enum value order changes using LastContractView#9906
Queued
Handle enum value order changes using LastContractView#9906
Conversation
Add backward compatibility logic in FixedEnumProvider.BuildEnumValues() to preserve enum member order and initialization values from the last contract for int-based fixed enums. This avoids breaking changes when the spec reorders enum values. Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix LastContractView to handle enum value order changes
Handle int enum value order changes using LastContractView
Mar 4, 2026
...http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/FixedEnumProvider.cs
Outdated
Show resolved
Hide resolved
...http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/FixedEnumProvider.cs
Outdated
Show resolved
Hide resolved
…ackCompatibility Move BuildEnumValuesForBackCompatibility to be a protected internal virtual method on TypeProvider, invoked from ProcessTypeForBackCompatibility when the type is an EnumProvider. FixedEnumProvider overrides it. Removed the IsIntValueType guard so string enums are also covered. Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
Handle int enum value order changes using LastContractView
Handle enum value order changes using LastContractView
Mar 4, 2026
...ages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs
Outdated
Show resolved
Hide resolved
...numProviders/TestData/EnumProviderTests/BackCompat_StringEnumOrderPreserved/MockInputEnum.cs
Show resolved
Hide resolved
…data - TypeProvider.ProcessTypeForBackCompatibility: perform a single Update call at the end of the method instead of two separate calls. - BackCompat_StringEnumOrderPreserved test data: changed from a C# enum to a static class with const string fields so the test data has actual string initialization values. Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…it values) Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
...http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/FixedEnumProvider.cs
Outdated
Show resolved
Hide resolved
…let compiler auto-assign Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
...http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/FixedEnumProvider.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
jorgerangel-msft
approved these changes
Mar 4, 2026
JoshLove-msft
approved these changes
Mar 4, 2026
Contributor
|
No changes needing a change description found. |
Any commits made after this event will not be merged.
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.
BuildEnumValuesForBackCompatibilitytoTypeProviderasprotected internal virtualIsIntValueTypecheck — applies to all fixed enum typesUpdatecall at end ofProcessTypeForBackCompatibilityBuildEnumValuesForBackCompatibilityeng/scripts/Generate.ps1Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.