Skip to content

Commit 422090d

Browse files
committed
Clean up
1 parent df168ad commit 422090d

25 files changed

+155
-113
lines changed

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/NuGetPackageWithNuGetVersion.cs renamed to src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/PackageWithNuGetVersion.cs

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@
33

44
#nullable enable
55

6-
using System;
76
using System.Collections.Generic;
87
using System.CommandLine.Parsing;
9-
using System.Diagnostics.CodeAnalysis;
108
using NuGet.Versioning;
119

1210
namespace NuGet.CommandLine.XPlat.Commands.Package
1311
{
14-
internal record NuGetPackageWithNuGetVersion : IEqualityComparer<NuGetPackageWithNuGetVersion>
12+
internal record PackageWithNuGetVersion
1513
{
1614
public required string Id { get; init; }
1715

1816
public NuGetVersion? NuGetVersion { get; init; }
1917

20-
internal static IReadOnlyList<NuGetPackageWithNuGetVersion> Parse(ArgumentResult result)
18+
internal static IReadOnlyList<PackageWithNuGetVersion> Parse(ArgumentResult result)
2119
{
2220
if (result.Tokens.Count == 0)
2321
{
2422
return [];
2523
}
2624

27-
var packages = new List<NuGetPackageWithNuGetVersion>(result.Tokens.Count);
25+
var packages = new List<PackageWithNuGetVersion>(result.Tokens.Count);
2826

2927
foreach (var token in result.Tokens)
3028
{
@@ -55,7 +53,7 @@ internal static IReadOnlyList<NuGetPackageWithNuGetVersion> Parse(ArgumentResult
5553
}
5654
}
5755

58-
var package = new NuGetPackageWithNuGetVersion
56+
var package = new PackageWithNuGetVersion
5957
{
6058
Id = packageId,
6159
NuGetVersion = newExactVersion
@@ -66,33 +64,5 @@ internal static IReadOnlyList<NuGetPackageWithNuGetVersion> Parse(ArgumentResult
6664

6765
return packages;
6866
}
69-
70-
public bool Equals(NuGetPackageWithNuGetVersion? x, NuGetPackageWithNuGetVersion? y)
71-
{
72-
if (ReferenceEquals(x, y))
73-
{
74-
return true;
75-
}
76-
77-
if (x is null || y is null)
78-
{
79-
return false;
80-
}
81-
82-
if (!x.Id.Equals(y.Id, StringComparison.OrdinalIgnoreCase))
83-
{
84-
return false;
85-
}
86-
87-
return VersionComparer.Compare(x.NuGetVersion, y.NuGetVersion, VersionComparison.Default) == 0;
88-
}
89-
90-
public int GetHashCode([DisallowNull] NuGetPackageWithNuGetVersion obj)
91-
{
92-
HashCode hash = new HashCode();
93-
hash.Add(obj.Id, StringComparer.OrdinalIgnoreCase);
94-
hash.Add(obj.NuGetVersion);
95-
return hash.ToHashCode();
96-
}
9767
}
9868
}

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/NuGetPackageWithVersionRange.cs renamed to src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/PackageWithVersionRange.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212
namespace NuGet.CommandLine.XPlat.Commands.Package
1313
{
14-
internal record NuGetPackageWithVersionRange : IEqualityComparer<NuGetPackageWithVersionRange>
14+
internal record PackageWithVersionRange : IEqualityComparer<PackageWithVersionRange>
1515
{
1616
public required string Id { get; init; }
1717
public required VersionRange? VersionRange { get; init; }
1818

19-
internal static IReadOnlyList<NuGetPackageWithVersionRange> Parse(ArgumentResult result)
19+
internal static IReadOnlyList<PackageWithVersionRange> Parse(ArgumentResult result)
2020
{
2121
if (result.Tokens.Count == 0)
2222
{
2323
return [];
2424
}
2525

26-
List<NuGetPackageWithVersionRange> packages = new List<NuGetPackageWithVersionRange>(result.Tokens.Count);
26+
List<PackageWithVersionRange> packages = new List<PackageWithVersionRange>(result.Tokens.Count);
2727

2828
foreach (var token in result.Tokens)
2929
{
@@ -51,7 +51,7 @@ internal static IReadOnlyList<NuGetPackageWithVersionRange> Parse(ArgumentResult
5151
}
5252
}
5353

54-
var package = new NuGetPackageWithVersionRange
54+
var package = new PackageWithVersionRange
5555
{
5656
Id = packageId,
5757
VersionRange = newVersion
@@ -62,7 +62,7 @@ internal static IReadOnlyList<NuGetPackageWithVersionRange> Parse(ArgumentResult
6262
return packages;
6363
}
6464

65-
public bool Equals(NuGetPackageWithVersionRange? x, NuGetPackageWithVersionRange? y)
65+
public bool Equals(PackageWithVersionRange? x, PackageWithVersionRange? y)
6666
{
6767
if (ReferenceEquals(x, y))
6868
{
@@ -82,7 +82,7 @@ public bool Equals(NuGetPackageWithVersionRange? x, NuGetPackageWithVersionRange
8282
return VersionRangeComparer.Default.Equals(x.VersionRange, y.VersionRange);
8383
}
8484

85-
public int GetHashCode([DisallowNull] NuGetPackageWithVersionRange obj)
85+
public int GetHashCode([DisallowNull] PackageWithVersionRange obj)
8686
{
8787
HashCode hash = new HashCode();
8888
hash.Add(obj.Id, StringComparer.OrdinalIgnoreCase);

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal record PackageUpdateArgs
1212
{
1313
public required string Project { get; init; }
1414

15-
public required IReadOnlyList<NuGetPackageWithVersionRange> Packages { get; init; }
15+
public required IReadOnlyList<PackageWithVersionRange> Packages { get; init; }
1616

1717
public required bool Interactive { get; init; }
1818

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ internal static void Register(Command packageCommand, Option<bool> interactiveOp
2424
{
2525
var command = new DocumentedCommand("update", Strings.PackageUpdateCommand_Description, "https://aka.ms/dotnet/package/update");
2626

27-
var packagesArguments = new Argument<IReadOnlyList<NuGetPackageWithVersionRange>>("packages")
27+
var packagesArguments = new Argument<IReadOnlyList<PackageWithVersionRange>>("packages")
2828
{
2929
Description = Strings.PackageUpdate_PackageArgumentDescription,
3030
Arity = ArgumentArity.ZeroOrMore,
31-
CustomParser = NuGetPackageWithVersionRange.Parse
31+
CustomParser = PackageWithVersionRange.Parse
3232
};
3333
command.Arguments.Add(packagesArguments);
3434

@@ -49,7 +49,7 @@ internal static void Register(Command packageCommand, Option<bool> interactiveOp
4949
command.SetAction(async (args, cancellationToken) =>
5050
{
5151
FileSystemInfo? project = args.GetValue(projectOption);
52-
IReadOnlyList<NuGetPackageWithVersionRange> packages = args.GetValue(packagesArguments) ?? [];
52+
IReadOnlyList<PackageWithVersionRange> packages = args.GetValue(packagesArguments) ?? [];
5353
bool interactive = args.GetValue(interactiveOption);
5454
VerbosityEnum verbosity = args.GetValue(verbosityOption) ?? VerbosityEnum.normal;
5555
LogLevel logLevel = verbosity.ToLogLevel();

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
182182
}
183183

184184
private static async Task<(List<PackageUpdateResult> vulnerablePackages, int packagesScanned)> SelectVulnerablePackagesToUpdateAsync(
185-
IReadOnlyList<NuGetPackageWithVersionRange>? packages,
185+
IReadOnlyList<PackageWithVersionRange>? packages,
186186
DependencyGraphSpec dgSpec,
187187
ILoggerWithColor logger,
188188
IPackageUpdateIO packageUpdateIO,
@@ -283,7 +283,7 @@ bool PackageHasVulnerability(string packageId, NuGetVersion version, IReadOnlyLi
283283
}
284284

285285
internal static async Task<List<PackageUpdateResult>> SelectPackagesToUpdateAsync(
286-
IReadOnlyList<NuGetPackageWithVersionRange> packages,
286+
IReadOnlyList<PackageWithVersionRange> packages,
287287
PackageSpec project,
288288
ILoggerWithColor logger,
289289
IPackageUpdateIO packageUpdateIO,
@@ -499,7 +499,7 @@ private static (VersionRange? version, List<string> targetFrameworks)
499499
return successful ? (packagesToUpdate, allProjectPackages.Count) : (null, allProjectPackages.Count);
500500
}
501501

502-
private static List<(NuGetPackageWithVersionRange identity, List<string> tfms)>? GetAllPackagesReferencedByProject(PackageSpec project, ILoggerWithColor logger)
502+
private static List<(PackageWithVersionRange identity, List<string> tfms)>? GetAllPackagesReferencedByProject(PackageSpec project, ILoggerWithColor logger)
503503
{
504504
var allPackages = new Dictionary<string, (VersionRange version, List<string> tfms, bool hasError)>(StringComparer.OrdinalIgnoreCase);
505505
bool hasErrors = false;
@@ -543,10 +543,10 @@ private static (VersionRange? version, List<string> targetFrameworks)
543543
return null;
544544
}
545545

546-
List<(NuGetPackageWithVersionRange package, List<string> tfms)> result = new(allPackages.Count);
546+
List<(PackageWithVersionRange package, List<string> tfms)> result = new(allPackages.Count);
547547
foreach (var kvp in allPackages)
548548
{
549-
var package = new NuGetPackageWithVersionRange { Id = kvp.Key, VersionRange = kvp.Value.version };
549+
var package = new PackageWithVersionRange { Id = kvp.Key, VersionRange = kvp.Value.version };
550550
result.Add((package, kvp.Value.tfms));
551551
}
552552

src/NuGet.Core/NuGet.CommandLine.XPlat/Strings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NuGet.Core/NuGet.CommandLine.XPlat/Strings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ Do not translate "PackageVersion"</comment>
11051105
<value>Argument cannot be null or empty.</value>
11061106
</data>
11071107
<data name="Error_InvalidVersion" xml:space="preserve">
1108-
<value>Invalid version value '{0}'. An exact NuGet version is required for this operation.</value>
1108+
<value>Invalid version value '{0}'.</value>
11091109
<comment>0 - package version</comment>
11101110
</data>
11111111
</root>

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.cs.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ NuGet vyžaduje zdroje HTTPS. Pokud chcete používat zdroje HTTP, musíte v sou
354354
<note>0 - The invalid source.</note>
355355
</trans-unit>
356356
<trans-unit id="Error_InvalidVersion">
357-
<source>Invalid version value '{0}'. An exact NuGet version is required for this operation.</source>
358-
<target state="new">Invalid version value '{0}'. An exact NuGet version is required for this operation.</target>
357+
<source>Invalid version value '{0}'.</source>
358+
<target state="new">Invalid version value '{0}'.</target>
359359
<note>0 - package version</note>
360360
</trans-unit>
361361
<trans-unit id="Error_InvalidVersionRange">

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.de.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ NuGet erfordert HTTPS-Quellen. Um HTTP-Quellen zu verwenden, müssen Sie „allo
354354
<note>0 - The invalid source.</note>
355355
</trans-unit>
356356
<trans-unit id="Error_InvalidVersion">
357-
<source>Invalid version value '{0}'. An exact NuGet version is required for this operation.</source>
358-
<target state="new">Invalid version value '{0}'. An exact NuGet version is required for this operation.</target>
357+
<source>Invalid version value '{0}'.</source>
358+
<target state="new">Invalid version value '{0}'.</target>
359359
<note>0 - package version</note>
360360
</trans-unit>
361361
<trans-unit id="Error_InvalidVersionRange">

src/NuGet.Core/NuGet.CommandLine.XPlat/xlf/Strings.es.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ NuGet requiere orígenes HTTPS. Para usar orígenes HTTP, es necesario establece
354354
<note>0 - The invalid source.</note>
355355
</trans-unit>
356356
<trans-unit id="Error_InvalidVersion">
357-
<source>Invalid version value '{0}'. An exact NuGet version is required for this operation.</source>
358-
<target state="new">Invalid version value '{0}'. An exact NuGet version is required for this operation.</target>
357+
<source>Invalid version value '{0}'.</source>
358+
<target state="new">Invalid version value '{0}'.</target>
359359
<note>0 - package version</note>
360360
</trans-unit>
361361
<trans-unit id="Error_InvalidVersionRange">

0 commit comments

Comments
 (0)