private static void ProcessPackage(Packages value, ErrorReporting reporting) { // Check for an empty file, where no resources/assets are listed. if (value.Count <= 0) { reporting.AddWarning("Package contains 0 assets"); } // Check that duplicate paths are reported as warnings. value .Select( s => new { Package = s.Key, Dupes = value[s.Key].Duplicates().ToList() }) .Where(s => s.Dupes.Count > 0) .ToList() .ForEach( s => reporting.AddWarning( string.Format("Package: {0} contains a duplicate asset paths:\n {1}", s.Package, string.Join("\n\t", s.Dupes.ToArray())))); // Check for infinite recursive includes of packages. }
/// <summary> /// Given that s is a .package path this will return the list of files /// for that package after recursively expanding that .package file. /// </summary> /// <param name="referencingFile"> /// The package where this the assetFile is referenced. /// </param> /// <param name="packageFile"> /// A .package file. /// </param> /// <param name="packages"> /// The set of packages being processed. /// </param> /// <returns> /// List of assets for the package s, where every .package has been expanded. /// </returns> private static IEnumerable<string> ExpandPackage( string referencingFile, string packageFile, Packages packages, HashSet<string> alreadyExpanded, ErrorReporting reporting) { // Have 2 cases: // case 1: packages contains reference. // case 2: packages DOES NOT contain reference. if (packages.ContainsKey(packageFile)) { if (alreadyExpanded.Contains(packageFile)) { reporting.AddError( string.Format( "Already included package:" + "\n\t{0} and including it again would cause infinite recursion." + "\n\tNo further expansion done.", packageFile)); return new List<string>(); } else { alreadyExpanded.Add(packageFile); return ExpandAssets(packageFile, packages, alreadyExpanded, reporting); } } else { reporting.AddWarning( string.Format( "Could not find package: {0}, as referenced in {1}", packageFile, referencingFile)); return new List<string>(); } }