@@ -29,6 +29,12 @@ internal sealed partial class FeedManager : IDisposable
2929 public bool HasPrivateRegistryFeeds { get ; }
3030 public bool CheckNugetFeedResponsiveness { get ; } = EnvironmentVariables . GetBooleanOptOut ( EnvironmentVariableNames . CheckNugetFeedResponsiveness ) ;
3131
32+ private readonly Lazy < ImmutableHashSet < string > > lazyExplicitFeeds ;
33+ public ImmutableHashSet < string > ExplicitFeeds => lazyExplicitFeeds . Value ;
34+
35+ private readonly Lazy < ImmutableHashSet < string > > lazyAllFeeds ;
36+ public ImmutableHashSet < string > AllFeeds => lazyAllFeeds . Value ;
37+
3238 public FeedManager ( ILogger logger , IDotNet dotnet , DependabotProxy ? dependabotProxy , FileProvider fileProvider )
3339 {
3440 this . logger = logger ;
@@ -38,6 +44,9 @@ public FeedManager(ILogger logger, IDotNet dotnet, DependabotProxy? dependabotPr
3844 PrivateRegistryFeeds = dependabotProxy ? . RegistryURLs . ToImmutableHashSet ( ) ?? [ ] ;
3945 HasPrivateRegistryFeeds = PrivateRegistryFeeds . Count > 0 ;
4046 emptyPackageDirectory = new DependencyDirectory ( "empty" , "empty package" , logger ) ;
47+
48+ lazyExplicitFeeds = new Lazy < ImmutableHashSet < string > > ( GetExplicitFeeds ) ;
49+ lazyAllFeeds = new Lazy < ImmutableHashSet < string > > ( GetAllFeeds ) ;
4150 }
4251
4352 private string ? GetDirectoryName ( string path )
@@ -271,7 +280,7 @@ private HashSet<string> GetExcludedFeeds()
271280 /// True if there is a timeout when trying to reach the feeds (excluding any feeds that are configured
272281 /// to be excluded from the check) or false otherwise.
273282 /// </returns>
274- public bool CheckSpecifiedFeeds ( HashSet < string > feeds , out HashSet < string > reachableFeeds )
283+ public bool CheckSpecifiedFeeds ( ImmutableHashSet < string > feeds , out HashSet < string > reachableFeeds )
275284 {
276285 // Exclude any feeds from the feed check that are configured by the corresponding environment variable.
277286 // These feeds are always assumed to be reachable.
@@ -342,7 +351,7 @@ private List<string> GetReachableNuGetFeeds(HashSet<string> feedsToCheck, bool i
342351 return reachableFeeds ;
343352 }
344353
345- public List < string > GetReachableFallbackNugetFeeds ( HashSet < string > ? feedsFromNugetConfigs )
354+ public List < string > GetReachableFallbackNugetFeeds ( ImmutableHashSet < string > ? feedsFromNugetConfigs )
346355 {
347356 var fallbackFeeds = EnvironmentVariables . GetURLs ( EnvironmentVariableNames . FallbackNugetFeeds ) . ToHashSet ( ) ;
348357 if ( fallbackFeeds . Count == 0 )
@@ -365,7 +374,7 @@ public List<string> GetReachableFallbackNugetFeeds(HashSet<string>? feedsFromNug
365374 return GetReachableNuGetFeeds ( fallbackFeeds , isFallback : true , out var _ ) ;
366375 }
367376
368- public ( HashSet < string > explicitFeeds , HashSet < string > allFeeds ) GetAllFeeds ( )
377+ private ImmutableHashSet < string > GetExplicitFeeds ( )
369378 {
370379 var nugetConfigs = fileProvider . NugetConfigs ;
371380
@@ -391,10 +400,17 @@ public List<string> GetReachableFallbackNugetFeeds(HashSet<string>? feedsFromNug
391400 explicitFeeds . UnionWith ( PrivateRegistryFeeds ) ;
392401 }
393402
403+ return explicitFeeds . ToImmutableHashSet ( ) ;
404+ }
405+
406+ private ImmutableHashSet < string > GetAllFeeds ( )
407+ {
408+ var nugetConfigs = fileProvider . NugetConfigs ;
409+
394410 HashSet < string > allFeeds = [ ] ;
395411
396412 // Add all explicitFeeds to the set of all feeds.
397- allFeeds . UnionWith ( explicitFeeds ) ;
413+ allFeeds . UnionWith ( ExplicitFeeds ) ;
398414
399415 // Obtain the list of feeds from the root source directory.
400416 // If a NuGet file is present it will be respected, otherwise we will just get the machine/environment specific feeds.
@@ -414,7 +430,7 @@ public List<string> GetReachableFallbackNugetFeeds(HashSet<string>? feedsFromNug
414430
415431 logger . LogInfo ( $ "Found { allFeeds . Count } NuGet feeds (with inherited ones) in nuget.config files: { string . Join ( ", " , allFeeds . OrderBy ( f => f ) ) } ") ;
416432
417- return ( explicitFeeds , allFeeds ) ;
433+ return allFeeds . ToImmutableHashSet ( ) ;
418434 }
419435
420436 [ GeneratedRegex ( @"^E\s(.*)$" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
0 commit comments