Skip to content
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

Compile-time codegen feedback #44580

Open
samvaity opened this issue Mar 10, 2025 · 0 comments
Open

Compile-time codegen feedback #44580

samvaity opened this issue Mar 10, 2025 · 0 comments
Assignees
Labels
Azure.Core.V2 Contains issues to consider when desiging Azure Core V2

Comments

@samvaity
Copy link
Member

samvaity commented Mar 10, 2025

  1. 'defaultPipeline' is not the right name - it is the httpPipeline

  2. get rid of the 'getPipeline' method - just use the final field directly.

  3. Don't create a 'String host' if the value is only used in one place - just put it directly into that place.

  4. Chain the 'create HTTP request' calls, to reduce the number of 'httpRequest.getHeaders().' calls, e.g. rather than this:

// Create the HTTP request

HttpRequest httpRequest = new HttpRequest().setMethod(HttpMethod.POST).setUri(host);

httpRequest.getHeaders().add(HttpHeaderName.CONTENT_LENGTH, String.valueOf(contentLength));

httpRequest.getHeaders().add(HttpHeaderName.CONTENT_TYPE, contentType);

Can you generate this:

// Create the HTTP request

HttpRequest httpRequest = new HttpRequest()

.setMethod(HttpMethod.POST)

.setUri(host)

.getHeaders()

	.add(HttpHeaderName.CONTENT_LENGTH, String.valueOf(contentLength))

	.add(HttpHeaderName.CONTENT_TYPE, contentType);
  1. Remember to add in whitespace lines before the various // comments - let's make the generated code pretty

  2. Line 94 seems unnecessary: BinaryData binaryData = (BinaryData) data; (where data is already BinaryData)

@samvaity samvaity self-assigned this Mar 10, 2025
@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Mar 10, 2025
@joshfree joshfree added Azure.Core.V2 Contains issues to consider when desiging Azure Core V2 and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core.V2 Contains issues to consider when desiging Azure Core V2
Projects
None yet
Development

No branches or pull requests

2 participants