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

Loading list from appsettings.xml fails #770

Closed
Eilon opened this issue Feb 1, 2018 · 3 comments
Closed

Loading list from appsettings.xml fails #770

Eilon opened this issue Feb 1, 2018 · 3 comments

Comments

@Eilon
Copy link
Member

Eilon commented Feb 1, 2018

From @sandersaares on February 1, 2018 10:4

I haven an appsettings.xml file with the following structure:

<config>
    <aaa>value1</aaa>
    <aaa>value2</aaa>
</config>

I wish to load this using the XML configuration loading pattern documented at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration

Expected behavior: a list is loaded, accessible as aaa:0 and aaa:1

Actual behavior: System.FormatException occurred, Message=A duplicate key 'aaa' was found.

Copied from original issue: dotnet/aspnetcore#2842

@muqeet-khan
Copy link

@sandersaares you will need to provide some sort of indices to your array for it to be populated in the Configuration.

Example:

<config>
  <aaa name="s">
    value1
  </aaa>
  <aaa name="t">
    value2
  </aaa>
</config>

you can then call it by Configuration["aaa:s"] . Replace s,t with 0 based index and call Configuraiton["aaa:0"]

Here (#115 (comment)) is the only place I could find a relevant spec for this.

@amoerie
Copy link

amoerie commented Feb 5, 2018

More discussion on this issue can be found here: https://github.com/aspnet/Configuration/issues/745
The "name" attribute feels like a workaround, and a rather poorly documented one too. Other than having to do some work, I see no reason to not support simple repeated XML elements.

@ajcvickers
Copy link
Contributor

Duplicate of #745

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants