Skip to content

Commit

Permalink
apply changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhomutov committed Jan 15, 2025
1 parent eee55db commit cc1fb27
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,6 @@ namespace Orc.NuGetExplorer
NuGet.Packaging.Core.PackageIdentity GetIdentity();
void ResetValidationContext();
}
public static class IPackageInstallationServiceExtensions
{
public static System.Threading.Tasks.Task<Orc.NuGetExplorer.InstallerResult> InstallAsync(this Orc.NuGetExplorer.Services.IPackageInstallationService service, NuGet.Packaging.Core.PackageIdentity package, Orc.NuGetExplorer.IExtensibleProject project, System.Collections.Generic.IReadOnlyList<NuGet.Protocol.Core.Types.SourceRepository> repositories, bool ignoreMissingPackages = false, System.Func<NuGet.Packaging.Core.PackageIdentity, bool>? packagePredicate = null, System.Threading.CancellationToken cancellationToken = default) { }
}
public interface IPackageLoaderService
{
Orc.NuGetExplorer.Providers.IPackageMetadataProvider? PackageMetadataProvider { get; }
Expand Down Expand Up @@ -432,6 +428,23 @@ namespace Orc.NuGetExplorer
string GetDirectory(string relativeDirectoryName);
string GetFile(string relativeFilePath);
}
[System.Runtime.CompilerServices.RequiredMember]
public class InstallationContext
{
[System.Obsolete(("Constructors of types with required members are not supported in this version of " +
"your compiler."), true)]
[System.Runtime.CompilerServices.CompilerFeatureRequired("RequiredMembers")]
public InstallationContext() { }
public bool AllowMultipleVersions { get; set; }
public bool IgnoreMissingPackages { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public NuGet.Packaging.Core.PackageIdentity Package { get; set; }
public System.Func<NuGet.Packaging.Core.PackageIdentity, bool>? PackagePredicate { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public Orc.NuGetExplorer.IExtensibleProject Project { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public System.Collections.Generic.IReadOnlyList<NuGet.Protocol.Core.Types.SourceRepository> Repositories { get; set; }
}
public class InstallerResult
{
public InstallerResult(System.Collections.Generic.IDictionary<NuGet.Protocol.Core.Types.SourcePackageDependencyInfo, NuGet.Protocol.Core.Types.DownloadResourceResult> downloadResult) { }
Expand Down Expand Up @@ -988,26 +1001,6 @@ namespace Orc.NuGetExplorer.Messaging
public PackagingDeletemeMessage(Orc.NuGetExplorer.Packaging.PackageOperationInfo content) { }
}
}
namespace Orc.NuGetExplorer.Models
{
[System.Runtime.CompilerServices.RequiredMember]
public class InstallationContext
{
[System.Obsolete(("Constructors of types with required members are not supported in this version of " +
"your compiler."), true)]
[System.Runtime.CompilerServices.CompilerFeatureRequired("RequiredMembers")]
public InstallationContext() { }
public bool AllowMultipleVersions { get; set; }
public bool IgnoreMissingPackages { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public NuGet.Packaging.Core.PackageIdentity Package { get; set; }
public System.Func<NuGet.Packaging.Core.PackageIdentity, bool>? PackagePredicate { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public Orc.NuGetExplorer.IExtensibleProject Project { get; set; }
[System.Runtime.CompilerServices.RequiredMember]
public System.Collections.Generic.IReadOnlyList<NuGet.Protocol.Core.Types.SourceRepository> Repositories { get; set; }
}
}
namespace Orc.NuGetExplorer.Packaging
{
public class EmptyPackageDetails : Orc.NuGetExplorer.IPackageDetails
Expand Down Expand Up @@ -1273,7 +1266,11 @@ namespace Orc.NuGetExplorer.Services
public interface IPackageInstallationService
{
NuGet.Packaging.VersionFolderPathResolver InstallerPathResolver { get; }
System.Threading.Tasks.Task<Orc.NuGetExplorer.InstallerResult> InstallAsync(Orc.NuGetExplorer.Models.InstallationContext context, System.Threading.CancellationToken cancellationToken = default);
System.Threading.Tasks.Task<Orc.NuGetExplorer.InstallerResult> InstallAsync(Orc.NuGetExplorer.InstallationContext context, System.Threading.CancellationToken cancellationToken = default);
[System.Obsolete(("Use `InstallAsync(InstallationContext context, CancellationToken cancellationToke" +
"n = default)` instead. Will be treated as an error from version 6.0.0. Will be r" +
"emoved in version 7.0.0."), false)]
System.Threading.Tasks.Task<Orc.NuGetExplorer.InstallerResult> InstallAsync(NuGet.Packaging.Core.PackageIdentity package, Orc.NuGetExplorer.IExtensibleProject project, System.Collections.Generic.IReadOnlyList<NuGet.Protocol.Core.Types.SourceRepository> repositories, bool ignoreMissingPackages = false, System.Func<NuGet.Packaging.Core.PackageIdentity, bool>? packagePredicate = null, System.Threading.CancellationToken cancellationToken = default);
System.Threading.Tasks.Task<long?> MeasurePackageSizeFromRepositoryAsync(NuGet.Packaging.Core.PackageIdentity packageIdentity, NuGet.Protocol.Core.Types.SourceRepository sourceRepository);
System.Threading.Tasks.Task UninstallAsync(NuGet.Packaging.Core.PackageIdentity package, Orc.NuGetExplorer.IExtensibleProject project, System.Collections.Generic.IEnumerable<NuGet.Packaging.PackageReference> installedPackageReferences, System.Func<NuGet.Packaging.Core.PackageIdentity, bool>? packagePredicate = null, System.Threading.CancellationToken cancellationToken = default);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Catel;
using Catel.Logging;
using Catel.Services;
using Models;
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.Packaging.Core;
Expand Down
2 changes: 1 addition & 1 deletion src/Orc.NuGetExplorer/Models/InstallationContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Orc.NuGetExplorer.Models;
namespace Orc.NuGetExplorer;

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using NuGet.Packaging;
using NuGet.Packaging.Core;
using NuGet.Protocol.Core.Types;
using Orc.NuGetExplorer.Models;

public interface IPackageInstallationService
{
Expand All @@ -18,6 +17,15 @@ public interface IPackageInstallationService

Task<InstallerResult> InstallAsync(InstallationContext context, CancellationToken cancellationToken = default);

[ObsoleteEx(ReplacementTypeOrMember = "InstallAsync(InstallationContext context, CancellationToken cancellationToken = default)", TreatAsErrorFromVersion = "6", RemoveInVersion = "7")]
public Task<InstallerResult> InstallAsync(
PackageIdentity package,
IExtensibleProject project,
IReadOnlyList<SourceRepository> repositories,
bool ignoreMissingPackages = false,
Func<PackageIdentity, bool>? packagePredicate = null,
CancellationToken cancellationToken = default);

Task UninstallAsync(PackageIdentity package,
IExtensibleProject project,
IEnumerable<PackageReference> installedPackageReferences,
Expand Down
20 changes: 18 additions & 2 deletions src/Orc.NuGetExplorer/Services/PackageInstallationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Catel.IoC;
using Catel.Logging;
using MethodTimer;
using Models;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Frameworks;
Expand Down Expand Up @@ -92,6 +91,23 @@ public PackageInstallationService(IServiceLocator serviceLocator,

public VersionFolderPathResolver InstallerPathResolver => _installerPathResolver;

[ObsoleteEx(ReplacementTypeOrMember = "InstallAsync(InstallationContext context, CancellationToken cancellationToken = default)", TreatAsErrorFromVersion = "6", RemoveInVersion = "7")]
public Task<InstallerResult> InstallAsync(PackageIdentity package, IExtensibleProject project, IReadOnlyList<SourceRepository> repositories, bool ignoreMissingPackages = false, Func<PackageIdentity, bool>? packagePredicate = null, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(package);
ArgumentNullException.ThrowIfNull(project);
ArgumentNullException.ThrowIfNull(repositories);
var context = new InstallationContext
{
Package = package,
Project = project,
Repositories = repositories,
IgnoreMissingPackages = ignoreMissingPackages,
PackagePredicate = packagePredicate,
};
return InstallAsync(context, cancellationToken);
}

public async Task UninstallAsync(PackageIdentity package, IExtensibleProject project, IEnumerable<PackageReference> installedPackageReferences,
Func<PackageIdentity, bool>? packagePredicate = null, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -282,7 +298,7 @@ public async Task<InstallerResult> InstallAsync(InstallationContext context, Can
{
// Track packages which already installed and make sure only one version of package exists
var resolver = new Resolver.PackageResolver();
availablePackagesToInstall = await resolver.ResolveWithVersionOverrideAsync(resolverContext, project, DependencyBehavior.Ignore,
availablePackagesToInstall = await resolver.ResolveWithVersionOverrideAsync(resolverContext, project, DependencyBehavior.Highest,
(project, conflict) => _fileSystemService.CreateDeleteme(conflict.PackageIdentity.Id, project.GetInstallPath(conflict.PackageIdentity)),
cancellationToken);
}
Expand Down

0 comments on commit cc1fb27

Please sign in to comment.