case insensitive msbuild metadata findng
This commit is contained in:
parent
362f71a94a
commit
875d91629e
2 changed files with 12 additions and 14 deletions
|
@ -171,20 +171,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration
|
|||
|
||||
public static ProjectMetadataElement GetMetadataWithName(this ProjectItemElement item, string name)
|
||||
{
|
||||
return item.Metadata.FirstOrDefault(m => m.Name.Equals(name, StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
public static bool HasConflictingMetadata(this ProjectItemElement item, ProjectItemElement otherItem)
|
||||
{
|
||||
foreach (var metadata in item.Metadata)
|
||||
{
|
||||
if (otherItem.Metadata.Any(m => m.Name == metadata.Name && m.Value != metadata.Value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return item.Metadata.FirstOrDefault(m => m.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public static void AddMetadata(this ProjectItemElement item, ProjectMetadataElement metadata)
|
||||
|
|
|
@ -129,6 +129,17 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
item1.ConditionChainsAreEquivalent(item2).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMetadataWithName_is_case_insensitive()
|
||||
{
|
||||
var project = ProjectRootElement.Create();
|
||||
var item1 = project.AddItem("test", "include1");
|
||||
item1.AddMetadata("name", "value");
|
||||
|
||||
item1.GetMetadataWithName("Name").Should().NotBeNull();
|
||||
item1.GetMetadataWithName("Name").Value.Should().Be("value");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HasConflictingMetadata_returns_true_when_items_have_metadata_with_same_name_but_different_value()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue