Skip to content

Update CreateMessage call to use new overload with Uri, method, and classifier #8169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 12, 2025

Updates the TypeSpec C# HTTP client generator to use the new CreateMessage overload introduced in System.ClientModel 1.6.0 that accepts Uri, HTTP method, and response classifier parameters.

Changes Made

System.ClientModel Version Update:

  • Updated dependency from 1.5.0 to 1.6.0 in NewProjectScaffolding.cs

Generator Code Updates:

  • Updated ClientPipelineApi.CreateMessage abstract signature to accept ValueExpression uri, ValueExpression method, and ValueExpression responseClassifier parameters
  • Modified ClientPipelineProvider.CreateMessage implementation to pass these parameters to the underlying ClientPipeline.CreateMessage call
  • Restructured RestClientProvider to build the URI first, then call CreateMessage with the complete URI and HTTP method

Code Generation Pattern Change:
The generated client code pattern has been updated:

Before:

PipelineMessage message = Pipeline.CreateMessage();
message.ResponseClassifier = PipelineMessageClassifier200;
PipelineRequest request = message.Request;
request.Method = "GET";
ClientUriBuilder uri = new ClientUriBuilder();
uri.Reset(_endpoint);
request.Uri = uri.ToUri();

After:

ClientUriBuilder uri = new ClientUriBuilder();
uri.Reset(_endpoint);
PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200);
message.ResponseClassifier = PipelineMessageClassifier200;
PipelineRequest request = message.Request;

Test Updates:

  • Updated all affected test expectation files to match the new generated code pattern
  • Fixed test mock classes to match the updated abstract method signature

This change enables the generator to take advantage of the more efficient CreateMessage overload while maintaining full compatibility with existing functionality including complex scenarios like pagination and parameter handling.

Fixes #8168.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Update CreateMessage call to use new overload Update CreateMessage call to use new overload with Uri, method, and classifier Aug 12, 2025
@Copilot Copilot AI requested a review from JoshLove-msft August 12, 2025 19:59
Copilot finished work on behalf of JoshLove-msft August 12, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update CreateMessage call to use new overload
2 participants