Include custom code properties in ConfigurationSchema.json and ClientSettings binding#10243
Merged
JoshLove-msft merged 4 commits intomicrosoft:mainfrom Apr 2, 2026
Conversation
…nSchema.json The ConfigurationSchemaGenerator now includes properties from CustomCodeView on client options types, and custom constructor parameters from client types. Previously, only properties from the TypeSpec input model were included in the generated schema. Hand-written properties added via partial classes (e.g., Audience on ConfigurationClientOptions) were silently dropped when the schema was regenerated. Changes: - BuildOptionsSchema: merges CustomCodeView properties with generated ones - BuildClientEntry: discovers custom constructor parameters from CustomCodeView - Added tests for both scenarios with custom code compilation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
…constructors Apply the same custom code property discovery to: - ClientOptionsProvider.BuildConfigurationSectionConstructor: binds custom code properties from configuration section - ClientSettingsProvider.BuildProperties: includes custom constructor params as settings properties - ClientSettingsProvider.BuildMethods (BindCore): binds custom constructor params from configuration section Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ClientOptionsProviderTests: verify config section constructor binds custom code properties (e.g., Audience from partial class) - ClientSettingsProviderTests: verify custom constructor parameters appear in settings properties and BindCore method Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…andard types - Move knownProps HashSet allocation inside the custom constructors null check to avoid unnecessary allocation (PR feedback from jorgerangel-msft) - Add IsStandardParameterType helper to filter out credential types (AuthenticationTokenProvider), endpoint types (Uri), and options types from custom constructor parameter discovery - Compare by both type equality and name to handle Roslyn vs typeof CSharpType mismatch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jsquire
approved these changes
Apr 1, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
ConfigurationSchemaGenerator,ClientOptionsProviderconfig constructor, andClientSettingsProvideronly discover properties from the TypeSpec input model (BuildProperties()). Hand-written properties added via partial classes (e.g.,AudienceonConfigurationClientOptionsin Azure.Data.AppConfiguration) are silently dropped when:BindCoremethod binds valuesThis was discovered via Azure/azure-sdk-for-net#57682 where bumping the emitter version caused the
Audienceproperty to disappear from the generatedConfigurationSchema.json.Fix
ConfigurationSchemaGenerator
BuildOptionsSchema: After collecting generated properties, also merges public properties fromclientOptions.CustomCodeView?.PropertiesBuildClientEntry: After collecting generated required params, discovers custom constructor parameters fromclient.CustomCodeView?.ConstructorsClientOptionsProvider
BuildConfigurationSectionConstructor: Now also binds custom code properties from the configuration sectionClientSettingsProvider
BuildProperties: Now includes custom constructor parameters as settings propertiesBuildMethods(BindCore): Now binds custom constructor parameters from configurationTests
Added 5 new tests across 3 test classes:
ConfigurationSchemaGeneratorTests.Generate_IncludesCustomCodeOptionsPropertiesConfigurationSchemaGeneratorTests.Generate_IncludesCustomConstructorParametersClientOptionsProviderTests.TestConfigurationSectionConstructorBody_BindsCustomCodePropertiesClientSettingsProviderTests.TestProperties_IncludesCustomConstructorParametersClientSettingsProviderTests.TestBindCoreMethod_BindsCustomConstructorParametersAll 91 related tests pass.