Skip to content
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

Add support for repeated XML elements without a name attribute #44608

Merged
merged 23 commits into from
Mar 10, 2021

Commits on Nov 12, 2020

  1. Add support for repeated XML elements without a name attribute

    This commit adds support in Microsoft.Extensions.Configuration.Xml for repeated XML elements without requiring a Name attribute.
    This solves a particularly subtle bug when configuring Serilog from an XML configuration source. For a full description, see dotnet#36541
    
    The original implementation of the XmlStreamConfigurationProvider has been modified to do the following:
    
    - Maintain a stack of encountered XML elements while traversing the XML source. This is needed to detect siblings.
    - When siblings are detected, automatically append an index to the generated configuration keys. This makes it work exactly the same as the JSON configuration provider with JSON arrays.
    
    Tests are updated to reflect the new behavior:
    - Tests that verified an exception occurs when entering duplicate keys have been removed. Duplicate keys are supported now.
    - Add tests that verify duplicate keys result in the correct configuration keys, with all the lower/upper case variants and with support for the special "Name" attribute handling.
    amoerie committed Nov 12, 2020
    Configuration menu
    Copy the full SHA
    01401f0 View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2020

  1. Disable tests for duplicate handling in XML config, they are incompat…

    …ible with new implementation
    amoerie committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    f83dcfe View commit details
    Browse the repository at this point in the history
  2. Stop using the 'Name' parameter to use arrays in XML in the tests, th…

    …is is no longer required
    amoerie committed Nov 13, 2020
    Configuration menu
    Copy the full SHA
    8de7bda View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2020

  1. Configuration menu
    Copy the full SHA
    96ea0b9 View commit details
    Browse the repository at this point in the history

Commits on Dec 18, 2020

  1. Rework the XML configuration provider

    The XML configuration provider now builds a simple in-memory model of the XML elements that it encounters
    Each element keeps track of its attributes, children and content.
    Furthermore, each element also has a reference to its siblings.
    Each group of siblings all share the same list.
    
    All of the above makes it possible to intelligently produce configuration keys and values, taking into account repeated XML elements.
    amoerie committed Dec 18, 2020
    Configuration menu
    Copy the full SHA
    ca7097a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c601197 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2021

  1. Cleanup nullable annotations in XmlConfigurationElement

    Also don't explicitly initialize properties to null
    amoerie committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    3dddfca View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5b55a5f View commit details
    Browse the repository at this point in the history
  3. Remove empty line

    amoerie committed Feb 5, 2021
    Configuration menu
    Copy the full SHA
    cd11a03 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    ff2336f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    de44ff0 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    2f77e01 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5999c1c View commit details
    Browse the repository at this point in the history

Commits on Feb 8, 2021

  1. Apply suggestions from code review

    Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
    amoerie and safern authored Feb 8, 2021
    Configuration menu
    Copy the full SHA
    9a1af2a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6f07563 View commit details
    Browse the repository at this point in the history
  3. Add tests related to case insensitivity in XML configuration keys

    Verify that a duplicate key exception is thrown when keys are duplicate with different casing
    Verify that XML siblings are properly detected when the siblings have different casing
    Verify that values with keys that were originally upper case can be retrieved with their lower case counterparts
    amoerie committed Feb 8, 2021
    Configuration menu
    Copy the full SHA
    e479aa9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f2e56ee View commit details
    Browse the repository at this point in the history

Commits on Feb 28, 2021

  1. Configuration menu
    Copy the full SHA
    8901143 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2021

  1. Configuration menu
    Copy the full SHA
    862244e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    49024de View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2021

  1. Configuration menu
    Copy the full SHA
    2c2f1b3 View commit details
    Browse the repository at this point in the history
  2. Rename ProcessAttributes -> ReadAttributes when parsing the XML

    This avoids confusion with the ProcessXYZ helper methods that run during a different stage in the algorithm
    amoerie committed Mar 10, 2021
    Configuration menu
    Copy the full SHA
    22c02e8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5a60973 View commit details
    Browse the repository at this point in the history