Skip to content

Honor custom code property replacements in generated ClientSettings.BindCore#10903

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/allow-property-replacement
Open

Honor custom code property replacements in generated ClientSettings.BindCore#10903
Copilot wants to merge 6 commits into
mainfrom
copilot/allow-property-replacement

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

When a generated ClientSettings property is replaced via [CodeGenMember("OriginalName")], the property was correctly dropped but the generated BindCore still assigned to the original (now non-existent) property, producing code that fails to compile.

// CUSTOM
public partial class QueueClientSettings
{
    [CodeGenMember("Url")]
    public Uri QueueUri { get; set; }
}

Previously BindCore emitted this.Url = url; (no longer exists). It now emits this.QueueUri = url; while still reading from the original section["Url"] key.

Changes

  • ClientSettingsProvider.GetSettingPropertyName: resolves the effective assignment target by matching the settings type's CanonicalView.Properties on OriginalName, returning the renamed name when a replacement exists.
  • configKey separation: threaded an optional configKey through AppendBindingForProperty and all Append*Binding helpers. configKey (original generated name) drives the configuration lookup; propName (possibly renamed) drives the property assignment. Defaults to propName, so existing callers (ClientOptionsProvider, tests) are unchanged.
  • BuildMethods: endpoint, required-parameter, and Options bindings now resolve their target name through GetSettingPropertyName, passing the original name as the config key.

Tests

  • Added TestBindCoreMethod_HonorsCustomPropertyRename with test data renaming EndpointServiceUri, asserting the assignment uses the renamed property while the config key stays "Endpoint".

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jun 5, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Allow property replacement in generated ClientSettings Honor custom code property replacements in generated ClientSettings.BindCore Jun 5, 2026
Copilot AI requested a review from jorgerangel-msft June 5, 2026 18:06
Comment thread .chronus/changes/honor-client-settings-custom-rename-2026-6-5-17-55-0.md Outdated
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10903

commit: eccc8c4

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@JoshLove-msft
Copy link
Copy Markdown
Contributor

@copilot resolve merge conflicts

…y-replacement

# Conflicts:
#	packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/ClientSettingsProviderTests.cs

Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 6, 2026

@copilot resolve merge conflicts

Merged origin/main. The only conflict was in ClientSettingsProviderTests.cs where both branches added a new test at the same spot — kept both (TestBindCoreMethod_HonorsCustomPropertyRename and TestGeneratedSettings_WithCustomizedBindCore). ClientSettingsProvider.cs auto-merged cleanly. All 41 ClientSettingsProviderTests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Property Replacement in Generated ClientSettings Using Custom Code

3 participants