// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.Build.Framework; using System; using System.Collections.Concurrent; using System.IO; using System.Threading.Tasks; using System.Xml.Linq; namespace RepoTasks { /// /// Filters a list of .xml files to only those that are .NET Xml docs files /// public class GetDocXmlFiles : Microsoft.Build.Utilities.Task { [Required] public ITaskItem[] Files { get; set; } [Output] public ITaskItem[] XmlDocFiles { get; set; } public override bool Execute() { var xmlDocs = new ConcurrentBag(); Parallel.ForEach(Files, f => { try { using (var file = File.OpenRead(f.ItemSpec)) using (var reader = new StreamReader(file)) { string line; for (var i = 0; i < 2; i++) { line = reader.ReadLine(); if (i == 0 && line.StartsWith("") + 2); } if (line.StartsWith("", StringComparison.OrdinalIgnoreCase) || line.StartsWith("