Skip to content

Microsoft.Extensions.Configuration add the ability to bypass "FormatException: A duplicate key" #113123

Open
@sb-viktor

Description

@sb-viktor

I'm using Microsoft.Extensions.Configuration.Ini v:9.0.2 and I get a FormatException every time I open the .ini file. For example I have this ini:

...

[UART]
Use = 1
Baudrate = 115200
COM = 31
COM = 25

...

And I build it into a configuration object:

IConfiguration config = new ConfigurationBuilder()
    .AddIniFile(filePath)
    .Build()

Then we get:

System.IO.InvalidDataException: 'Failed to load configuration from file 'filePath'.'
Inner Exception
FormatException: A duplicate key 'UART:COM' was found.


I want IConfigurationBuilder to overwrite the value itself. The last written value will be the value that will get to IConfigurationBuilder. If we consider the same example, the final COM value will be 25

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions