Skip to content
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

Configuration binding of array leads to duplicate values #45

Open
ite-klass opened this issue Apr 17, 2024 · 0 comments
Open

Configuration binding of array leads to duplicate values #45

ite-klass opened this issue Apr 17, 2024 · 0 comments

Comments

@ite-klass
Copy link

ite-klass commented Apr 17, 2024

With configuration binding I see array values being duplicated.

With an app.toml file containing

[Logging]

[Logging.Sql]

[Logging.Email]
To = ['email1', 'email2']

config types

public record AppConfig(string ServiceName, LoggingConfig Logging)
{
    public AppConfig() : this(ServiceName: "AppName", Logging: new()) { }
}

public record LoggingConfig
{
    public LoggingEmailConfig? Email { get; set; }
}

public record LoggingEmailConfig(string[] To) { }

and setup

configurationManager.AddTomlFile("app.toml", optional: false, reloadOnChange: false);
var config = configurationManager..Get<AppConfig>();

config.Email.To now contains ["email1", "email2", "email1", "email2"] instead of ["email1", "email2"].

(I dropped unrelated properties and values from the types and toml to simplify the example.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant