You've already forked linux-packaging-mono
Imported Upstream version 5.14.0.78
Former-commit-id: 3494343bcc9ddb42b36b82dd9ae7b69e85e0229f
This commit is contained in:
parent
74b74abd9f
commit
19234507ba
47
external/linker/corebuild/integration/ILLink.Tasks/FindDuplicatesByMetadata.cs
vendored
Normal file
47
external/linker/corebuild/integration/ILLink.Tasks/FindDuplicatesByMetadata.cs
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
namespace ILLink.Tasks
|
||||
{
|
||||
public class FindDuplicatesByMetadata : Task
|
||||
{
|
||||
/// <summary>
|
||||
/// Items to scan.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public ITaskItem [] Items { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name of metadata to scan for.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public String MetadataName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Duplicate items: the input items for which the
|
||||
/// specified metadata was shared by multiple input
|
||||
/// items.
|
||||
/// </summary>
|
||||
[Output]
|
||||
public ITaskItem [] DuplicateItems { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Duplicate representatives: includes one input
|
||||
/// item from each set of duplicates.
|
||||
/// </summary>
|
||||
[Output]
|
||||
public ITaskItem [] DuplicateRepresentatives { get; set; }
|
||||
|
||||
public override bool Execute ()
|
||||
{
|
||||
var duplicateGroups = Items.GroupBy (i => i.GetMetadata (MetadataName))
|
||||
.Where (g => g.Count () > 1);
|
||||
DuplicateItems = duplicateGroups.SelectMany (g => g).ToArray ();
|
||||
DuplicateRepresentatives = duplicateGroups.Select (g => g.First ()).ToArray ();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user