Skip to content

Commit 4690d92

Browse files
committed
C#: Remove the explicitfeeds argument from DownloadMissingPackagesFromSpecificFeeds as it is always called with this argument.
1 parent 508c780 commit 4690d92

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ private List<string> GetReachableNuGetFeeds(HashSet<string> feedsToCheck, bool i
445445
return reachableFeeds;
446446
}
447447

448-
public List<string> GetReachableFallbackNugetFeeds(ImmutableHashSet<string>? feedsFromNugetConfigs)
448+
public List<string> GetReachableFallbackNugetFeeds()
449449
{
450450
var fallbackFeeds = EnvironmentVariables.GetURLs(EnvironmentVariableNames.FallbackNugetFeeds).ToHashSet();
451451
if (fallbackFeeds.Count == 0)
@@ -456,12 +456,12 @@ public List<string> GetReachableFallbackNugetFeeds(ImmutableHashSet<string>? fee
456456
var shouldAddNugetConfigFeeds = EnvironmentVariables.GetBooleanOptOut(EnvironmentVariableNames.AddNugetConfigFeedsToFallback);
457457
logger.LogInfo($"Adding feeds from nuget.config to fallback restore: {shouldAddNugetConfigFeeds}");
458458

459-
if (shouldAddNugetConfigFeeds && feedsFromNugetConfigs?.Count > 0)
459+
if (shouldAddNugetConfigFeeds && ExplicitFeeds.Count > 0)
460460
{
461-
// There are some feeds in `feedsFromNugetConfigs` that have already been checked for reachability, we could skip those.
462-
// But we might use different responsiveness testing settings when we try them in the fallback logic, so checking them again is safer.
463-
fallbackFeeds.UnionWith(feedsFromNugetConfigs);
464-
logger.LogInfo($"Using NuGet feeds from nuget.config files as fallback feeds: {string.Join(", ", feedsFromNugetConfigs.OrderBy(f => f))}");
461+
// Feeds in `ExplicitFeeds` may already been checked for reachability.
462+
// But we might use different responsiveness testing settings when we try them in the fallback logic, so checking them again.
463+
fallbackFeeds.UnionWith(ExplicitFeeds);
464+
logger.LogInfo($"Using NuGet feeds from nuget.config files as fallback feeds: {string.Join(", ", ExplicitFeeds.OrderBy(f => f))}");
465465
}
466466
}
467467

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public HashSet<AssemblyLookupLocation> Restore()
133133
{
134134
// If we experience a timeout, we use this fallback.
135135
// todo: we could also check the reachability of the inherited nuget feeds, but to use those in the fallback we would need to handle authentication too.
136-
var unresponsiveMissingPackageLocation = DownloadMissingPackagesFromSpecificFeeds([], explicitFeeds);
136+
var unresponsiveMissingPackageLocation = DownloadMissingPackagesAndUseFallback([]);
137137
return unresponsiveMissingPackageLocation is null
138138
? []
139139
: [unresponsiveMissingPackageLocation];
@@ -196,7 +196,7 @@ public HashSet<AssemblyLookupLocation> Restore()
196196
var usedPackageNames = GetAllUsedPackageDirNames(dependencies);
197197

198198
var missingPackageLocation = feedManager.CheckNugetFeedResponsiveness
199-
? DownloadMissingPackagesFromSpecificFeeds(usedPackageNames, explicitFeeds)
199+
? DownloadMissingPackagesAndUseFallback(usedPackageNames)
200200
: DownloadMissingPackages(usedPackageNames);
201201

202202
if (missingPackageLocation is not null)
@@ -303,9 +303,9 @@ private void RestoreProjects(IEnumerable<string> projects, out ConcurrentBag<Dep
303303
compilationInfoContainer.CompilationInfos.Add(("Failed project restore with missing package error", nugetMissingPackageFailures.ToString()));
304304
}
305305

306-
private AssemblyLookupLocation? DownloadMissingPackagesFromSpecificFeeds(IEnumerable<string> usedPackageNames, ImmutableHashSet<string>? feedsFromNugetConfigs)
306+
private AssemblyLookupLocation? DownloadMissingPackagesAndUseFallback(IEnumerable<string> usedPackageNames)
307307
{
308-
var reachableFallbackFeeds = feedManager.GetReachableFallbackNugetFeeds(feedsFromNugetConfigs);
308+
var reachableFallbackFeeds = feedManager.GetReachableFallbackNugetFeeds();
309309
compilationInfoContainer.CompilationInfos.Add(("Reachable fallback NuGet feed count", reachableFallbackFeeds.Count.ToString()));
310310

311311
if (reachableFallbackFeeds.Count > 0)

0 commit comments

Comments
 (0)