Skip to content

C#: Re-factor feed handling logic into its own component.#22011

Draft
michaelnebel wants to merge 6 commits into
github:mainfrom
michaelnebel:csharp/removeafallback
Draft

C#: Re-factor feed handling logic into its own component.#22011
michaelnebel wants to merge 6 commits into
github:mainfrom
michaelnebel:csharp/removeafallback

Conversation

@michaelnebel

@michaelnebel michaelnebel commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This is a semantics preserving re-factor, where the logic related feed checking/discovery is moved into its own component, which will enable re-use in subsequent PR(s).

@github-actions github-actions Bot added the C# label Jun 19, 2026
@michaelnebel michaelnebel force-pushed the csharp/removeafallback branch from b12d21a to 62bfb70 Compare June 19, 2026 12:49
Comment thread csharp/extractor/Semmle.Util/FileUtils.cs Fixed
Comment on lines +197 to +210
catch (Exception exc)
{
if (exc is TaskCanceledException tce &&
tce.CancellationToken == cts.Token &&
cts.Token.IsCancellationRequested)
{
logger.LogInfo($"Didn't receive answer from NuGet feed '{feed}' in {timeoutMilliSeconds}ms.");
timeoutMilliSeconds *= 2;
continue;
}

logger.LogInfo($"Querying NuGet feed '{feed}' failed. The reason for the failure: {exc.Message}");
return false;
}
@michaelnebel michaelnebel changed the title C#: NoOpPackageRestore only needs the PackageConfigs collection and n… C#: Re-factor feed handling logic into its own component. Jun 22, 2026
@michaelnebel michaelnebel force-pushed the csharp/removeafallback branch from 2ccca0d to 5f31632 Compare June 22, 2026 10:46
Comment on lines +49 to +52
catch (Exception exc)
{
logger.LogWarning($"Failed to get directory of '{path}': {exc}");
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors NuGet feed handling in the C# dependency fetching extractor by moving feed discovery/reachability/restore-source construction into a dedicated FeedManager component, reducing responsibility and complexity in NugetPackageRestorer.

Changes:

  • Introduces FeedManager to encapsulate NuGet feed enumeration, reachability checks (incl. Dependabot proxy support), and restore source argument construction.
  • Updates NugetPackageRestorer to delegate feed-related logic to FeedManager and to dispose it appropriately.
  • Simplifies PackagesConfigRestorer’s no-op implementation by passing only the packages.config collection it needs, and reuses the moved public NuGet feed constant.
Show a summary per file
File Description
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/PackagesConfigRestorer.cs Adjusts the no-op packages.config restorer to depend only on the packages.config list; switches default feed constant reference.
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs Delegates feed logic to FeedManager, removes inlined feed-handling code, and disposes the new component.
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs New component containing NuGet feed discovery, reachability checks, fallback feed handling, and restore source argument creation.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs Outdated
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants