private static void ApplyUniqueMetadataProperties(ITaskItem candidate) { var extension = candidate.GetMetadata("Extension"); var filename = candidate.GetMetadata("FileName"); switch (extension) { case ".dll": if (string.IsNullOrEmpty(candidate.GetMetadata("AssetTraitName"))) { candidate.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource"); candidate.SetMetadata("AssetTraitValue", "runtime"); } break; case ".wasm": case ".blat": case ".dat" when filename.StartsWith("icudt"): candidate.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource"); candidate.SetMetadata("AssetTraitValue", "native"); break; case ".pdb": candidate.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource"); candidate.SetMetadata("AssetTraitValue", "symbol"); candidate.RemoveMetadata("OriginalItemSpec"); break; default: break; } }
public void TestRemoveMetadata3() { item = new TaskItem("lalala"); item.SetMetadata("a", "b"); item.RemoveMetadata("a"); Assert.AreEqual(11, item.MetadataCount, "A1"); }
private void VerifyTaskItem(ITaskItem input, ITaskItem output) { // remove unnecessary metadata to keep only ones that would be in result task items var removeMetadata = new[] { MetadataKeys.IsImplicitlyDefined }; foreach (var rm in removeMetadata) { output.RemoveMetadata(rm); input.RemoveMetadata(rm); } input.ItemSpec.Should().Be(output.ItemSpec); foreach (var metadata in input.MetadataNames) { input.GetMetadata(metadata.ToString()).Should().Be(output.GetMetadata(metadata.ToString())); } }
private void VerifyTargetTaskItem(DependencyType type, ITaskItem input, ITaskItem output) { type.ToString().Should().Be(output.GetMetadata(MetadataKeys.Type)); // remove unnecessary metadata to keep only ones that would be in result task items var removeMetadata = new[] { MetadataKeys.Type, MetadataKeys.ResolvedPath }; foreach (var rm in removeMetadata) { output.RemoveMetadata(rm); input.RemoveMetadata(rm); } foreach (var metadata in input.MetadataNames) { input.GetMetadata(metadata.ToString()).Should().Be(output.GetMetadata(metadata.ToString())); } }
private void VerifyTaskItem(ITaskItem input, ITaskItem output, string expectedItemSpec = null) { // remove unnecessary metadata to keep only ones that would be in result task items var removeMetadata = new[] { MetadataKeys.IsImplicitlyDefined, MetadataKeys.IsTopLevelDependency, MetadataKeys.Type }; foreach (var rm in removeMetadata) { output.RemoveMetadata(rm); input.RemoveMetadata(rm); } if (expectedItemSpec != null) { expectedItemSpec.Should().Be(output.ItemSpec); } foreach (var metadata in input.MetadataNames) { input.GetMetadata(metadata.ToString()).Should().Be(output.GetMetadata(metadata.ToString())); } }
public override bool Execute() { string [] fields = FieldsToRemove.Split(new char [] { ',', ';' }); if (fields.Length == 0) { Log.LogWarning("No metadata field names specified, returning"); return(true); } ProcessedItems = new ITaskItem[Items.Length]; for (int i = 0; i < Items.Length; i++) { ITaskItem current = Items[i]; foreach (string fieldName in fields) { if (current.GetMetadata(fieldName) != null) { current.RemoveMetadata(fieldName); } } ProcessedItems[i] = current; } return(true); }
/// <summary> /// Some metadata should not be forwarded between the parent and child items. /// </summary> private static void RemoveNonForwardableMetadata(ITaskItem item) { item.RemoveMetadata(ItemMetadataNames.winmdImplmentationFile); item.RemoveMetadata(ItemMetadataNames.imageRuntime); item.RemoveMetadata(ItemMetadataNames.winMDFile); }
public void TestRemoveMetadata2() { item = new TaskItem("lalala"); item.RemoveMetadata(null); }
public void TestRemoveMetadata1() { item = new TaskItem("lalala"); item.RemoveMetadata("EXTension"); }
public void TestRemoveMetadata3 () { item = new TaskItem ("lalala"); item.SetMetadata ("a", "b"); item.RemoveMetadata ("a"); Assert.AreEqual (11, item.MetadataCount, "A1"); }
public void TestRemoveMetadata2 () { item = new TaskItem ("lalala"); item.RemoveMetadata (null); }
public void TestRemoveMetadata1 () { item = new TaskItem ("lalala"); item.RemoveMetadata ("EXTension"); }
static void CopyAllMetadata(ITaskItem source, ITaskItem dest) { // CopyMetadata adds an OriginalItemSpec, which we don't want. So we subsequently remove it source.CopyMetadataTo(dest); dest.RemoveMetadata("OriginalItemSpec"); }