C#: Make sure allFeeds contains at least explicitFeeds#21236
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug in the computation of allFeeds in the NuGet package restoration logic. The PR ensures that allFeeds always includes explicitFeeds, which is normally the case except when configuration files with non-standard casing (like Nuget.Config instead of nuget.config) are encountered on case-sensitive file systems.
Changes:
- Added logic to explicitly union
explicitFeedsintoallFeedsto handle the edge case where case-sensitive filesystems causedotnet nuget list sourceto miss configuration files that are otherwise valid - Added comprehensive comments explaining the rationale and the specific edge case being addressed
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
michaelnebel
left a comment
There was a problem hiding this comment.
That is some excellent 🕵️ work!!!
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
Outdated
Show resolved
Hide resolved
Contributor
|
We should also run DCA. |
8857553 to
1aba0b2
Compare
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs
Outdated
Show resolved
Hide resolved
michaelnebel
approved these changes
Jan 30, 2026
Contributor
michaelnebel
left a comment
There was a problem hiding this comment.
Fantastic!
Thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This (sort of) fixes a (sort of) bug in the computation of
allFeeds. We assume thatallFeedsincludesexplicitFeedsand that is generally true, except for one case. On systems with case-sensitive file systems, we may discover a configuration file such asNuget.Config, which is not recognised bydotnet nuget list source(which e.g. only recognisesNuGet.configandnuget.config). In that case, our call toGetNugetFeedswill retrieve the feeds from that file (because it is accepted when provided explicitly as--configfileargument), but the call toGetNugetFeedsFromFolderwill not.Arguably, another option here would be to make our configuration file discovery more strict and only recognise the same case-sensitive filenames as
dotnet nuget list source. However, that may catch out customers by surprise who normally work on case-insensitive systems, but who use Default Setup.Note that this doesn't address scenarios where
GetNugetFeedsFromFoldermisses feeds from parent directories because they have names thatdotnet nuget list sourcedoesn't recognise.