Permalink
Browse files

fixed error where empty dependency set wasn't incuded in flattened de…

…ps; fixed error where an empty target fx was using the default target fx instead of remaining empty when flattened
  • Loading branch information...
1 parent f21797a commit a9ae38c26be3decb975435170a68f89bfa8b0843 @half-ogre half-ogre committed Jun 14, 2012
Showing with 39 additions and 8 deletions.
  1. +21 −1 Website/ExtensionMethods.cs
  2. +18 −7 Website/Services/PackageService.cs
@@ -52,7 +52,27 @@ public static string Flatten(this ICollection<PackageAuthor> authors)
public static string Flatten(this IEnumerable<PackageDependencySet> dependencySets)
{
- return FlattenDependencies(dependencySets.SelectMany(ds => ds.Dependencies.Select(d => new { d.Id, VersionSpec = d.VersionSpec.ToStringSafe(), TargetFramework = ds.TargetFramework == null ? null : VersionUtility.GetShortFrameworkName(ds.TargetFramework) })));
+ var dependencies = new List<dynamic>();
+
+ foreach (var dependencySet in dependencySets)
+ {
+ if (dependencySet.Dependencies.Count == 0)
+ dependencies.Add(new
+ {
+ Id = (string)null,
+ VersionSpec = (string)null,
+ TargetFramework = dependencySet.TargetFramework == null ? null : VersionUtility.GetShortFrameworkName(dependencySet.TargetFramework)
+ });
+ else
+ foreach (var dependency in dependencySet.Dependencies.Select(d => new { d.Id, d.VersionSpec, dependencySet.TargetFramework }))
+ dependencies.Add(new
+ {
+ dependency.Id,
+ VersionSpec = dependency.VersionSpec == null ? null : dependency.VersionSpec.ToString(),
+ TargetFramework = dependency.TargetFramework == null ? null : VersionUtility.GetShortFrameworkName(dependency.TargetFramework)
+ });
+ }
+ return FlattenDependencies(dependencies);
}
public static string Flatten(this ICollection<PackageDependency> dependencies)
@@ -287,13 +287,24 @@ Package CreatePackageFromNuGetPackage(PackageRegistration packageRegistration, I
foreach (var author in nugetPackage.Authors)
package.Authors.Add(new PackageAuthor { Name = author });
- foreach (var dependency in nugetPackage.DependencySets.SelectMany(ds => ds.Dependencies.Select(d => new { d.Id, d.VersionSpec, ds.TargetFramework })))
- package.Dependencies.Add(new PackageDependency
- {
- Id = dependency.Id,
- VersionSpec = dependency.VersionSpec.ToStringSafe(),
- TargetFramework = VersionUtility.GetShortFrameworkName(dependency.TargetFramework ?? VersionUtility.DefaultTargetFramework)
- });
+ foreach(var dependencySet in nugetPackage.DependencySets)
+ {
+ if (dependencySet.Dependencies.Count == 0)
+ package.Dependencies.Add(new PackageDependency
+ {
+ Id = null,
+ VersionSpec = null,
+ TargetFramework = dependencySet.TargetFramework == null ? null : VersionUtility.GetShortFrameworkName(dependencySet.TargetFramework)
+ });
+ else
+ foreach (var dependency in dependencySet.Dependencies.Select(d => new { d.Id, d.VersionSpec, dependencySet.TargetFramework }))
+ package.Dependencies.Add(new PackageDependency
+ {
+ Id = dependency.Id,
+ VersionSpec = dependency.VersionSpec == null ? null : dependency.VersionSpec.ToString(),
+ TargetFramework = dependency.TargetFramework == null ? null : VersionUtility.GetShortFrameworkName(dependency.TargetFramework)
+ });
+ }
package.FlattenedAuthors = package.Authors.Flatten();
package.FlattenedDependencies = package.Dependencies.Flatten();

0 comments on commit a9ae38c

Please sign in to comment.