Skip to content

Commit 1a50cd4

Browse files
authored
Fix process framework references crash when null RID is passed (#50682)
1 parent ffd90ac commit 1a50cd4

File tree

3 files changed

+846
-354
lines changed

3 files changed

+846
-354
lines changed

src/Common/NuGetUtils.NuGet.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
using NuGet.Frameworks;
75
using NuGet.RuntimeModel;
86

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

30-
public static string GetLockFileLanguageName(string projectLanguage)
28+
public static string? GetLockFileLanguageName(string? projectLanguage)
3129
{
3230
switch (projectLanguage)
3331
{
@@ -37,7 +35,7 @@ public static string GetLockFileLanguageName(string projectLanguage)
3735
}
3836
}
3937

40-
public static NuGetFramework ParseFrameworkName(string frameworkName)
38+
public static NuGetFramework? ParseFrameworkName(string? frameworkName)
4139
{
4240
return frameworkName == null ? null : NuGetFramework.Parse(frameworkName);
4341
}
@@ -75,24 +73,24 @@ bool FileMatchesProjectLanguage()
7573
return IsAnalyzer() && FileMatchesProjectLanguage();
7674
}
7775

78-
public static string GetBestMatchingRid(RuntimeGraph runtimeGraph, string runtimeIdentifier,
76+
public static string? GetBestMatchingRid(RuntimeGraph runtimeGraph, string runtimeIdentifier,
7977
IEnumerable<string> availableRuntimeIdentifiers, out bool wasInGraph)
8078
{
8179
return GetBestMatchingRidWithExclusion(runtimeGraph, runtimeIdentifier,
8280
runtimeIdentifiersToExclude: null,
8381
availableRuntimeIdentifiers, out wasInGraph);
8482
}
8583

86-
public static string GetBestMatchingRidWithExclusion(RuntimeGraph runtimeGraph, string runtimeIdentifier,
87-
IEnumerable<string> runtimeIdentifiersToExclude,
84+
public static string? GetBestMatchingRidWithExclusion(RuntimeGraph runtimeGraph, string runtimeIdentifier,
85+
IEnumerable<string>? runtimeIdentifiersToExclude,
8886
IEnumerable<string> availableRuntimeIdentifiers, out bool wasInGraph)
8987
{
9088
wasInGraph = runtimeGraph.Runtimes.ContainsKey(runtimeIdentifier);
9189

92-
string bestMatch = null;
90+
string? bestMatch = null;
9391

9492
HashSet<string> availableRids = new(availableRuntimeIdentifiers, StringComparer.Ordinal);
95-
HashSet<string> excludedRids = runtimeIdentifiersToExclude switch { null => null, _ => new HashSet<string>(runtimeIdentifiersToExclude, StringComparer.Ordinal) };
93+
HashSet<string>? excludedRids = runtimeIdentifiersToExclude switch { null => null, _ => new HashSet<string>(runtimeIdentifiersToExclude, StringComparer.Ordinal) };
9694
foreach (var candidateRuntimeIdentifier in runtimeGraph.ExpandRuntime(runtimeIdentifier))
9795
{
9896
if (bestMatch == null && availableRids.Contains(candidateRuntimeIdentifier))

0 commit comments

Comments
 (0)