-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-Extensions-Configurationneeds-breaking-change-doc-createdBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnetBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
Milestone
Description
Description
Before this changes I could convert any non-terminal section (section that doesn't have a value, but has child keys) to an array as shown the example below. This is not possible in the current implementation.
var configRoot = new ConfigurationBuilder()
.AddInMemoryCollection(new KeyValuePair<string, string>[]
{
new("section:key1", "1"),
new("section:key2", "2"),
new("section:key3", "3")
/**
{
"section": {
"key1": "1",
"key2": "2",
"key3": "3"
}
}
*/
})
.Build();
var values = configRoot.GetSection("section").Get<int[]>();
Assert.Equal(3, values.Length);
Assert.Equal(1, values[0]);
Assert.Equal(2, values[1]);
Assert.Equal(3, values[2]);Other information
This line of code requires the child key (as "key1", "key2", "key3" in example above) to be an integer.
Metadata
Metadata
Assignees
Labels
area-Extensions-Configurationneeds-breaking-change-doc-createdBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnetBreaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet