Bug Report
Emitter Version
@azure-typespec/http-client-csharp v1.0.0-alpha.20260512.2
Description
@@clientName directives for discriminated union subtypes are ignored during code generation. The emitter generates classes using the original TypeSpec model name instead of the @@clientName-specified name.
This is a regression — the GA version of our SDK (generated with an earlier emitter) correctly produced ContentArrayField, ContentStringField, etc. The new emitter produces ArrayField, StringField, etc., ignoring the @@clientName directives.
Repro
TypeSpec models (models.tsp):
@discriminator("type")
model ContentField { ... }
model ArrayField extends ContentField {
type: ContentFieldType.array;
valueArray?: ContentField[];
}
model StringField extends ContentField {
type: ContentFieldType.string;
valueString?: string;
}
// ... other subtypes of ContentField discriminated union
Client customization (client.tsp) — source: client.tsp L166-L174:
@@clientName(StringField, "ContentStringField", "csharp");
@@clientName(DateField, "ContentDateTimeOffsetField", "csharp");
@@clientName(TimeField, "ContentTimeField", "csharp");
@@clientName(NumberField, "ContentNumberField", "csharp");
@@clientName(IntegerField, "ContentIntegerField", "csharp");
@@clientName(BooleanField, "ContentBooleanField", "csharp");
@@clientName(ArrayField, "ContentArrayField", "csharp");
@@clientName(ObjectField, "ContentObjectField", "csharp");
@@clientName(JsonField, "ContentJsonField", "csharp");
Expected Behavior
The emitter should generate C# classes with the @@clientName-specified names:
ContentArrayField.cs
ContentStringField.cs
ContentDateTimeOffsetField.cs
- etc.
Actual Behavior
The emitter generates classes using the original TypeSpec model names, ignoring @@clientName:
ArrayField.cs
StringField.cs
DateField.cs
- etc.
Impact
This is a breaking change for our published GA SDK (Azure.AI.ContentUnderstanding). Our GA SDK exposes ContentArrayField, ContentStringField, etc. as public types. Regenerating with the new emitter renames these types, breaking:
- All consumer code using these types
- Our customization files (
ContentUnderstandingClient.Customizations.cs) which reference these types by their @@clientName names — resulting in 144 compilation errors after regeneration
Merged GA SDK (proof that older emitter correctly applied @@clientName)
Context
- TypeSpec
@@clientName directives: client.tsp L166-L174 (C#) and client.tsp L207-L215 (Java)
- TypeSpec repo:
azure-rest-api-specs-pr (private), PR #27815
- SDK:
Azure.AI.ContentUnderstanding
- API version:
2026-07-01-preview (base GA: 2025-11-01)
- The same issue also affects the Java emitter (
@azure-tools/typespec-java) — Azure/autorest.java#3337
Bug Report
Emitter Version
@azure-typespec/http-client-csharpv1.0.0-alpha.20260512.2Description
@@clientNamedirectives for discriminated union subtypes are ignored during code generation. The emitter generates classes using the original TypeSpec model name instead of the@@clientName-specified name.This is a regression — the GA version of our SDK (generated with an earlier emitter) correctly produced
ContentArrayField,ContentStringField, etc. The new emitter producesArrayField,StringField, etc., ignoring the@@clientNamedirectives.Repro
TypeSpec models (
models.tsp):Client customization (
client.tsp) — source:client.tspL166-L174:Expected Behavior
The emitter should generate C# classes with the
@@clientName-specified names:ContentArrayField.csContentStringField.csContentDateTimeOffsetField.csActual Behavior
The emitter generates classes using the original TypeSpec model names, ignoring
@@clientName:ArrayField.csStringField.csDateField.csImpact
This is a breaking change for our published GA SDK (
Azure.AI.ContentUnderstanding). Our GA SDK exposesContentArrayField,ContentStringField, etc. as public types. Regenerating with the new emitter renames these types, breaking:ContentUnderstandingClient.Customizations.cs) which reference these types by their@@clientNamenames — resulting in 144 compilation errors after regenerationMerged GA SDK (proof that older emitter correctly applied
@@clientName)ContentArrayField.csContentUnderstandingClient.Customizations.csContext
@@clientNamedirectives:client.tspL166-L174 (C#) andclient.tspL207-L215 (Java)azure-rest-api-specs-pr(private), PR #27815Azure.AI.ContentUnderstanding2026-07-01-preview(base GA:2025-11-01)@azure-tools/typespec-java) — Azure/autorest.java#3337