-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Named Options inherit values from parent? #112365
Comments
Tagging subscribers to this area: @dotnet/area-system-configuration |
Related comment in the source code: runtime/src/libraries/Microsoft.Extensions.Options/src/ConfigureNamedOptions.cs Lines 100 to 109 in 02f99e5
If you want to configure only the default options, I think you'll need to use Options.DefaultName rather than However, if this is by design, then it seems worth mentioning in the OptionsConfigurationServiceCollectionExtensions.Configure documentation. |
The behavior looks inconsistent in that, after the |
Tagging subscribers to this area: @dotnet/area-extensions-configuration |
Description
Not sure if that is a bug or just not expected by me, but:
Nested options that I resolve by name have values from the parent set instead of nulls.
Reproduction Steps
Given appsettings like
Register both configs - default and named:
Resolve
AnotherMySettings
:Expected behavior
_mySettings.SomeValue
=foo2
_mySettings.AnotherValue
=null
Actual behavior
_mySettings.SomeValue
=foo2
_mySettings.AnotherValue
=bar1
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
Demo Project: https://github.com/matthiaslischka/NamedOptions/
The text was updated successfully, but these errors were encountered: