Ejemplo n.º 1
0
        public static void RemoveDuplicateOutputFiles(ManifestItemCollection manifestItems)
        {
            if (manifestItems == null)
            {
                throw new ArgumentNullException(nameof(manifestItems));
            }

            var manifestItemGroups = (from item in manifestItems
                                      from output in item.OutputFiles.Values
                                      let relativePath = output?.RelativePath
                                                         select new { item, relativePath }).GroupBy(obj => obj.relativePath, FilePathComparer.OSPlatformSensitiveStringComparer);

            foreach (var manifestItemGroup in manifestItemGroups)
            {
                if (manifestItemGroup.Count() > 1)
                {
                    // TODO: plan to change this warning to error, add error code to analyze the impact.
                    Logger.LogWarning(
                        $"Multiple input files would generate to the same output path overwriting each other. Please rename at least {manifestItemGroup.Count() - 1} of following input files to ensure that there will be only one file to generate to the output path: \"{string.Join(", ", manifestItemGroup.Select(duplicate => duplicate.item.SourceRelativePath))}\".",
                        code: WarningCodes.Build.DuplicateOutputFiles);

                    foreach (var itemToRemove in manifestItemGroup.Skip(1))
                    {
                        manifestItems.Remove(itemToRemove.item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void RemoveDuplicateOutputFiles(ManifestItemCollection manifestItems)
        {
            if (manifestItems == null)
            {
                throw new ArgumentNullException(nameof(manifestItems));
            }

            var itemsToRemove = new HashSet <string>();

            foreach (var duplicates in (from m in manifestItems
                                        from output in m.OutputFiles.Values
                                        let relativePath = output?.RelativePath
                                                           select new { item = m, relativePath })
                     .GroupBy(obj => obj.relativePath, FilePathComparer.OSPlatformSensitiveStringComparer)
                     .Where(g => g.Count() > 1))
            {
                // TODO: plan to change this warning to error, add error code to analyze the impact.
                var message = $"Multiple input files generate to the same output {duplicates} overwriting each other. " +
                              $"Please rename at least {duplicates.Count() - 1} of following files to resolve conflict: " +
                              string.Join(", ", duplicates.Select(i => $"{{file:'{i.item.SourceRelativePath}', group:'{i.item.Group}'}}"));
                Logger.LogWarning(message, code: WarningCodes.Build.DuplicateOutputFiles);
                itemsToRemove.UnionWith(duplicates.Skip(1).Select(duplicate => duplicate.item.SourceRelativePath));
            }
            manifestItems.RemoveAll(m => itemsToRemove.Contains(m.SourceRelativePath));
        }
Ejemplo n.º 3
0
 public static void ApplyLogCodes(ManifestItemCollection manifestItems, ConcurrentDictionary <string, ImmutableHashSet <string> > codes)
 {
     if (manifestItems == null)
     {
         throw new ArgumentException(nameof(manifestItems));
     }
     if (codes == null)
     {
         throw new ArgumentException(nameof(codes));
     }
     foreach (var item in manifestItems)
     {
         if (codes.TryGetValue(item.SourceRelativePath, out var value))
         {
             item.LogCodes = value;
         }
     }
 }
Ejemplo n.º 4
0
        public static void RemoveDuplicateOutputFiles(ManifestItemCollection manifestItems)
        {
            if (manifestItems == null)
            {
                throw new ArgumentNullException(nameof(manifestItems));
            }

            var itemsToRemove = new HashSet <string>();

            foreach (var duplicates in (from m in manifestItems
                                        from output in m.OutputFiles.Values
                                        let relativePath = output?.RelativePath
                                                           select new { item = m, relativePath })
                     .GroupBy(obj => obj.relativePath, FilePathComparer.OSPlatformSensitiveStringComparer)
                     .Where(g => g.Count() > 1))
            {
                Logger.LogWarning($"Overwrite occurs while input files \"{string.Join(", ", duplicates.Select(duplicate => duplicate.item.SourceRelativePath))}\" writing to the same output file \"{duplicates.Key}\"");
                itemsToRemove.UnionWith(duplicates.Skip(1).Select(duplicate => duplicate.item.SourceRelativePath));
            }
            manifestItems.RemoveAll(m => itemsToRemove.Contains(m.SourceRelativePath));
        }
Ejemplo n.º 5
0
        public static void RemoveDuplicateOutputFiles(ManifestItemCollection manifestItems)
        {
            if (manifestItems == null)
            {
                throw new ArgumentNullException(nameof(manifestItems));
            }

            var itemsToRemove = new HashSet <string>();

            foreach (var duplicates in (from m in manifestItems
                                        from output in m.OutputFiles.Values
                                        let relativePath = output?.RelativePath
                                                           select new { item = m, relativePath })
                     .GroupBy(obj => obj.relativePath, FilePathComparer.OSPlatformSensitiveStringComparer)
                     .Where(g => g.Count() > 1))
            {
                // TODO: plan to change this warning to error, add error code to analyze the impact.
                Logger.LogWarning(
                    $"Multiple input files are attempting to write to the same output file \"{duplicates.Key}\". Please rename at least {duplicates.Count() - 1} of following input files to ensure no duplicate output files: \"{string.Join(", ", duplicates.Select(duplicate => duplicate.item.SourceRelativePath))}\".",
                    code: WarningCodes.Build.DuplicateOutputFiles);
                itemsToRemove.UnionWith(duplicates.Skip(1).Select(duplicate => duplicate.item.SourceRelativePath));
            }
            manifestItems.RemoveAll(m => itemsToRemove.Contains(m.SourceRelativePath));
        }