Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/Common/NuGetUtils.NuGet.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#nullable disable

using NuGet.Frameworks;
using NuGet.RuntimeModel;

Expand All @@ -27,7 +25,7 @@ public static bool IsPlaceholderFile(string path)
return separator == '\\' || separator == '/';
}

public static string GetLockFileLanguageName(string projectLanguage)
public static string? GetLockFileLanguageName(string? projectLanguage)
{
switch (projectLanguage)
{
Expand All @@ -37,7 +35,7 @@ public static string GetLockFileLanguageName(string projectLanguage)
}
}

public static NuGetFramework ParseFrameworkName(string frameworkName)
public static NuGetFramework? ParseFrameworkName(string? frameworkName)
{
return frameworkName == null ? null : NuGetFramework.Parse(frameworkName);
}
Expand Down Expand Up @@ -75,24 +73,24 @@ bool FileMatchesProjectLanguage()
return IsAnalyzer() && FileMatchesProjectLanguage();
}

public static string GetBestMatchingRid(RuntimeGraph runtimeGraph, string runtimeIdentifier,
public static string? GetBestMatchingRid(RuntimeGraph runtimeGraph, string runtimeIdentifier,
IEnumerable<string> availableRuntimeIdentifiers, out bool wasInGraph)
{
return GetBestMatchingRidWithExclusion(runtimeGraph, runtimeIdentifier,
runtimeIdentifiersToExclude: null,
availableRuntimeIdentifiers, out wasInGraph);
}

public static string GetBestMatchingRidWithExclusion(RuntimeGraph runtimeGraph, string runtimeIdentifier,
IEnumerable<string> runtimeIdentifiersToExclude,
public static string? GetBestMatchingRidWithExclusion(RuntimeGraph runtimeGraph, string runtimeIdentifier,
IEnumerable<string>? runtimeIdentifiersToExclude,
IEnumerable<string> availableRuntimeIdentifiers, out bool wasInGraph)
{
wasInGraph = runtimeGraph.Runtimes.ContainsKey(runtimeIdentifier);

string bestMatch = null;
string? bestMatch = null;

HashSet<string> availableRids = new(availableRuntimeIdentifiers, StringComparer.Ordinal);
HashSet<string> excludedRids = runtimeIdentifiersToExclude switch { null => null, _ => new HashSet<string>(runtimeIdentifiersToExclude, StringComparer.Ordinal) };
HashSet<string>? excludedRids = runtimeIdentifiersToExclude switch { null => null, _ => new HashSet<string>(runtimeIdentifiersToExclude, StringComparer.Ordinal) };
foreach (var candidateRuntimeIdentifier in runtimeGraph.ExpandRuntime(runtimeIdentifier))
{
if (bestMatch == null && availableRids.Contains(candidateRuntimeIdentifier))
Expand Down
Loading