You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[http-client-csharp] Emit Obsolete attributes for deprecated APIs - #12394
Emit warning-only Obsolete attributes from TypeSpec #deprecated metadata on models, fixed/extensible enums, and synchronous/asynchronous protocol and convenience methods. Preserve messages, including empty strings and C# escaping.
Preserve the last released GA contract: existing APIs that were not obsolete do not gain the attribute. Apply the same rule after parameter reordering and to compatibility overloads. New APIs and previously experimental APIs can be marked obsolete; already obsolete APIs use the current message.
Respect customization-supplied attributes without duplicating them on partial implementations.
Suppress obsolete-reference diagnostics within generated implementation code while retaining consumer warnings.
Add metadata, provider, output-baseline, customization, compatibility, and generated-library coverage; regenerate the sample and all Spector libraries.
Validation
Package build and API extraction passed; the generator solution, including generated libraries, builds with warnings as errors.
Emitter: 396 passed, 2 skipped (serial run to avoid an existing five-second test timeout under concurrent builds).
Repository/package formatting, emitter type-aware oxlint, and Cop checks passed. The package's existing ESLint script references an unavailable tool, so linting used the repository's configured oxlint instead.
A separate consumer build reported the expected CS0618 diagnostics for the model, both enum forms, and the operation.
Windows validation used temporary drive mappings to avoid existing long-path limitations. Regeneration reported restore/artifact-path warnings for some long Spector paths; the subsequent shortened-path solution build succeeded.
Preserve non-obsolete GA contracts and compatibility overloads while exposing TypeSpec deprecation messages on new APIs.
Co-authored-by: Copilot App <[email protected]>
Keep customization-owned Obsolete attributes on the defining declaration in the shared partial-signature builder, covering non-client methods as well as operation methods.
Co-authored-by: Copilot App <[email protected]>
If the GA contract contains obsolete Read(int value) and non-obsolete Read(int value, bool added = false), this early filtering removes the current deprecation message, so BackCompatHelper.cs:534–543 strips Obsolete from the restored one-parameter overload. Defer GA filtering to the existing post-overload pass in TypeProvider.cs:1254–1263 so the stable signature stays unchanged while the already-obsolete overload retains the current message.
Suppress all experimental and obsolete diagnostics on generated model registrations. Defer GA method filtering until after compatibility overload restoration so previously obsolete overloads retain the current message.
Co-authored-by: Copilot App <[email protected]>
Fixed the mixed GA-overload case from the latest review in fb5bf95 as well. Deprecation metadata is now retained until compatibility overloads are restored, then the existing final GA pass removes it only from signatures that were previously non-obsolete. An already-obsolete restored overload keeps the current message, while the stable overload remains non-obsolete. Added a sync/async regression covering the mixed contract.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The interacting changes to published-contract preservation, partial-method attributes, and diagnostic suppression warrant final human review despite the extensive regression coverage.
Keep custom Experimental and Obsolete attributes on partial declarations through the shared signature builder. Cover non-client block- and expression-bodied methods, and remove the requested emitter documentation changes.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Released-contract compatibility remains unresolved, and the interactions between attribute caching, visitors, and warning suppression warrant final human review.
If a visitor renames or moves a deprecated type to an existing, non-obsolete GA identity after Attributes has been read, the cached Obsolete attribute survives and introduces consumer warnings on that stable API. ResetMembersBasedOnIdentityChange refreshes LastContractView but leaves _attributes intact (TypeProvider.cs:986–1013). Re-evaluate generated deprecation metadata against the final identity without discarding visitor-supplied attributes, and add a regression that reads attributes before renaming.
Re-evaluate generated obsolete metadata after visitor renames and namespace changes while preserving visitor-added attributes and explicit removals. Prevent stale attribute snapshots from restoring obsolete warnings on non-obsolete GA types.
Co-authored-by: Copilot App <[email protected]>
Fixed the cached-attribute identity issue from the latest review in 96f0a6e. Generated deprecation metadata is now re-evaluated after type updates against the final identity and released contract. Visitor-added attributes, explicit removals, and replacement Obsolete messages are preserved; applying a stale pre-rename attribute list cannot reintroduce a generated warning on a non-obsolete GA type.
Added rename/namespace-change regressions for models and both enum forms, transitions to and from GA identities, customization precedence, visitor overrides, stale attribute snapshots, and final generated output.
Remove mutable type-map keys before name or namespace updates and reinsert owned mappings afterward. Refresh serialization caches so renamed enum helpers retain warning suppressions and final identities.
Co-authored-by: Copilot App <[email protected]>
Resolve name and namespace together so provider reindexing never overwrites an unrelated intermediate identity. Cover models and both enum forms with retained warning lookup.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Interactions among published API compatibility, partial customization, diagnostic suppression, and provider identity updates warrant final human review.
Remove the combined-model suppression test and its unused fixture and baseline as requested. Reuse IsObsoleteAttribute in the context check per review feedback.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Interactions among released-contract preservation, partial-method customization, type-identity caches, and diagnostic suppressions warrant final human review despite extensive regression coverage.
Group generated attribute updates under the existing inclusion branches and use consistent conditional attribute collection syntax.
Co-authored-by: Copilot App <[email protected]>
When a visitor explicitly adds [Obsolete] to a method that was not obsolete in the last released contract, this filter removes it—even if the operation has no #deprecated metadata. Visitors run before compatibility processing (CSharpGen.cs:80–92), so the intended consumer warning disappears. Track generator-owned method deprecation attributes and restrict this removal to those, preserving explicit visitor overrides.
Track generated Obsolete attribute instances before library visitors run, and limit GA compatibility filtering to those instances. Keep explicit visitor attributes on methods and restored compatibility overloads.
Co-authored-by: Copilot App <[email protected]>
Fixed the visitor-owned method attribute finding from the latest review in 3ce1ba0. The compatibility pass now tracks the original generated Obsolete instances before library visitors run and removes only those for previously non-obsolete GA signatures. Explicit visitor additions and replacements, including custom diagnostic IDs, remain intact. Restored compatibility overloads also preserve explicit visitor overrides rather than applying the automatic-metadata rule to them.
Added failing-before-fix regressions through the real library visitor path with and without TypeSpec deprecation metadata, generic method/compatibility-overload coverage, and a control showing the generated attribute is still removed when a visitor adds its own. Existing generated-only GA and mixed-overload regressions remain passing.
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
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.
Fixes #12392.
Changes
Obsoleteattributes from TypeSpec#deprecatedmetadata on models, fixed/extensible enums, and synchronous/asynchronous protocol and convenience methods. Preserve messages, including empty strings and C# escaping.Validation
Windows validation used temporary drive mappings to avoid existing long-path limitations. Regeneration reported restore/artifact-path warnings for some long Spector paths; the subsequent shortened-path solution build succeeded.