Skip to content

Commit 2ccca0d

Browse files
committed
C#: Move the nuget.config diagnostics out of the GetAllFeeds method.
1 parent 7ebc0fd commit 2ccca0d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ internal sealed partial class NugetPackageRestorer : IDisposable
1919
private readonly FileProvider fileProvider;
2020
private readonly FileContent fileContent;
2121
private readonly IDotNet dotnet;
22-
private readonly DependabotProxy? dependabotProxy;
2322
private readonly IDiagnosticsWriter diagnosticsWriter;
2423
private readonly DependencyDirectory legacyPackageDirectory;
2524
private readonly DependencyDirectory missingPackageDirectory;
@@ -42,7 +41,6 @@ public NugetPackageRestorer(
4241
this.fileProvider = fileProvider;
4342
this.fileContent = fileContent;
4443
this.dotnet = dotnet;
45-
this.dependabotProxy = dependabotProxy;
4644
this.diagnosticsWriter = diagnosticsWriter;
4745
this.logger = logger;
4846
this.compilationInfoContainer = compilationInfoContainer;
@@ -117,6 +115,8 @@ public HashSet<AssemblyLookupLocation> Restore()
117115

118116
try
119117
{
118+
EmitNugetConfigDiagnostics();
119+
120120
// Find feeds that are configured in NuGet.config files and divide them into ones that
121121
// are explicitly configured for the project or by a private registry, and "all feeds"
122122
// (including inherited ones) from other locations on the host outside of the working directory.
@@ -627,15 +627,15 @@ private void EmitUnreachableFeedsDiagnostics(bool allFeedsReachable)
627627
compilationInfoContainer.CompilationInfos.Add(("All NuGet feeds reachable", allFeedsReachable ? "1" : "0"));
628628
}
629629

630-
private (HashSet<string> explicitFeeds, HashSet<string> allFeeds) GetAllFeeds()
630+
private void EmitNugetConfigDiagnostics()
631631
{
632-
var nugetConfigs = fileProvider.NugetConfigs;
633-
634632
// On systems with case-sensitive file systems (for simplicity, we assume that is Linux), the
635633
// filenames of NuGet configuration files must be named correctly. For compatibility with projects
636634
// that are typically built on Windows or macOS where this doesn't matter, we accept all variants
637635
// of `nuget.config` ourselves. However, `dotnet` does not. If we detect that incorrectly-named
638636
// files are present, we emit a diagnostic to warn the user.
637+
var nugetConfigs = fileProvider.NugetConfigs;
638+
639639
if (SystemBuildActions.Instance.IsLinux())
640640
{
641641
string[] acceptedNugetConfigNames = ["nuget.config", "NuGet.config", "NuGet.Config"];
@@ -665,6 +665,12 @@ private void EmitUnreachableFeedsDiagnostics(bool allFeedsReachable)
665665
));
666666
}
667667
}
668+
}
669+
670+
671+
private (HashSet<string> explicitFeeds, HashSet<string> allFeeds) GetAllFeeds()
672+
{
673+
var nugetConfigs = fileProvider.NugetConfigs;
668674

669675
// Find feeds that are explicitly configured in the NuGet configuration files that we found.
670676
var explicitFeeds = nugetConfigs

0 commit comments

Comments
 (0)