-
Notifications
You must be signed in to change notification settings - Fork 839
Add support for repeated XML elements without a Name attribute in configuration XML files. #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…figuration XML files. - Maintain a stack of elements that are encountered during traversal of the XML file - Detect sibling elements and automatically append indexes to the generated configuration keys, exactly like how the JSON configuration providers does for JSON arrays - Add unit tests to verify no existing features were broken in the process - Existing tests were not modified, i.e. this is not a breaking change.
…own for duplicate keys This is obviously no longer the case, repeated elements now contribute to the key.
@ajcvickers Is there anything holding back this PR? Other than busy schedules. 😉 |
@amoerie Nope. Just time. |
Fair enough, thanks! |
Looking forward to this landing. Not being able to express lists like I was used to from json configs when the app uses xml instead was quite unexpected. Is there a rough timeframe for this landing by now? |
With this solution you are still not able to use IOptions
will not fill the list. This is because of the ItemName don't exists in Jsonfiles.
JsonConfigurationProvider would build paths like XmlConfigurationprovider build the path
Will generate But IOptions don't want the Item part Is there any possibility to remove "Item"? |
If you don't want "Item" to appear in the config list, I believe you can do the following: (with the changes from this PR)
|
I also want to use XmlSerializer to write to the File, without weird Attributes. Change Line 224:
This will fix my Issue, but maybe the behavior of IOptions should be fixed. |
I really wish this would get merged. I could do with some array-like behaviour in my XML configuration. |
As per aspnet/Announcements#411, we are currently migrating components from this repository to other repositories. This PR targets components that have been moved to dotnet/runtime, in the src/libraries directory. If you're still interested in contributing this change, please retarget your PR to dotnet/runtime and reference the original issue discussing the change or bug fix. If you have questions, or need guidance on how to port your change, please tag |
I've already migrated this pull request once. This pull request has been left open for more than a year. Obviously, there is no interest to actually merge this, so I don't think I'll spend the time again. |
@amoerie That's a shame. There's an issue with Serilog config where it requires sinks to be in an array and a property in each array object is actually called...... "Name". So it clashes with the XML "name" attribute requirement. Could really do with a fix. |
I would also like to see this merged. I stumbled into this issue while trying to add some legacy config files to a new dotnet core project. |
It's not that I'm unwilling to do the work again, it's that I'm not convinced this PR would get any attention, exactly as before. If I can get an "official" confirmation that this PR would be strongly considered for merging, I am willing to make it happen again. |
@amoerie I see that your PR was blocked twice because of two different repo consolidations. The source code is now moved to dotnet/runtime. Are you still interested in pushing a PR for this? |
Hi @maryamariyan I made the pull request here: dotnet/runtime#43722 I'm glad to see this is being followed up on. |
I'm recreating my original PR here, as requested in aspnet/Configuration#816 (comment) by @ajcvickers
I know this is a considerable change in the existing code, but all existing tests are still intact and green. The "Name" feature is still completely supported and as such, this is not a breaking change.
Addresses #485
Addresses #761