[http-client-csharp] Add SSE protocol Spector scenarios - #11921
[http-client-csharp] Add SSE protocol Spector scenarios#11921JoshLove-msft wants to merge 8 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Upgrade all TypeSpec and Azure toolchain dependencies and matching peer declarations to the stable September releases. Keep SSE customizations and scenario generation out of the dependency PR. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Support namespace-qualified CodeGenType mappings, preserve used customization attributes in stubs, and regenerate fixtures for the full TypeSpec upgrade. Keep streaming scenario tests in their separate PR. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Revert 422b45e from this branch; the shared model rename is maintained independently in microsoft#11920. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge approved dependency baseline 3d9a081 from microsoft#11918. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
commit: |
|
No changes needing a change description found. |
There was a problem hiding this comment.
🟡 Changes recommended
The new stub-library “used customization attribute” detection compares minimally-qualified Roslyn names against fully-qualified provider names, which can cause required attributes to be incorrectly dropped.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the http-client-csharp TypeSpec dependency set and expands Spector coverage for SSE “protocol” scenarios, while also enhancing the generator’s customization handling (qualified-name matching) and stub-library pruning of unused customization attributes.
Changes:
- Bump TypeSpec/Azure Tools dependencies for
http-client-csharpand refresh Spector fixture outputs accordingly. - Add seven missing SSE protocol Spector tests (envelope/no-envelope, id/retry validation, and reconnect via
Last-Event-ID). - Prefer qualified
CodeGenTypenames during customization lookups and add tests for qualified-name model/enum customization; refine stub generation to drop unused customization attribute definitions.
File summaries
| File | Description |
|---|---|
| packages/http-client-csharp/package.json | Updates peer/dev dependency versions for the emitter toolchain. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/tspCodeModel.json | Regenerated SSE Spector code model reflecting new protocol surface. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/StreamingSseModelFactory.cs | Regenerated model factory with protocol model support. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/SseClient.cs | Regenerated client to expose GetProtocolClient(). |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/ProtocolData.cs | New generated protocol data client for envelope/no-envelope scenarios. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Protocol.cs | New generated protocol client for id/retry/reconnect scenarios. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/StreamingSseContext.cs | Registers ProtocolInfo for MRW buildable context. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/ProtocolInfo.Serialization.cs | New generated serialization for ProtocolInfo. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Models/ProtocolInfo.cs | New generated model type for protocol event payloads. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Generated/Internal/CodeGenTypeAttribute.cs | Generated customization attribute definition for fixture compilation. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/streaming/sse/src/Custom/ProtocolInfo.cs | Customization to rename protocol Info to ProtocolInfo. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/tspCodeModel.json | New/updated Spector code model for response “body or no content” fixture. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Response.BodyOrNoContent.csproj | Adds new Spector fixture project definition. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/schema/ConfigurationSchema.json | Adds generated configuration schema for the new fixture. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/ResponseBodyOrNoContentModelFactory.cs | Adds generated model factory for the new fixture. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/ResponseBodyOrNoContentContext.cs | Adds MRW context for fixture models. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/BlobLayout.Serialization.cs | Adds generated serialization for BlobLayout. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/Models/BlobLayout.cs | Adds generated model BlobLayout. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClientSettings.cs | Adds generated settings type for the new fixture client. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClientOptions.cs | Adds generated options type for the new fixture client. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/src/Generated/BodyOrNoContentClient.cs | Adds generated client for “body or no content” operations. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Response.BodyOrNoContent.slnx | Adds solution entry for the new fixture. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Response.BodyOrNoContent.NuGet.targets | Adds targets for configuration schema packing/consumption. |
| packages/http-client-csharp/generator/TestProjects/Spector/http/response/body-or-no-content/Configuration.json | Adds generator configuration for the new fixture. |
| packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Streaming/Sse/SseTests.cs | Adds seven SSE protocol Spector scenarios and a single-event reader helper. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/QualifiedNameOverridesSimpleName/CustomModels.cs | Test data for qualified vs simple customization precedence. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameModelsByQualifiedNames/CustomModels.cs | Test data for renaming multiple same-named models by qualified names. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameModelByQualifiedName/ProtocolInfo.cs | Test data for single qualified-name rename. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelCustomizationTests/CanRenameEnumByQualifiedName/FirstStatus.cs | Test data for qualified-name enum rename. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs | Adds unit tests validating qualified-name customization behavior. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/SourceInput/SourceInputModel.cs | Prefers qualified CodeGenType names when resolving customization types. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Properties/launchSettings.json | Adds a launch profile for the new Spector fixture. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestData/InputLibraryVisitorTests/StubKeepsUsedCustomizationAttributes/Model.cs | Test data to ensure stub keeps attributes when directly used. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/TestData/InputLibraryVisitorTests/StubKeepsInheritedCustomizationAttributes/Model.cs | Test data to ensure stub keeps base attributes for derived usage. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Microsoft.TypeSpec.Generator.ClientModel.Tests.csproj | Adds stub-library project reference needed by new tests. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/InputLibraryVisitorTests.cs | Adds tests verifying unused customization attributes are dropped/kept appropriately. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel.StubLibrary/src/StubLibraryVisitor.cs | Implements detection of which customization attributes are used by custom code. |
Review details
- Files reviewed: 21/38 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for (var type = semanticModel.GetTypeInfo(attribute).Type as INamedTypeSymbol; | ||
| type is not null; | ||
| type = type.BaseType) | ||
| { | ||
| names.Add(type.ToDisplayString()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return names; | ||
| } | ||
|
|
||
| protected override TypeProvider? VisitType(TypeProvider type) | ||
| { | ||
| var isUsedCustomizationAttribute = type is CustomCodeAttributeDefinition && | ||
| _usedCustomizationAttributes.Value.Contains($"{type.Type.Namespace}.{type.Name}"); |
Summary
Depends on #11918.
Add the seven missing SSE protocol Spector tests:
WithEnvelope,WithoutEnvelope,Id,InvalidId,Retry,InvalidRetry, andReconnect. Assert exact event counts, types, and payloads, valid metadata preserved, and invalid ID/retry metadata ignored. Reconnect is explicit usingRequestOptions: sendLast-Event-IDfrom the first event, then assert resumed event 2.The incremental diff over #11918 is only
SseTests.cs(+109 lines). Existing JSONL and basic SSE tests are unchanged. This branch retains the lower PR's reproducible pinned toolchain and C# customization; it adds no generator or TypeSpec customization. The shared model-name fix in #11920 is independent and can replace the lower workaround after publication and adoption.Validation
All 12 Streaming runtime tests and 12 coverage entries pass, with 0 skipped. Regenerated back to stubs with no generated diff from the lower PR. The final stubbed test-project build, formatting, lint, and Cop checks passed.
This fork-dependent PR targets Microsoft
main, so the lower ancestry remains until #11918 merges.