Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

BCL API review: Split implementation of IConfigurationSourceRoot and IConfiguration #194

Closed
@divega

Description

@divega

While the consuming and producing interfaces (IConfiguration and IConfigurationSourceRoot) are already separate, there is one concrete implementation (Configuration) that conflates them.

This causes a usability issue. The following code looks like should work but won't compile:

IConfiguration Configuration;
...
Configuration = new Configuration
    .AddJsonFile("config.json")
    .AddEnvironmentVariables();

While you can invoke the AddX extension methods on a Configuration, the methods will (appropriately) return IConfigurationSourceRoot which cannot be assigned to IConfiguration.

We will try separating them so that the separation is more explicit, e.g.:

IConfiguration Configuration;
...
var configurationBuilder = 
    new ConfigurationBuilder(appEnv.ApplicationBasePath) 
        .AddJsonFile("config.json") 
        .AddEnvironmentVariables(); 
Configuration = configurationBuilder.Build(); 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions