Open
Description
Description
Using ConfigurationBuilder
with AddEnvironmentVariables
its not possible to make a collection empty, its only possible to make specific items null (using eg Some__Collection__0
)
Environment.SetEnvironmentVariable("Some__Collection", "{}"); //the same with empty string and "[]"
var x = new ConfigurationBuilder()
.AddJsonFile("test.json", optional: false, reloadOnChange: true)
//{
// "Some": {
// "Collection": [
// "value1"
// ]
// }
// }
.AddEnvironmentVariables()
.Build();
x.GetSection("Some:Collection").Get<IEnumerable<string>>(); // always have value1
Reproduction Steps
Run code included in the description
Expected behavior
Add and document a way to make a collection empty using env variables
Actual behavior
Original values are always read
Regression?
No response
Known Workarounds
No response
Configuration
.NET 9
Microsoft.Extensions.Configuration: 9.0.1
Microsoft.Extensions.Configuration.EnvironmentVariables: 9.0.1
Microsoft.Extensions.Configuration.Json: 9.0.1
Other information
No response