Skip to content

[C#] Revert Obsolete attribute generation for deprecated APIs and properties - #12580

Draft
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 4 commits into
mainfrom
revert/csharp-deprecation-prs
Draft

Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 4 commits into
mainfrom
revert/csharp-deprecation-prs

Conversation

Copilot AI commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Reverts #12523 and #12394, removing automatic Obsolete attribute generation for deprecated C# APIs and model properties, along with the associated metadata, warning suppressions, tests, and generated sample additions.

Conflicts were resolved to preserve newer constructor samples and array-customization coverage. The existing one-line partial-method modifier safeguard is retained because removing it breaks two newer paging tests. Sample-TypeSpec was regenerated using the underlying CLI commands from Generate.ps1.

Validation

  • npm run build passed.
  • Emitter tests: 418 passed, 2 skipped.
  • Core generator tests: 3,200 passed.
  • ClientModel generator tests: 2,729 passed.
  • Sample customization tests: 37 passed.
  • git diff --check passed.

Formatting and Cop execution were blocked by session permissions. npm run lint could not run because ESLint is missing. PowerShell is unavailable, so the full regeneration script could not run; the affected Sample-TypeSpec project was regenerated directly instead.

Revert PRs #12523 and #12394 (ccde4f5 and ea154bb).

Resolve conflicts by preserving newer constructor samples and array-customization coverage. Retain the partial-method modifier guard required by newer paging tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
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.

@pkg-pr-new

pkg-pr-new Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@12580

commit: 60b509b

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Provider renames break map lookups, partial-method customization can duplicate attributes and fail compilation, and enumerable attribute inputs can be silently discarded.

3 open issues
What changed in this PR

Reverts automatic C# [Obsolete] generation introduced by #12394 and #12523, while preserving newer constructor samples, array-customization coverage, and the partial-method modifier safeguard.

Changes:

  • Removes automatic deprecation attributes and related compatibility and warning-suppression logic.
  • Deletes deprecation-specific tests, fixtures, and sample APIs; regenerates Sample-TypeSpec.
  • Adds checks that property deprecation metadata remains readable and does not affect generated model output.

Paths below are relative to packages/http-client-csharp/generator/.

File Description
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​SampleTypeSpecModelFactory.cs Removes deprecation sample factories.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​SampleTypeSpecClient.cs Removes the deprecation subclient accessor and cache.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​SampleTypeSpecContext.cs Removes deprecation sample registrations.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​RenamedModelCustom.Serialization.cs Removes obsolete-reference suppressions.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​RenamedModelCustom.cs Removes the property attribute and suppressions.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​LegacyExtensibleChoice.cs Deletes the deprecated extensible-enum sample.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​LegacyDetails.Serialization.cs Deletes legacy model serialization.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​LegacyDetails.cs Deletes the deprecated model sample.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​LegacyChoice.Serialization.cs Deletes legacy enum serialization.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​LegacyChoice.cs Deletes the deprecated fixed-enum sample.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​CurrentDetails.Serialization.cs Deletes derived deprecation sample serialization.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​Models/​CurrentDetails.cs Deletes the derived deprecation sample model.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​DeprecationSamples.RestClient.cs Deletes deprecation sample request builders.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​DeprecationSamples.cs Deletes the deprecation sample client.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​CollectionResults/​ExperimentalSamplesGetAllCollectionResult.cs Updates experimental paging suppressions.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​CollectionResults/​ExperimentalSamplesGetAllAsyncCollectionResult.cs Updates asynchronous paging suppressions.
TestProjects/​Local/​Sample-TypeSpec/​src/​Custom/​DeprecationSamples.cs Deletes obsolete partial-method customizations.
TestProjects/​Local/​Sample-TypeSpec/​Sample-TypeSpec.tsp Removes deprecation sample definitions.
TestProjects/​Local.Tests/​CustomizationTests.cs Removes deprecation sample assertions.
Microsoft.TypeSpec.Generator/​test/​Writers/​TypeProviderWriterTests.cs Checks unchanged model output with deprecation metadata.
Microsoft.TypeSpec.Generator/​test/​Writers/​TestData/​TypeProviderWriterTests/​WriteDeprecatedEnumWithEscapedMessage.cs Deletes the obsolete enum output baseline.
Microsoft.TypeSpec.Generator/​test/​TypeFactoryTests.cs Removes provider identity-update tests.
Microsoft.TypeSpec.Generator/​test/​Providers/​TypeProviderTests.cs Removes deprecation tests; retains array customization coverage.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​DeprecationPreservesLastContract/​Types.cs Deletes prior-contract deprecation fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​DeprecationPreservesBackCompatOverloads/​LegacyClient.cs Deletes compatibility-overload fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​DeprecationIdentityUpdatesAreReflectedInGeneratedCode.cs Deletes the identity-update output baseline.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​DeprecatedPropertiesPreserveMessagesAndCustomizations/​Custom.cs Deletes the obsolete property customization fixture.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​DeprecatedCustomModelKeepsExistingAttribute/​Legacy.cs Deletes obsolete type customization fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepObsoleteOnDeclaration/​Custom.cs Deletes obsolete partial-method declarations.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepObsoleteOnDeclaration(True).cs Deletes the expression-bodied obsolete-method baseline.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepObsoleteOnDeclaration(False).cs Deletes the block-bodied obsolete-method baseline.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepExperimentalOnDeclaration/​Custom.cs Deletes experimental partial-method fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepExperimentalOnDeclaration(True).cs Deletes the expression-bodied experimental-method baseline.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomPartialMethodsKeepExperimentalOnDeclaration(False).cs Deletes the block-bodied experimental-method baseline.
Microsoft.TypeSpec.Generator/​test/​Providers/​TestData/​TypeProviderTests/​CustomObsoleteTypeReferencesUseDiagnosticId/​Custom.cs Deletes custom obsolete-diagnostic fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​PropertyProviderTests.cs Removes lazy attribute-enumerable tests.
Microsoft.TypeSpec.Generator/​test/​Providers/​ModelProviders/​TestData/​ModelProviderTests/​CustomizedObsoleteProperties/​Custom.cs Deletes obsolete property inheritance fixtures.
Microsoft.TypeSpec.Generator/​test/​Providers/​ModelProviders/​ModelProviderTests.cs Removes inherited deprecation suppression tests.
Microsoft.TypeSpec.Generator/​src/​Writers/​CodeWriter.cs Removes declaration-specific property suppressions.
Microsoft.TypeSpec.Generator/​src/​Utilities/​BackCompatHelper.cs Removes obsolete metadata handling for compatibility overloads.
Microsoft.TypeSpec.Generator/​src/​TypeFactory.cs Removes identity-map and serialization-cache maintenance helper.
Microsoft.TypeSpec.Generator/​src/​Statements/​SuppressionStatement.cs Reverts recursive statement unwrapping.
Microsoft.TypeSpec.Generator/​src/​Snippets/​ModelProviderSnippets.cs Removes accessed-property tracking.
Microsoft.TypeSpec.Generator/​src/​Shared/​ExperimentalApiHelpers.cs Removes obsolete diagnostic collection.
Microsoft.TypeSpec.Generator/​src/​Shared/​DeprecationApiHelpers.cs Deletes automatic deprecation helpers.
Microsoft.TypeSpec.Generator/​src/​Providers/​TypeProvider.cs Removes deprecation tracking and compatibility reconciliation.
Microsoft.TypeSpec.Generator/​src/​Providers/​PropertyProvider.cs Removes deprecation handling and reverts attribute materialization.
Microsoft.TypeSpec.Generator/​src/​Providers/​PartialMethodCustomization.cs Reverts custom attribute filtering.
Microsoft.TypeSpec.Generator/​src/​Providers/​NamedTypeSymbolProvider.cs Removes obsolete method metadata and overridden-property tracking.
Microsoft.TypeSpec.Generator/​src/​Providers/​ModelProvider.cs Removes property deprecation reconciliation and suppressions.
Microsoft.TypeSpec.Generator/​src/​Providers/​EnumProvider.cs Restores constructor assignment of deprecation metadata.
Microsoft.TypeSpec.Generator/​src/​Providers/​CanonicalTypeProvider.cs Removes custom override base-property linking.
Microsoft.TypeSpec.Generator.Input/​test/​TypeSpecInputConverterTests.cs Adds property deprecation metadata deserialization cases.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​DeprecationPreservesObsoleteOverloadsBesideStableSignatures/​TestClient.cs Deletes mixed stable/obsolete overload fixtures.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​DeprecationPreservesLastContractMethods/​TestClient.cs Deletes prior-contract method fixtures.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​DeprecatedCustomizedPartialMethodsKeepExistingAttributes/​TestClient.cs Deletes obsolete partial-method fixtures.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​TestData/​ScmMethodProviderCollectionTests/​CustomProtocolDiagnosticsAreSuppressedByConvenienceMethods/​TestClient.cs Deletes protocol diagnostic customization fixtures.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmModelProvider/​TestData/​ScmModelProviderTests/​TestMultipartFormDataModel_DeprecatedNonFilePartSuppressesFileOverloads.cs Deletes the multipart deprecation baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmModelProvider/​TestData/​ScmModelProviderTests/​OptionalNullableOverrideSuppressesDeprecatedBaseReference.cs Deletes the nullable override suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmModelProvider/​ScmModelProviderTests.cs Removes nullable override and multipart deprecation tests.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmMethodProviderCollectionTests.cs Removes method deprecation tests and suppression assertions.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​RestClientProviders/​TestData/​RestClientProviderTests/​ExplodedQuerySuppressesDeprecatedPropertyAccesses.cs Deletes the exploded-query suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​RestClientProviders/​RestClientProviderTests.cs Removes exploded-query deprecation tests.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​XmlSerializationTests.cs Removes inherited obsolete-property serialization tests.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​TestData/​XmlSerializationTests/​XmlSerializationSuppressesInheritedObsoletePropertyWarnings.cs Deletes the XML suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​TestData/​MrwSerializationTypeDefinitionTests/​SerializationReferencesHonorCustomObsoleteDiagnostic/​Legacy.cs Deletes the custom obsolete serialization fixture.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​TestData/​MrwSerializationTypeDefinitionTests/​SerializationReferencesHonorCustomObsoleteDiagnostic.cs Deletes the custom diagnostic serialization baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​TestData/​JsonModelCoreTests/​SerializationSuppressesInheritedObsoletePropertyWarning.cs Deletes the JSON suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​TestData/​JsonModelCoreTests/​CustomOverrideSerializationSuppressesInheritedObsoletePropertyWarning/​Custom.cs Deletes the custom override serialization fixture.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​MrwSerializationTypeDefinitionTests.cs Removes custom obsolete-diagnostic serialization coverage.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​MrwSerializationTypeDefinitions/​JsonModelCoreTests.cs Removes deprecation tests and restores constructor setup.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​EnumProvider/​TestData/​EnumProviderSerializationTests/​RenamedDeprecatedFixedEnumKeepsSerializationSuppressions.cs Deletes the renamed enum suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​EnumProvider/​EnumProviderSerializationTests.cs Removes renamed deprecated enum coverage.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​TestData/​ModelReaderWriterContextDefinitionTests/​ExperimentalObsoleteFrameworkTypesHaveAllSuppressions.cs Deletes the combined framework diagnostic baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​TestData/​ModelReaderWriterContextDefinitionTests/​CustomObsoleteDiagnosticIdsAreSuppressed/​CustomizedObsoleteModel.cs Deletes the custom context diagnostic fixture.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​TestData/​ModelReaderWriterContextDefinitionTests/​CustomObsoleteDiagnosticIdsAreSuppressed.cs Deletes the custom context suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​Definitions/​ModelReaderWriterContextDefinitionTests.cs Removes combined and custom obsolete diagnostic tests.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​CollectionResultDefinitions/​TestData/​CollectionResultDefinitionTests/​PagingSuppressesOnlyAccessedDeprecatedProperties.cs Deletes the scoped paging suppression baseline.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​CollectionResultDefinitions/​CollectionResultDefinitionTests.cs Removes deprecated paging-property suppression tests.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ClientProviders/​ClientProviderTests.cs Removes the client identity-map update test.
Microsoft.TypeSpec.Generator.ClientModel/​test/​ModelReaderWriterValidation/​TestProjects/​Sample_TypeSpec/​RenamedModelTests.cs Removes obsolete-property warning suppressions.
Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ScmModelProvider.cs Removes override and multipart assignment suppressions.
Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ScmMethodProviderCollection.cs Removes obsolete emission and property-access suppression tracking.
Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​RestClientProvider.cs Removes exploded-query property suppressions.
Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​ModelReaderWriterContextDefinition.cs Reverts context attributes to single-diagnostic suppression.
Microsoft.TypeSpec.Generator.ClientModel/​src/​Providers/​CollectionResultDefinition.cs Replaces per-access tracking with response-property suppressions.

Review effort: Balanced

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@@ -270,33 +270,14 @@ .. CreateRequestParameters
];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot lets pull the latest from main and address the merge conflicts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged the latest main and resolved the Sample-TypeSpec conflicts, preserving the union coverage while keeping the deprecated sample APIs removed. Merge commit: 60b509b7.

…tion-prs

# Conflicts:
#	packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/Sample-TypeSpec.tsp
#	packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/Models/SampleTypeSpecContext.cs
#	packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecClient.cs
#	packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/src/Generated/SampleTypeSpecModelFactory.cs
#	packages/http-client-csharp/generator/TestProjects/Local/Sample-TypeSpec/tspCodeModel.json

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants