-
Notifications
You must be signed in to change notification settings - Fork 359
Expand back-compat property type preservation to all public model properties #10413
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
Copilot
wants to merge
10
commits into
main
Choose a base branch
from
copilot/expand-back-compat-support
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
10 commits
Select commit
Hold shift + click to select a range
c79daca
Initial plan
Copilot d6d7c2a
Expand back-compat property type support to all model properties
Copilot fd9ef6e
Add BuildPropertiesForBackCompatibility API, align docs with main
Copilot 6275b90
Merge main: align with #10319 revert (drop AreNamesEqual on collectio…
Copilot 7c64485
Merge remote-tracking branch 'origin/main' into copilot/expand-back-c…
86c40d0
Always preserve last contract property type in back-compat scenario
Copilot d26b620
Merge remote-tracking branch 'origin/main' into copilot/expand-back-c…
Copilot f4cdb93
Simplify TryGetLastContractPropertyTypeOverride; sync from main
Copilot 4584e8b
Update BuildPropertiesForBackCompatibility XML summary to reflect unc…
Copilot 0f006de
Move BuildPropertiesForBackCompatibility to run after visitors
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
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
11 changes: 11 additions & 0 deletions
11
...oviderTests/BackCompat_EnumPropertyTypeIsRetainedWhenNullabilityDiffers/MockInputModel.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,11 @@ | ||
| namespace Sample.Models | ||
| { | ||
| public partial class MockInputModel | ||
| { | ||
| public StatusEnum? Status { get; set; } | ||
| } | ||
|
|
||
| public partial struct StatusEnum | ||
| { | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...Data/ModelProviderTests/BackCompat_NullableScalarPropertyTypeIsRetained/MockInputModel.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 partial class MockInputModel | ||
| { | ||
| public int? Count { get; set; } | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...roviderTests/BackCompat_ScalarPropertyTypeOverriddenWhenTypeNameDiffers/MockInputModel.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 partial class MockInputModel | ||
| { | ||
| public string Count { get; set; } | ||
| } | ||
| } |
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
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.
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.
@copilot this needs to run after all visitors have run.
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.
Moved the call from
BuildPropertiesintoProcessTypeForBackCompatibilityin 0f006de — it now runs alongside the existing methods/constructors back-compat passes, after all visitors have completed (perCSharpGen.csline 79–82). Updated the affectedModelProviderTeststo triggerProcessTypeForBackCompatibilityexplicitly. All 1421 generator tests + 1311 ClientModel tests pass.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.
@copilot Not sure if that is the issue, but seeing a regression where the known azure type property serialization is not applied for nullable AzureLocation.
https://github.com/Azure/azure-sdk-for-net/blob/main/eng/packages/http-client-csharp/generator/Azure.Generator/src/Primitives/KnownAzureTypes.cs
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.
That's very likely caused by the move. Before, back-compat ran inside
BuildPropertiesand the Azure visitor ran after it, re-stampingoutputProperty.Typewith theAzureLocationTypeProvider'sCSharpType(which carries theImplementation/known-Azure-type metadata that MRW serializer codegen keys off of). Now back-compat runs after the visitor and wholesale replacesoutputProperty.TypewithlastContractPropertyTypefromLastContractPropertiesMap— that one is built by reflecting over the previous binary, so it's a "raw" frameworkCSharpTypewithout the TypeProvider association. The serializer then doesn't recognize it as a known Azure type.A targeted fix: when
lastContractPropertyTypeandoutputProperty.Typehave the same underlying name/namespace and only differ in nullability (or collection wrapping), keep the visitor'soutputProperty.Typeand just adjust nullability/wrapping on it (preserving theImplementation). When they differ in the underlying type (thestring→intscenario), fall back to wholesale replacement as today.Want me to go that route, or do you have a different shape in mind? If you can point me at a small failing test (or the exact property/type pairing), I can verify locally before pushing.
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.
@JoshLove-msft do you know which library was hitting this? I have a new regen pr here Azure/azure-sdk-for-net#58604