-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse package information for unique packages (#50)
- Loading branch information
Showing
4 changed files
with
117 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Jeff Kluge. All rights reserved. | ||
// | ||
// Licensed under the MIT license. | ||
|
||
using NuGet.Packaging; | ||
using NuGet.Packaging.Core; | ||
using System.Collections.Concurrent; | ||
|
||
namespace PackagesConfigConverter | ||
{ | ||
internal sealed class PackageInfoFactory | ||
{ | ||
private readonly PackagePathResolver _packagePathResolver; | ||
private readonly VersionFolderPathResolver _versionFolderPathResolver; | ||
private readonly ConcurrentDictionary<PackageIdentity, PackageInfo> _packages = new (); | ||
|
||
public PackageInfoFactory(PackagePathResolver packagePathResolver, VersionFolderPathResolver versionFolderPathResolver) | ||
{ | ||
_packagePathResolver = packagePathResolver; | ||
_versionFolderPathResolver = versionFolderPathResolver; | ||
} | ||
|
||
public PackageInfo GetPackageInfo(PackageIdentity identity) => _packages.GetOrAdd(identity, id => new PackageInfo(id, _packagePathResolver, _versionFolderPathResolver)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Jeff Kluge. All rights reserved. | ||
// | ||
// Licensed under the MIT license. | ||
|
||
using CommandLine; | ||
using Microsoft.Build.Construction; | ||
using NuGet.Packaging.Core; | ||
using NuGet.Versioning; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace PackagesConfigConverter | ||
{ | ||
internal sealed class PackageUsage | ||
{ | ||
public PackageUsage(PackageIdentity identity, PackageInfo packageInfo, bool isDevelopmentDependency) | ||
{ | ||
PackageInfo = packageInfo; | ||
IsDevelopmentDependency = isDevelopmentDependency; | ||
} | ||
|
||
public PackageInfo PackageInfo { get; } | ||
|
||
public bool IsDevelopmentDependency { get; } | ||
|
||
public IEnumerable<ProjectElement> AllElements => AnalyzerItems.Cast<ProjectElement>().Concat(AssemblyReferences).Concat(Imports); | ||
|
||
public List<ProjectItemElement> AnalyzerItems { get; } = new (); | ||
|
||
public List<ProjectItemElement> AssemblyReferences { get; } = new (); | ||
|
||
public List<ProjectImportElement> Imports { get; } = new (); | ||
|
||
public bool GeneratePathProperty { get; set; } | ||
|
||
public bool IsMissingTransitiveDependency { get; set; } | ||
|
||
public string PackageId => PackageInfo.Identity.Id; | ||
|
||
public NuGetVersion PackageVersion => PackageInfo.Identity.Version; | ||
} | ||
} |
Oops, something went wrong.