Describe the bug
The C# generator emits undeclared local variables and substitutes default for constructor arguments when deserializing some models whose property names begin with an acronym such as VMware.
This is a regression between:
Microsoft.TypeSpec.Generator.ClientModel 1.0.0-alpha.20260817.7 (commit 1a7f2f4d05e819a8312528e8d207af2f90597d63)
Microsoft.TypeSpec.Generator.ClientModel 1.0.0-alpha.20260818.17 (commit a849fcfc965b6dc0cb8dffcb32132e71655a6b4a)
The affected range contains #11714 and its follow-up #11719. In particular, #11714 changed PropertyProvider.AsVariableExpression to reuse AsParameter, while #11719 changed normalization of newly generated property-derived parameters. The combination appears to make deserialization use the normalized/back-compat parameter expression without producing a corresponding local declaration or constructor argument.
Reproduction
Full Azure SDK for .NET regeneration:
Two affected generated models are:
InMageRcmFabricCreationContent
VMwareCbtEnableMigrationContent
For InMageRcmFabricCreationContent, the previous generator emitted:
ResourceIdentifier vMwareSiteId = default;
// ...
vMwareSiteId = new ResourceIdentifier(prop.Value.GetString());
// ...
return new InMageRcmFabricCreationContent(
instanceType,
additionalBinaryDataProperties,
vMwareSiteId,
physicalSiteId,
sourceAgentIdentity);
The new generator emits:
// No vmwareSiteId declaration
// ...
vmwareSiteId = new ResourceIdentifier(prop.Value.GetString());
// ...
return new InMageRcmFabricCreationContent(
instanceType,
additionalBinaryDataProperties,
default,
physicalSiteId,
sourceAgentIdentity);
VMwareCbtEnableMigrationContent has the equivalent change from the declared vMwareMachineId local to an undeclared vmwareMachineId, followed by default in the constructor call.
The full repository build fails with:
error CS0103: The name 'vmwareMachineId' does not exist in the current context
error CS0103: The name 'vmwareSiteId' does not exist in the current context
Relevant generated diffs:
Expected behavior
The deserializer should:
- Declare exactly one local for each deserialized property.
- Assign the JSON value to that local.
- Pass that local to the model constructor.
- Keep generated local/parameter naming internally consistent regardless of acronym normalization or last-contract parameter spelling.
It must not emit an undeclared assignment or replace a successfully deserialized required value with default.
Impact
The generated SDK does not compile. Independently of the compile error, the generated default constructor argument would discard the deserialized resource identifier.
The management generator's own test suite does not currently cover the combination of acronym-prefixed properties, last-contract constructor compatibility, and model deserialization, so its CI passed while the full Azure SDK regeneration failed.
Related issues: #11696, #11707.
- by copilot
Describe the bug
The C# generator emits undeclared local variables and substitutes
defaultfor constructor arguments when deserializing some models whose property names begin with an acronym such asVMware.This is a regression between:
Microsoft.TypeSpec.Generator.ClientModel1.0.0-alpha.20260817.7(commit1a7f2f4d05e819a8312528e8d207af2f90597d63)Microsoft.TypeSpec.Generator.ClientModel1.0.0-alpha.20260818.17(commita849fcfc965b6dc0cb8dffcb32132e71655a6b4a)The affected range contains #11714 and its follow-up #11719. In particular, #11714 changed
PropertyProvider.AsVariableExpressionto reuseAsParameter, while #11719 changed normalization of newly generated property-derived parameters. The combination appears to make deserialization use the normalized/back-compat parameter expression without producing a corresponding local declaration or constructor argument.Reproduction
Full Azure SDK for .NET regeneration:
Azure.Generator:1.0.0-alpha.20260818.5Microsoft.TypeSpec.Generator.ClientModel:1.0.0-alpha.20260818.17Two affected generated models are:
InMageRcmFabricCreationContentVMwareCbtEnableMigrationContentFor
InMageRcmFabricCreationContent, the previous generator emitted:The new generator emits:
VMwareCbtEnableMigrationContenthas the equivalent change from the declaredvMwareMachineIdlocal to an undeclaredvmwareMachineId, followed bydefaultin the constructor call.The full repository build fails with:
Relevant generated diffs:
Expected behavior
The deserializer should:
It must not emit an undeclared assignment or replace a successfully deserialized required value with
default.Impact
The generated SDK does not compile. Independently of the compile error, the generated
defaultconstructor argument would discard the deserialized resource identifier.The management generator's own test suite does not currently cover the combination of acronym-prefixed properties, last-contract constructor compatibility, and model deserialization, so its CI passed while the full Azure SDK regeneration failed.
Related issues: #11696, #11707.
- by copilot