Skip to content

Commit

Permalink
Call XElements "Property" with escaped names
Browse files Browse the repository at this point in the history
  • Loading branch information
Forgind committed Jul 30, 2021
1 parent 1d845f3 commit 7b41f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 3 additions & 7 deletions src/Tasks/CombineTargetFrameworkInfoProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Shared;
using System.Xml.Linq;

namespace Microsoft.Build.Tasks
Expand Down Expand Up @@ -36,9 +32,9 @@ public override bool Execute()
{
if (PropertiesAndValues != null)
{
XElement root = new XElement(RootElementName);
XElement root = new("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName)));

foreach (var item in PropertiesAndValues)
foreach (ITaskItem item in PropertiesAndValues)
{
root.Add(new XElement(item.ItemSpec, item.GetMetadata("Value")));
}
Expand Down
10 changes: 3 additions & 7 deletions src/Tasks/CombineXmlElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Shared;
using System.Xml.Linq;

namespace Microsoft.Build.Tasks
Expand All @@ -24,7 +20,7 @@ public class CombineXmlElements : TaskExtension
/// <summary>
/// The XML elements to include as children of the root element
/// </summary>
public ITaskItem [] XmlElements { get; set; }
public ITaskItem[] XmlElements { get; set; }

/// <summary>
/// The generated XML
Expand All @@ -36,7 +32,7 @@ public override bool Execute()
{
if (XmlElements != null)
{
XElement root = new XElement(RootElementName);
XElement root = new XElement("Property", new XAttribute("Name", EscapingUtilities.Escape(RootElementName)));

foreach (var item in XmlElements)
{
Expand Down

0 comments on commit 7b41f2c

Please sign in to comment.