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
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
01401f0
Add support for repeated XML elements without a name attribute
amoerie Nov 12, 2020
f83dcfe
Disable tests for duplicate handling in XML config, they are incompat…
amoerie Nov 13, 2020
8de7bda
Stop using the 'Name' parameter to use arrays in XML in the tests, th…
amoerie Nov 13, 2020
96ea0b9
Merge branch 'master' of github.com:dotnet/runtime into repeatedeleme…
amoerie Dec 17, 2020
ca7097a
Rework the XML configuration provider
amoerie Dec 18, 2020
c601197
Add test that verifies mixing repeated with non-repeated XML elements…
amoerie Dec 18, 2020
3dddfca
Cleanup nullable annotations in XmlConfigurationElement
amoerie Feb 5, 2021
5b55a5f
Use ordinal ignore case when detecting siblings in XML configuration
amoerie Feb 5, 2021
cd11a03
Remove empty line
amoerie Feb 5, 2021
ff2336f
Remove usage of Linq method '.Any()'
amoerie Feb 5, 2021
de44ff0
Remove dependency on System.Linq in XmlStreamConfigurationProvider
amoerie Feb 5, 2021
2f77e01
Simplify check that detects whether the current element is the root e…
amoerie Feb 5, 2021
5999c1c
Merge branch 'master' of github.com:dotnet/runtime into repeatedeleme…
amoerie Feb 5, 2021
9a1af2a
Apply suggestions from code review
amoerie Feb 8, 2021
6f07563
Add test for array simulation using Name attribute
amoerie Feb 8, 2021
e479aa9
Add tests related to case insensitivity in XML configuration keys
amoerie Feb 8, 2021
f2e56ee
Merge master and resolve conflicts
amoerie Feb 8, 2021
8901143
Improve performance of XML configuration provider
amoerie Feb 28, 2021
862244e
Revert accidental change of solution file
amoerie Mar 1, 2021
49024de
Merge branch 'main' into repeatedelementsinxmlconfig
amoerie Mar 1, 2021
2c2f1b3
Apply suggestion from feedback: simplify children list initialization
amoerie Mar 10, 2021
22c02e8
Rename ProcessAttributes -> ReadAttributes when parsing the XML
amoerie Mar 10, 2021
5a60973
Merge branch 'main' of github.com:dotnet/runtime into repeatedelement…
amoerie Mar 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;

namespace Microsoft.Extensions.Configuration.Xml
{
internal class XmlConfigurationElement
{
public string ElementName { get; }

public string Name { get; }

/// <summary>
/// A composition of ElementName and Name, that serves as the basis for detecting siblings
/// </summary>
public string SiblingName { get; }

/// <summary>
/// The children of this element
/// </summary>
public IDictionary<string, List<XmlConfigurationElement>> ChildrenBySiblingName { get; set; }

/// <summary>
/// Performance optimization: do not initialize a dictionary and a list for elements with a single child
/// </summary>
public XmlConfigurationElement SingleChild { get; set; }

public XmlConfigurationElementTextContent TextContent { get; set; }

public List<XmlConfigurationElementAttributeValue> Attributes { get; set; }

public XmlConfigurationElement(string elementName, string name)
{
ElementName = elementName ?? throw new ArgumentNullException(nameof(elementName));
Name = name;
SiblingName = string.IsNullOrEmpty(Name) ? ElementName : ElementName + ":" + Name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Microsoft.Extensions.Configuration.Xml
{
internal class XmlConfigurationElementAttributeValue
{
public XmlConfigurationElementAttributeValue(string attribute, string value, int? lineNumber, int? linePosition)
{
Attribute = attribute ?? throw new ArgumentNullException(nameof(attribute));
Value = value ?? throw new ArgumentNullException(nameof(value));
LineNumber = lineNumber;
LinePosition = linePosition;
}

public string Attribute { get; }

public string Value { get; }

public int? LineNumber { get; }

public int? LinePosition { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Microsoft.Extensions.Configuration.Xml
{
internal class XmlConfigurationElementTextContent
{
public XmlConfigurationElementTextContent(string textContent, int? linePosition, int? lineNumber)
{
TextContent = textContent ?? throw new ArgumentNullException(nameof(textContent));
LineNumber = lineNumber;
LinePosition = linePosition;
}

public string TextContent { get; }

public int? LineNumber { get; }

public int? LinePosition { get; }
}
}
Loading