Add spector test for alternate-type with emitter fixes for external types#861
Merged
Add spector test for alternate-type with emitter fixes for external types#861
Conversation
Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Co-authored-by: antkmsft <41349689+antkmsft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add spector test for azure-http-specs
Add spector test for alternate-type with emitter fixes for external types
Feb 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds spector test coverage for the azure/client-generator-core/alternate-type spec, demonstrating external type replacement using the geojson::Feature crate. To support this, the emitter was enhanced to gracefully handle non-discriminated unions that appear in external types (which will be replaced and thus won't be emitted) and to support the TypeSpec numeric base type by mapping it to Rust's f64.
Changes:
- Enhanced emitter to skip non-discriminated unions in
adaptTypes()instead of failing, since external types containing these unions will be replaced - Added support for TypeSpec's
numerictype by mapping it tof64in Rust code generation - Added comprehensive spector test suite for alternate-type feature with TypeSpec definitions, Cargo workspace integration, generated code, and integration tests
Reviewed changes
Copilot reviewed 8 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typespec-rust/src/tcgcadapter/adapter.ts | Emitter enhancements: skip non-discriminated unions in adaptTypes() and getType(); map numeric type to f64 |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/main.tsp | TypeSpec definitions for Feature, Geometry, and test operations demonstrating external type usage |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/client.tsp | Rust-specific alternateType decorator mapping Feature to geojson::Feature |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/Cargo.toml | Package configuration with geojson dependency |
| packages/typespec-rust/test/Cargo.toml | Workspace member addition and geojson dependency declaration |
| packages/typespec-rust/test/Cargo.lock | Dependency lock file updates for geojson and transitive dependencies |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/src/lib.rs | Library entry point |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/src/generated/* | Generated client and model code using external geojson::Feature type |
| packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/tests/external_type_client.rs | Integration tests validating external type usage in operations and model properties |
| packages/typespec-rust/.scripts/tspcompile.js | Build script integration for the new test suite |
RickWinter
reviewed
Feb 18, 2026
packages/typespec-rust/test/spector/azure/client-generator-core/alternate-type/client.tsp
Show resolved
Hide resolved
jhendrixMSFT
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds spector test for
azure/client-generator-core/alternate-typedemonstrating external type replacement withgeojson::Feature.Changes
Emitter: Handle non-discriminated unions in external types
adaptTypes()instead of failinggetType()when encountering unsupported unionsEmitter: Add
numerictype supportnumericbase type tof64Test infrastructure
client.tspwith RustalternateTypedecorator mapping Feature →geojson::FeatureExample
Generated code uses external type from geojson crate:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.