@@ -21,6 +21,7 @@ public class FileProvider
2121 private readonly Lazy < string [ ] > dlls ;
2222 private readonly Lazy < string [ ] > nugetConfigs ;
2323 private readonly Lazy < string [ ] > globalJsons ;
24+ private readonly Lazy < string [ ] > packagesConfigs ;
2425 private readonly Lazy < string [ ] > razorViews ;
2526 private readonly Lazy < string [ ] > resources ;
2627 private readonly Lazy < string ? > rootNugetConfig ;
@@ -32,31 +33,38 @@ public FileProvider(DirectoryInfo sourceDir, ILogger logger)
3233
3334 all = GetAllFiles ( ) ;
3435 allNonBinary = new Lazy < FileInfo [ ] > ( ( ) => all . Where ( f => ! binaryFileExtensions . Contains ( f . Extension . ToLowerInvariant ( ) ) ) . ToArray ( ) ) ;
35- smallNonBinary = new Lazy < string [ ] > ( ( ) =>
36- {
37- var ret = SelectSmallFiles ( allNonBinary . Value ) . SelectFileNames ( ) . ToArray ( ) ;
38- logger . LogInfo ( $ "Found { ret . Length } small non-binary files in { SourceDir } .") ;
39- return ret ;
40- } ) ;
36+ smallNonBinary = new Lazy < string [ ] > ( ( ) => ReturnAndLogFiles ( "small non-binary" , SelectSmallFiles ( allNonBinary . Value ) . SelectFileNames ( ) . ToArray ( ) ) ) ;
4137 sources = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByExtension ( "source" , ".cs" ) ) ;
4238 projects = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByExtension ( "project" , ".csproj" ) ) ;
4339 solutions = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByExtension ( "solution" , ".sln" ) ) ;
4440 dlls = new Lazy < string [ ] > ( ( ) => SelectBinaryFileNamesByExtension ( "DLL" , ".dll" ) ) ;
45- nugetConfigs = new Lazy < string [ ] > ( ( ) => allNonBinary . Value . SelectFileNamesByName ( "nuget.config" ) . ToArray ( ) ) ;
46- globalJsons = new Lazy < string [ ] > ( ( ) => allNonBinary . Value . SelectFileNamesByName ( "global.json" ) . ToArray ( ) ) ;
41+ nugetConfigs = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByName ( "nuget.config" ) ) ;
42+ globalJsons = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByName ( "global.json" ) ) ;
43+ packagesConfigs = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByName ( "packages.config" ) ) ;
4744 razorViews = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByExtension ( "razor view" , ".cshtml" , ".razor" ) ) ;
4845 resources = new Lazy < string [ ] > ( ( ) => SelectTextFileNamesByExtension ( "resource" , ".resx" ) ) ;
4946
5047 rootNugetConfig = new Lazy < string ? > ( ( ) => all . SelectRootFiles ( SourceDir ) . SelectFileNamesByName ( "nuget.config" ) . FirstOrDefault ( ) ) ;
5148 }
5249
53- private string [ ] SelectTextFileNamesByExtension ( string filetype , params string [ ] extensions )
50+ private string [ ] ReturnAndLogFiles ( string filetype , IEnumerable < string > files )
5451 {
55- var ret = allNonBinary . Value . SelectFileNamesByExtension ( extensions ) . ToArray ( ) ;
52+ var ret = files . ToArray ( ) ;
5653 logger . LogInfo ( $ "Found { ret . Length } { filetype } files in { SourceDir } .") ;
5754 return ret ;
5855 }
5956
57+ private string [ ] SelectTextFileNamesByExtension ( string filetype , params string [ ] extensions )
58+ => ReturnAndLogFiles ( filetype , allNonBinary . Value . SelectFileNamesByExtension ( extensions ) ) ;
59+
60+ private string [ ] SelectTextFileNamesByName ( string name )
61+ {
62+ var ret = allNonBinary . Value . SelectFileNamesByName ( name ) . ToArray ( ) ;
63+ var ending = ret . Length == 0 ? "." : $ ": { string . Join ( ", " , ret . OrderBy ( s => s ) ) } .";
64+ logger . LogInfo ( $ "Found { ret . Length } { name } files in { SourceDir } { ending } ") ;
65+ return ret ;
66+ }
67+
6068 private string [ ] SelectBinaryFileNamesByExtension ( string filetype , params string [ ] extensions )
6169 {
6270 var ret = all . SelectFileNamesByExtension ( extensions ) . ToArray ( ) ;
@@ -117,6 +125,7 @@ private FileInfo[] GetAllFiles()
117125 public ICollection < string > NugetConfigs => nugetConfigs . Value ;
118126 public string ? RootNugetConfig => rootNugetConfig . Value ;
119127 public IEnumerable < string > GlobalJsons => globalJsons . Value ;
128+ public ICollection < string > PackagesConfigs => packagesConfigs . Value ;
120129 public ICollection < string > RazorViews => razorViews . Value ;
121130 public ICollection < string > Resources => resources . Value ;
122131 }
0 commit comments