Restore missing last-contract buildable attributes on ModelReaderWriterContextDefinition - #11379
Merged
jorgerangel-msft merged 11 commits intoJul 27, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add back compat attribute processing for ModelReaderWriterContextDefinition
Restore missing last-contract buildable attributes on ModelReaderWriterContextDefinition
Jul 23, 2026
jorgerangel-msft
left a comment
Contributor
There was a problem hiding this comment.
@copilot add at least 1 more unit test that covers a case where there are attributes in custom code, back compat, and in the generated layer
commit: |
…te layers, validate via TestData Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Contributor
Author
Added |
Copilot stopped work on behalf of
jorgerangel-msft due to an error
July 24, 2026 16:08
jorgerangel-msft
force-pushed
the
copilot/add-back-compat-attribute-processing
branch
from
July 24, 2026 18:23
2445304 to
73eada8
Compare
jorgerangel-msft
force-pushed
the
copilot/add-back-compat-attribute-processing
branch
from
July 24, 2026 18:28
73eada8 to
2c6cf95
Compare
Contributor
|
No changes needing a change description found. |
…om AddAttributeForType, expose GetClrMetadataName on CSharpType Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…pe for key and emission Use targetType (the constructed type from the last contract) for both the dictionary key and the emitted TypeOf(...) expression, instead of resolvedProvider.Type (the generic type definition). This ensures: - typeof(Foo<string>) is emitted instead of typeof(Foo<T>) - Foo<string> and Foo<int> are treated as distinct entries (not deduplicated) Also refactor AddAttributeForType(TypeProvider) to accept an explicit key so the suppression-handling path uses the targetType-derived key when called from AddLastContractBuildableAttributes. Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…ClrMetadataName property tests and ObsoleteCustomType suppression test Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
… use CanonicalView, add experimental/both-attributes tests - Remove comment before AddLastContractBuildableAttributes call - Remove comment before new attribute statement - Remove redundant typeKey computation (identity already computed at line 129) - Fix AddAttributeForType to always use typeProvider.CanonicalView.Attributes - Fix LiteralExpression.Write() to handle byte, sbyte, short, ushort, uint, ulong (needed for CanonicalView.Attributes to work on BCL types with compiler-emitted attrs) - Add LastContractBuildableAttributesForExperimentalCustomTypeHaveSuppression test - Add LastContractBuildableAttributesForExperimentalAndObsoleteCustomTypeHaveSuppression test (verifies experimental takes precedence when both attrs are present) Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
… tests for uint/ulong/byte/sbyte/short/ushort Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
JoshLove-msft
approved these changes
Jul 27, 2026
jorgerangel-msft
approved these changes
Jul 27, 2026
jorgerangel-msft
deleted the
copilot/add-back-compat-attribute-processing
branch
July 27, 2026 20:09
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.
ModelReaderWriterContextDefinitionrebuilt its[ModelReaderWriterBuildable(...)]attributes purely from the current generation, so a type dropped from the spec silently lost its buildable entry — a source-breaking change for consumers that rely on the context to build that type. Attributes are now reconciled against the last contract.Changes
ModelReaderWriterContextDefinition.BuildAttributes()— after collecting generated + customized entries, restore anyModelReaderWriterBuildableAttributepresent onLastContractViewthat the current generation no longer produces.IsFrameworkType == false), so they're matched byType.FullyQualifiedNamerather thanType.FrameworkType.global::.Foo) when the referenced type isn't defined in that compilation.IsBuildableAttributealready recognizes the restored attributes, soBuildAttributesForWritedoes not re-emit them.Tests —
LastContractBuildableAttributesAreRestoredWhenMissing(removed type restored, present type not duplicated) andBuildAttributesForBackCompatibilityDeduplicatesAcrossGeneratedCustomAndLastContractBuildableAttributes(dedupe across all three sources), plus supportingSampleContext.csTestData.Given a last contract that shipped
RegularModel+RemovedModelbut a generation that only producesRegularModel, the emitted context is: