Skip to content

Commit 75dc980

Browse files
committed
C#: Address Copilots review comments.
1 parent 5e5a428 commit 75dc980

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private IEnumerable<string> RestoreSolutions(string? nugetSources, out Dependenc
352352
var feedArgs = new StringBuilder();
353353
foreach (var feed in feeds)
354354
{
355-
feedArgs.Append($" -s {feed}");
355+
feedArgs.Append($" -s \"{feed}\"");
356356
}
357357

358358
return feedArgs.ToString();
@@ -692,7 +692,7 @@ private void TryChangeProjectFile(DirectoryInfo projectDir, Regex pattern, strin
692692

693693
private static async Task<HttpResponseMessage> ExecuteGetRequest(string address, HttpClient httpClient, CancellationToken cancellationToken)
694694
{
695-
return await httpClient.GetAsync(address, cancellationToken);
695+
return await httpClient.GetAsync(address, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
696696
}
697697

698698
private bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount, out bool isTimeout)
@@ -737,7 +737,7 @@ private bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount,
737737
try
738738
{
739739
logger.LogInfo($"Attempt {i + 1}/{tryCount} to reach NuGet feed '{feed}'.");
740-
var response = ExecuteGetRequest(feed, client, cts.Token).GetAwaiter().GetResult();
740+
using var response = ExecuteGetRequest(feed, client, cts.Token).GetAwaiter().GetResult();
741741
response.EnsureSuccessStatusCode();
742742
logger.LogInfo($"Querying NuGet feed '{feed}' succeeded.");
743743
return true;
@@ -824,9 +824,12 @@ private bool CheckSpecifiedFeeds(HashSet<string> feeds, out HashSet<string> reac
824824
}).ToHashSet();
825825

826826
reachableFeeds = GetReachableNuGetFeeds(feedsToCheck, isFallback: false, out var isTimeout).ToHashSet();
827-
828827
var allReachable = reachableFeeds.Count == feedsToCheck.Count;
829828
EmitUnreachableFeedsDiagnostics(allReachable);
829+
830+
// Always consider feeds excluded for the reachability check as reachable.
831+
reachableFeeds.UnionWith(feeds.Where(feed => excludedFeeds.Contains(feed)));
832+
830833
return !isTimeout;
831834
}
832835

0 commit comments

Comments
 (0)