Skip to content

Commit 198bee1

Browse files
committed
cleanup
1 parent 93eaf3a commit 198bee1

13 files changed

Lines changed: 41 additions & 18 deletions

File tree

src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/PackageReferenceProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ internal static Dictionary<string, TransitiveEntry> ComputeTransitivePackageOrig
383383
// For each target framework graph (Framework, RID)-pair:
384384
foreach (LockFileTarget targetFxGraph in targetsList)
385385
{
386-
var key = new FrameworkRuntimePair(targetFxGraph.TargetAlias, targetFxGraph.TargetFramework, targetFxGraph.RuntimeIdentifier);
386+
var key = new FrameworkRuntimePair(targetFxGraph.TargetFramework, targetFxGraph.RuntimeIdentifier);
387387

388388
foreach (var directPkg in installedPackages) // 3.1 For each direct dependency
389389
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable enable
22
~NuGet.Commands.IRestoreTargetGraph.TargetAlias.get -> string
3+
~NuGet.Commands.IRestoreTargetGraph.TargetGraphNameWithAlias.get -> string
34
~NuGet.Commands.RestoreTargetGraph.TargetAlias.get -> string
45
~NuGet.Commands.RestoreTargetGraph.TargetGraphNameWithAlias.get -> string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable enable
22
~NuGet.Commands.IRestoreTargetGraph.TargetAlias.get -> string
3+
~NuGet.Commands.IRestoreTargetGraph.TargetGraphNameWithAlias.get -> string
34
~NuGet.Commands.RestoreTargetGraph.TargetAlias.get -> string
45
~NuGet.Commands.RestoreTargetGraph.TargetGraphNameWithAlias.get -> string

src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreTargetGraph.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Diagnostics;
7+
using System.Globalization;
68
using System.Linq;
79
using NuGet.Client;
810
using NuGet.Common;
@@ -81,7 +83,7 @@ internal RestoreTargetGraph(IEnumerable<ResolverConflict> conflicts,
8183
Framework = framework;
8284
Graphs = graphs;
8385
TargetGraphName = FrameworkRuntimePair.GetTargetGraphName(Framework, RuntimeIdentifier);
84-
TargetGraphNameWithAlias = FrameworkRuntimePair.GetTargetGraphName(TargetAlias, RuntimeIdentifier);
86+
TargetGraphNameWithAlias = GetTargetGraphName(TargetAlias, RuntimeIdentifier);
8587
Conventions = new ManagedCodeConventions(runtimeGraph);
8688

8789
Install = install;
@@ -91,6 +93,24 @@ internal RestoreTargetGraph(IEnumerable<ResolverConflict> conflicts,
9193
ResolvedDependencies = resolvedDependencies;
9294
}
9395

96+
internal static string GetTargetGraphName(string targetAlias, string runtimeIdentifier)
97+
{
98+
if (targetAlias is null) throw new ArgumentNullException(nameof(targetAlias));
99+
100+
if (string.IsNullOrEmpty(runtimeIdentifier))
101+
{
102+
return targetAlias;
103+
}
104+
else
105+
{
106+
return string.Format(
107+
CultureInfo.InvariantCulture,
108+
"{0}/{1}",
109+
targetAlias,
110+
runtimeIdentifier);
111+
}
112+
}
113+
94114
internal static RestoreTargetGraph Create(IEnumerable<GraphNode<RemoteResolveResult>> graphs, RemoteWalkContext context, ILogger logger, string targetAlias, NuGetFramework framework)
95115
{
96116
return Create(RuntimeGraph.Empty, graphs, context, logger, targetAlias, framework, runtimeIdentifier: null);

src/NuGet.Core/NuGet.Frameworks/PublicAPI.Shipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ NuGet.Frameworks.FrameworkRuntimePair
120120
NuGet.Frameworks.FrameworkRuntimePair.CompareTo(NuGet.Frameworks.FrameworkRuntimePair? other) -> int
121121
NuGet.Frameworks.FrameworkRuntimePair.Equals(NuGet.Frameworks.FrameworkRuntimePair? other) -> bool
122122
NuGet.Frameworks.FrameworkRuntimePair.Framework.get -> NuGet.Frameworks.NuGetFramework!
123+
NuGet.Frameworks.FrameworkRuntimePair.FrameworkRuntimePair(NuGet.Frameworks.NuGetFramework! framework, string? runtimeIdentifier) -> void
123124
NuGet.Frameworks.FrameworkRuntimePair.Name.get -> string!
124125
NuGet.Frameworks.FrameworkRuntimePair.RuntimeIdentifier.get -> string!
125126
NuGet.Frameworks.FrameworkSpecificMapping

src/NuGet.Core/NuGet.Packaging/RuntimeModel/JsonRuntimeFormat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,11 @@ private static IEnumerable<FrameworkRuntimePair> ReadCompatibilitySets(KeyValueP
185185
case JTokenType.Array:
186186
foreach (var value in (JArray)property.Value)
187187
{
188-
yield return new FrameworkRuntimePair(framework.GetShortFolderName(), framework, value.Value<string>());
188+
yield return new FrameworkRuntimePair(framework, value.Value<string>());
189189
}
190190
break;
191191
case JTokenType.String:
192-
yield return new FrameworkRuntimePair(framework.GetShortFolderName(), framework, property.Value.ToString());
192+
yield return new FrameworkRuntimePair(framework, property.Value.ToString());
193193
break;
194194
// Other token types are not supported
195195
}

src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.Utf8JsonStreamReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ private static IEnumerable<FrameworkRuntimePair> ReadCompatibilitySets(IReadOnly
575575

576576
foreach (string value in values)
577577
{
578-
yield return new FrameworkRuntimePair(string.Empty, framework, value);
578+
yield return new FrameworkRuntimePair(framework, value);
579579
}
580580
}
581581

test/NuGet.Clients.Tests/NuGet.PackageManagement.VisualStudio.Test/Projects/PackageReferenceProjectTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void MergeTransitiveOrigin_DuplicateTransitiveOrigins_Merges()
2323
var te = new Dictionary<FrameworkRuntimePair, IList<PackageReference>>
2424
{
2525
{
26-
new FrameworkRuntimePair("net472", net472, string.Empty),
26+
new FrameworkRuntimePair(net472, string.Empty),
2727
new List<PackageReference>()
2828
{
2929
new PackageReference(new PackageIdentity("package1", new NuGetVersion("0.0.1")), net472),
@@ -47,15 +47,15 @@ public void MergeTransitiveOrigin_MultiTargeting_MergesLatest()
4747
var te = new Dictionary<FrameworkRuntimePair, IList<PackageReference>>
4848
{
4949
{
50-
new FrameworkRuntimePair("net472", net472, string.Empty),
50+
new FrameworkRuntimePair(net472, string.Empty),
5151
new List<PackageReference>()
5252
{
5353
new PackageReference(new PackageIdentity("package1", new NuGetVersion("0.0.1")), net472),
5454
new PackageReference(new PackageIdentity("package1", new NuGetVersion("0.0.2")), net472),
5555
}
5656
},
5757
{
58-
new FrameworkRuntimePair("net6.0", net60, string.Empty),
58+
new FrameworkRuntimePair(net60, string.Empty),
5959
new List<PackageReference>()
6060
{
6161
new PackageReference(new PackageIdentity("package1", new NuGetVersion("0.0.3")), net60),

test/NuGet.Core.Tests/NuGet.Packaging.Test/RuntimeModelTests/JsonRuntimeFormatTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public void CanParseSupportsSection()
3434
{
3535
new CompatibilityProfile("windows-frob", new []
3636
{
37-
new FrameworkRuntimePair("netcore5.0", FrameworkConstants.CommonFrameworks.NetCore50, "winfrob-x86"),
38-
new FrameworkRuntimePair("netcore5.0", FrameworkConstants.CommonFrameworks.NetCore50, "winfrob-x64")
37+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.NetCore50, "winfrob-x86"),
38+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.NetCore50, "winfrob-x64")
3939
})
4040
}),
4141
ParseRuntimeJsonString(content));
@@ -73,7 +73,7 @@ public void CanParseCompatProfilesWithoutRuntimeIDs()
7373
new RuntimeGraph(new[]
7474
{
7575
new CompatibilityProfile("windows-phone-8", new [] {
76-
new FrameworkRuntimePair("wp-8", FrameworkConstants.CommonFrameworks.WP8, null)
76+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.WP8, null)
7777
})
7878
}),
7979
ParseRuntimeJsonString(content));

test/NuGet.Core.Tests/NuGet.Packaging.Test/RuntimeModelTests/RuntimeGraphTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,14 @@ public void MergeReplacesCompatibilityProfilesDefinedInRightWithValuesFromLeftIf
512512
{
513513
new CompatibilityProfile("frob", new []
514514
{
515-
new FrameworkRuntimePair("dnx452", FrameworkConstants.CommonFrameworks.Dnx452, "frob")
515+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.Dnx452, "frob")
516516
})
517517
});
518518
var rightGraph = new RuntimeGraph(new[]
519519
{
520520
new CompatibilityProfile("frob", new []
521521
{
522-
new FrameworkRuntimePair("dnxcore50", FrameworkConstants.CommonFrameworks.DnxCore50, "blob")
522+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.DnxCore50, "blob")
523523
})
524524
});
525525
var graph = RuntimeGraph.Merge(leftGraph, rightGraph);
@@ -537,7 +537,7 @@ public void MergeReplacesCompatibilityProfilesDefinedInRightIntoLeftIfLeftIsEmpt
537537
{
538538
new CompatibilityProfile("frob", new []
539539
{
540-
new FrameworkRuntimePair("dnxcore50", FrameworkConstants.CommonFrameworks.DnxCore50, "blob")
540+
new FrameworkRuntimePair(FrameworkConstants.CommonFrameworks.DnxCore50, "blob")
541541
})
542542
});
543543
var graph = RuntimeGraph.Merge(leftGraph, rightGraph);

0 commit comments

Comments
 (0)