Skip to content

Support immutable types with configuration binding #43662

@davidfowl

Description

@davidfowl

Similar to #43359 but specifically for configuration binding. Support binding from IConfiguration to say a record or any immutable .NET object. This has been solved in JSON (it's basically deserialization) and we can use any lessons learned there to implement a solution in configuration.

public record Settings(string Color, int Length);

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<Settings>(Configuration.GetSection("MySettings"));
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions