Skip to content

Upgrade @typespec/http-specs to 0.1.0-alpha.35 and add missing Spector coverage#10128

Merged
JoshLove-msft merged 11 commits into
microsoft:mainfrom
JoshLove-msft:jolov/upgrade-http-specs-csharp
Mar 25, 2026
Merged

Upgrade @typespec/http-specs to 0.1.0-alpha.35 and add missing Spector coverage#10128
JoshLove-msft merged 11 commits into
microsoft:mainfrom
JoshLove-msft:jolov/upgrade-http-specs-csharp

Conversation

@JoshLove-msft
Copy link
Copy Markdown
Contributor

@JoshLove-msft JoshLove-msft commented Mar 25, 2026

Summary

Upgrades @typespec/http-specs from 0.1.0-alpha.33 to 0.1.0-alpha.35 and adds missing Spector test coverage for the C# HTTP client emitter. Includes two generator bug fixes discovered during the upgrade.

Changes

Dependency upgrade

  • Bumped @typespec/http-specs from 0.1.0-alpha.33 to 0.1.0-alpha.35
  • Regenerated all Spector libraries via Generate.ps1

Generator fixes

PropertyProvider CS0542 fix — The generator compared the raw property name against the enclosing type name to detect member-name collisions, but the collision occurs after PascalCase conversion (e.g. property filter on type Filter). Now compares the PascalCased identifier name and appends Property suffix when they match.

XML namespace declaration fix — The generator emitted namespace declarations inline on child elements instead of on the root element. While semantically valid XML, the Spector server's xml2js comparison treats these as structurally different. Now collects all property namespaces and declares them on the root element.

New Spector test coverage

special-words (1 new test):

  • ExtensibleStrings_PutExtensibleStringValueAsync

payload/xml (22 new tests):

  • Get/Put for ModelWithRenamedProperty, ModelWithNestedModel, ModelWithRenamedNestedModel, ModelWithWrappedPrimitiveCustomItemNames, ModelWithUnwrappedModelArray, ModelWithRenamedWrappedModelArray, ModelWithRenamedUnwrappedModelArray, ModelWithRenamedWrappedAndItemModelArray, ModelWithRenamedAttribute, ModelWithNamespace, ModelWithNamespaceOnProperties

Validation

  • Build: 0 errors, 0 warnings
  • All generator unit tests pass (including new PropertyProvider test)
  • XML Spector tests: 50/50 passed
  • Special-words Spector tests: 104/104 passed

JoshLove-msft and others added 2 commits March 24, 2026 17:13
…a.35

Regenerated Spector libraries to pick up changes in payload/pageable,
payload/xml, and special-words.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add tests for DictMethods, WithList model properties and
ExtensibleStrings.PutExtensibleStringValue scenarios.

Fix CS0542 build error in generated Filter.cs where property name
matched the enclosing type name (generator bug workaround).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Mar 25, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft JoshLove-msft enabled auto-merge March 25, 2026 00:38
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 25, 2026

Open in StackBlitz

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

commit: be5f0c2

@github-actions
Copy link
Copy Markdown
Contributor

No changes needing a change description found.

JoshLove-msft and others added 3 commits March 24, 2026 18:15
Add 23 new XML test scenarios covering:
- ModelWithRenamedProperty (get/put)
- ModelWithNestedModel (get/put)
- ModelWithRenamedNestedModel (get/put)
- ModelWithWrappedPrimitiveCustomItemNames (get/put)
- ModelWithUnwrappedModelArray (get/put)
- ModelWithRenamedWrappedModelArray (get/put)
- ModelWithRenamedUnwrappedModelArray (get/put)
- ModelWithRenamedWrappedAndItemModelArray (get/put)
- ModelWithRenamedAttribute (get/put)
- ModelWithNamespace (get/put)
- ModelWithNamespaceOnProperties (get/put)

Add AlternateInitialVerb pageable test for POST-based pagination
(new scenario from http-specs 0.1.0-alpha.35).

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

The generator compared the raw property name against the enclosing
type name to detect CS0542 conflicts, but the conflict occurs after
PascalCase conversion (e.g. property 'filter' on type 'Filter').

Now compares the PascalCased identifier name instead, correctly
appending 'Property' suffix to avoid the collision.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…P method bug

The generator uses POST for next-page requests but the spec expects
GET. This is a separate generator issue to be fixed in a follow-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@jorgerangel-msft jorgerangel-msft left a comment

Choose a reason for hiding this comment

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

It looks like the new xml scenarios are failing

JoshLove-msft and others added 3 commits March 25, 2026 11:50
The C# generator's XML serialization for namespace-prefixed models
produces invalid XML, causing the Spector server to crash. This
cascades to break ALL other PUT tests (including pre-existing ones).

Keep only GET tests which all pass and verify correct deserialization.
PUT tests can be re-added once the XML serialization bugs are fixed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The generator was emitting namespace declarations inline on child
elements (e.g. <ns2:author xmlns:ns2='...'>) instead of on the root
element. While semantically valid XML, the Spector server's xml2js
deep comparison treats these as structurally different, causing PUT
test failures.

Now collects all property namespaces and declares them on the root
element via WriteAttributeString('xmlns', prefix, null, namespace),
matching the expected XML format.

Restores all XML PUT tests (11 new scenarios).

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

Address review feedback:
- Only add xmlns declarations when the model itself has a root
  namespace (ns != null), avoiding spurious declarations on models
  without one (e.g. XmlAdvancedModel).
- Revert test expectation changes for models without root namespaces.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add WriteNamespaceDeclaration helper to XmlWriterSnippets. Use it instead of raw Invoke in BuildXmlWriteMethodBody.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@JoshLove-msft JoshLove-msft added this pull request to the merge queue Mar 25, 2026
Merged via the queue into microsoft:main with commit bf8d08e Mar 25, 2026
26 checks passed
@JoshLove-msft JoshLove-msft deleted the jolov/upgrade-http-specs-csharp branch March 25, 2026 23:22
msyyc pushed a commit that referenced this pull request Apr 1, 2026
…r coverage (#10128)

## Summary

Upgrades `@typespec/http-specs` from `0.1.0-alpha.33` to
`0.1.0-alpha.35` and adds missing Spector test coverage for the C# HTTP
client emitter. Includes two generator bug fixes discovered during the
upgrade.

## Changes

### Dependency upgrade
- Bumped `@typespec/http-specs` from `0.1.0-alpha.33` to
`0.1.0-alpha.35`
- Regenerated all Spector libraries via `Generate.ps1`

### Generator fixes

**PropertyProvider CS0542 fix** — The generator compared the raw
property name against the enclosing type name to detect member-name
collisions, but the collision occurs after PascalCase conversion (e.g.
property `filter` on type `Filter`). Now compares the PascalCased
identifier name and appends `Property` suffix when they match.

**XML namespace declaration fix** — The generator emitted namespace
declarations inline on child elements instead of on the root element.
While semantically valid XML, the Spector server's xml2js comparison
treats these as structurally different. Now collects all property
namespaces and declares them on the root element.

### New Spector test coverage

**special-words** (1 new test):
- `ExtensibleStrings_PutExtensibleStringValueAsync`

**payload/xml** (22 new tests):
- Get/Put for ModelWithRenamedProperty, ModelWithNestedModel,
ModelWithRenamedNestedModel, ModelWithWrappedPrimitiveCustomItemNames,
ModelWithUnwrappedModelArray, ModelWithRenamedWrappedModelArray,
ModelWithRenamedUnwrappedModelArray,
ModelWithRenamedWrappedAndItemModelArray, ModelWithRenamedAttribute,
ModelWithNamespace, ModelWithNamespaceOnProperties

## Validation
- Build: 0 errors, 0 warnings
- All generator unit tests pass (including new PropertyProvider test)
- XML Spector tests: 50/50 passed
- Special-words Spector tests: 104/104 passed

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants