[http-client-csharp] Handling types that are both experimental and obsolete, including omitting unused types

Aperta
#12,408 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

Start with the C# generator changes in Azure/azure-sdk-for-net#64227 and inspect how it emits [Obsolete] and [Experimental] attributes, then trace model reachability and type suppression customization. The issue asks for a safe policy covering backward compatibility, retained SDK references, serialization, custom code, and generated suppressions. Done means proposing and implementing a policy or opt-in mechanism that handles these cases without breaking generated or custom code.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

emitter:client:csharp feature

Context

While updating the C# generator in Azure/azure-sdk-for-net#64227 to @typespec/http-client-csharp 1.0.0-alpha.20261026.4, regeneration added [Obsolete] to three types that already have [Experimental("AAIP001")]:

  • Azure.AI.Extensions.OpenAI.BrowserAutomationPreviewTool
  • Azure.AI.Projects.Agents.BrowserAutomationPreviewToolboxTool
  • Azure.AI.Projects.Agents.WorkflowAgentDefinition

This produces obsolete diagnostics at existing use sites. It also exposes a compiler interaction: adding [Obsolete] to an experimental type causes references inside that type to other experimental APIs to start reporting their diagnostics. For example, BrowserAutomationPreviewTool derives from OpenAI's experimental ResponseTool, so both generated and custom partial declarations start reporting OPENAI001.

Minimal reproduction

Verified with .NET SDK 10.0.401:

using System;
using System.Diagnostics.CodeAnalysis;

[Experimental("OPENAI001")]
public class ExperimentalBase { }

[Experimental("AAIP001")]
[Obsolete("Legacy")]
public class Derived : ExperimentalBase { }

The base-class reference reports OPENAI001. Removing only [Obsolete("Legacy")] makes the example compile without diagnostics.

Desired direction / questions

What should the generator's policy be for types that are both experimental and deprecated?

Ideally, we would not generate the type when it is not required for backward compatibility and is not otherwise used. Could we consider:

  • Omitting these types when the configured backward-compatibility baseline does not require them and no retained SDK surface depends on them, or providing an explicit opt-in policy for this behavior.
  • Defining the reachability rules carefully: client signatures, other models, polymorphic serialization/deserialization, and custom code may still require a type. Generator-created model factories or model-reader/writer context registrations should not accidentally make an otherwise unused type impossible to omit.
  • Providing a supported per-type exclusion customization when automatic omission cannot be determined safely. The current C# CodeGenSuppress attribute suppresses members, not top-level types.
  • When the type must remain, generating the necessary narrowly scoped suppressions for experimental dependencies so that adding [Obsolete] does not break generated code. Custom-code references may still need explicit acknowledgement.

The types above are examples of the attribute interaction, not a claim that they can all be removed as-is: there are existing custom dispatch, telemetry, test, and sample references that must be accounted for. The goal is to discuss a safe policy and customization mechanism rather than dropping every deprecated experimental type unconditionally.

Lingua principale
Java
Stelle
5.9k
Fork
421
Merge medio
2g 3h
PR unite (30g)
176

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/typespec

Tutte le issue di microsoft/typespec

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.