-
Notifications
You must be signed in to change notification settings - Fork 175
Put all optional client parameters into client options #3910
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8717fbc
Put all optional client parameters into client options
pshao25 71287d1
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 4472b2f
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 c26032e
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 ab7d989
update
pshao25 4abe948
Regenerate all code (any successful run even without change will have…
actions-user 15b9299
update
pshao25 f750175
Merge branch 'constructor3706' of https://github.com/pshao25/autorest…
pshao25 4997efc
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 3d9d590
update
pshao25 e2d833e
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 7aa23a5
update
pshao25 862d4eb
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 66beca9
update
pshao25 b303284
update
pshao25 37f52ba
update
pshao25 d9f06da
update
pshao25 87d5950
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 1506b29
update
pshao25 2c96f11
update
pshao25 c9f5a2c
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 b428cee
update
pshao25 9fabdbe
update
pshao25 e4d0ab7
Merge branch 'feature/v3' of https://github.com/Azure/autorest.csharp…
pshao25 e20e3b7
update
pshao25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| ## Service Client Constrctors | ||
|
|
||
| Scope: This document only applies to DPG services. | ||
|
|
||
| There will be two **public** client constructors in a generated service client. One primary public constructor with all the user defined client parameters plus `ClientOptions`, and one secondary public constructor with all the user defined **required** client parameters. The secondary public constructor calls the primary public constructor underneath. | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
|
|
||
| For example, user defines required parameters `Uri endpoint` and `AzureKeyCredential credential`, then the generated public constructors are: | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```C# | ||
| public ServiceClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new ServiceClientOptions()) {} | ||
|
|
||
| public ServiceClient(Uri endpoint, AzureKeyCredential credential, ServiceClientOptions options) {} | ||
| ``` | ||
|
|
||
| Normally, all the client parameters are required. But if user defines some additional optional client parameters, all the optional client parameters will go to `ClientOptions`, except `endpoint`. | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
|
|
||
| For example, user defines an optional parameter `string optional`. The `ClientOptions` will have a new property as | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```C# | ||
| public partial class ServiceClientOptions : ClientOptions | ||
| { | ||
| ... | ||
|
|
||
| public string Optional { get; set; } | ||
| } | ||
| ``` | ||
|
|
||
| The signature of the public constructors will keep the same, but its implementation will become to | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
| ```C# | ||
| public ServiceClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new ServiceClientOptions()) {} | ||
|
|
||
| public ServiceClient(Uri endpoint, AzureKeyCredential credential, ServiceClientOptions options) | ||
| { | ||
| ... | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
| _optional = options.Optional; | ||
| } | ||
| ``` | ||
|
|
||
| If the optional client parameters user defines contains `endpoint`, it will still be in the client constructor, not going to `ClientOptions`. For example, user defines an optional parameter `string optional`, an optional `endpoint` with default value `"http://localhost:3000"`, and a required parameter `AzureKeyCredential credential`, the generated public constructors are: | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```C# | ||
| public ServiceClient(AzureKeyCredential credential) : this(new Uri("http://localhost:3000"), credential, new ServiceClientOptions()) {} | ||
|
|
||
| public ServiceClient(Uri endpoint, AzureKeyCredential credential, ServiceClientOptions options) | ||
| { | ||
| ... | ||
|
pshao25 marked this conversation as resolved.
Outdated
|
||
| _optional = options.Optional; | ||
| } | ||
|
|
||
| public partial class ServiceClientOptions : ClientOptions | ||
| { | ||
| ... | ||
|
|
||
| public string Optional { get; set; } | ||
| } | ||
| ``` | ||
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.