fix: respect wire type for endpoint params in ClientSettings#10088
fix: respect wire type for endpoint params in ClientSettings#10088jorgerangel-msft merged 5 commits intomainfrom
Conversation
…lways Uri Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
jorgerangel-msft
left a comment
There was a problem hiding this comment.
@copilot lets also add a test to validate the generated internal ctor when the endpoint param is a string or a uri
...p/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientSettingsProvider.cs
Outdated
Show resolved
Hide resolved
...rator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientSettingsProviderTests.cs
Show resolved
Hide resolved
...rator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientSettingsProviderTests.cs
Show resolved
Hide resolved
…ointProperty PropertyProvider, add TestData-based tests and constructor tests Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Done in 82a38d4. Added |
jorgerangel-msft
left a comment
There was a problem hiding this comment.
@copilot lets also add a test case to validate the generated clientsettings when a client is defined like:
@server(
"https://{fullyQualifiedNamespace}",
"The Schema Registry service endpoint.",
{
@doc("The Schema Registry service endpoint, for example 'my-namespace.servicebus.windows.net'.")
fullyQualifiedNamespace: string,
}
)
...rator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientSettingsProviderTests.cs
Show resolved
Hide resolved
...rator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientSettingsProviderTests.cs
Show resolved
Hide resolved
…ctor + named string endpoint tests Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Added |
...Providers/TestData/ClientSettingsProviderTests/TestSettingsConstructor_WithStringEndpoint.cs
Outdated
Show resolved
Hide resolved
...Providers/TestData/ClientSettingsProviderTests/TestSettingsConstructor_WithStringEndpoint.cs
Outdated
Show resolved
Hide resolved
…lid generated code Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
ClientSettingsProviderunconditionally typed endpoint properties asUriand usedUri.TryCreatebinding, ignoring the actual wire type. Astring-typed endpoint likefullyQualifiedNamespace: stringshould producestring?, notUri?.Changes
ClientSettingsProvider.cs: ConsolidatedEndpointPropertyNameandEndpointPropertyTypeinto a singleEndpointPropertyof typePropertyProvider, created in the constructor from the input endpoint parameter's wire type.BuildProperties()includes the pre-created property directly, andBuildMethods()routes throughAppendBindingForProperty()instead of hardcodingUri.ClientProvider.cs: UpdatedBuildSettingsConstructors()to useClientSettings.EndpointPropertyinstead of the removedClientSettings.EndpointPropertyName.ClientSettingsProviderTests.cs: Tests combine inline assertions (property types, BindCore method signature and binding patterns) with TestData-based validation usingTypeProviderWriterto compare full generated output. AddedTestGeneratedSettings_WithStringEndpoint,TestGeneratedSettings_WithUrlEndpoint, andTestGeneratedSettings_WithNamedStringEndpoint(forfullyQualifiedNamespace: stringpattern) to validate generated settings. AddedTestSettingsConstructor_WithStringEndpointandTestSettingsConstructor_WithUrlEndpointwith TestData to validate the full generated client including the settings constructor for both endpoint types.Before/After
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.