Skip to content

Configuration binding of array leads to duplicate values #45

@ite-klass

Description

@ite-klass

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions