@@ -128,9 +128,10 @@ public Autobuilder(IBuildActions actions, AutobuildOptions options)
128128
129129 projectsOrSolutionsToBuildLazy = new Lazy < IList < IProjectOrSolution > > ( ( ) =>
130130 {
131+ List < IProjectOrSolution > ret ;
131132 if ( options . Solution . Any ( ) )
132133 {
133- var ret = new List < IProjectOrSolution > ( ) ;
134+ ret = new List < IProjectOrSolution > ( ) ;
134135 foreach ( var solution in options . Solution )
135136 {
136137 if ( actions . FileExists ( solution ) )
@@ -141,53 +142,43 @@ public Autobuilder(IBuildActions actions, AutobuildOptions options)
141142 return ret ;
142143 }
143144
144- bool FindFiles ( string extension , Func < string , ProjectOrSolution > create , out IEnumerable < IProjectOrSolution > files )
145+ IEnumerable < IProjectOrSolution > FindFiles ( string extension , Func < string , ProjectOrSolution > create )
145146 {
146- var allFiles = GetExtensions ( extension ) .
147+ var matchingFiles = GetExtensions ( extension ) .
147148 Select ( p => ( ProjectOrSolution : create ( p . Item1 ) , DistanceFromRoot : p . Item2 ) ) .
148149 Where ( p => p . ProjectOrSolution . HasLanguage ( this . Options . Language ) ) .
149150 ToArray ( ) ;
150151
151- if ( allFiles . Length == 0 )
152- {
153- files = null ;
154- return false ;
155- }
152+ if ( matchingFiles . Length == 0 )
153+ return null ;
156154
157155 if ( options . AllSolutions )
158- {
159- files = allFiles . Select ( p => p . ProjectOrSolution ) ;
160- return true ;
161- }
156+ return matchingFiles . Select ( p => p . ProjectOrSolution ) ;
162157
163- var firstIsClosest = allFiles . Length > 1 && allFiles [ 0 ] . DistanceFromRoot < allFiles [ 1 ] . DistanceFromRoot ;
164- if ( allFiles . Length == 1 || firstIsClosest )
165- {
166- files = allFiles . Select ( p => p . ProjectOrSolution ) . Take ( 1 ) ;
167- return true ;
168- }
158+ var firstIsClosest = matchingFiles . Length > 1 && matchingFiles [ 0 ] . DistanceFromRoot < matchingFiles [ 1 ] . DistanceFromRoot ;
159+ if ( matchingFiles . Length == 1 || firstIsClosest )
160+ return matchingFiles . Select ( p => p . ProjectOrSolution ) . Take ( 1 ) ;
169161
170- var candidates = allFiles .
171- Where ( f => f . DistanceFromRoot == allFiles [ 0 ] . DistanceFromRoot ) .
162+ var candidates = matchingFiles .
163+ Where ( f => f . DistanceFromRoot == matchingFiles [ 0 ] . DistanceFromRoot ) .
172164 Select ( f => f . ProjectOrSolution ) ;
173165 Log ( Severity . Info , $ "Found multiple '{ extension } ' files, giving up: { string . Join ( ", " , candidates ) } .") ;
174- files = new IProjectOrSolution [ 0 ] ;
175- return true ;
166+ return new IProjectOrSolution [ 0 ] ;
176167 }
177168
178169 // First look for `.proj` files
179- if ( FindFiles ( ".proj" , f => new Project ( this , f ) , out var ret1 ) )
180- return ret1 . ToList ( ) ;
170+ ret = FindFiles ( ".proj" , f => new Project ( this , f ) ) ? . ToList ( ) ;
171+ if ( ret != null )
172+ return ret ;
181173
182174 // Then look for `.sln` files
183- if ( FindFiles ( ".sln" , f => new Solution ( this , f ) , out var ret2 ) )
184- return ret2 . ToList ( ) ;
175+ ret = FindFiles ( ".sln" , f => new Solution ( this , f ) ) ? . ToList ( ) ;
176+ if ( ret != null )
177+ return ret ;
185178
186179 // Finally look for language specific project files, e.g. `.csproj` files
187- if ( FindFiles ( this . Options . Language . ProjectExtension , f => new Project ( this , f ) , out var ret3 ) )
188- return ret3 . ToList ( ) ;
189-
190- return new List < IProjectOrSolution > ( ) ;
180+ ret = FindFiles ( this . Options . Language . ProjectExtension , f => new Project ( this , f ) ) ? . ToList ( ) ;
181+ return ret ?? new List < IProjectOrSolution > ( ) ;
191182 } ) ;
192183
193184 SemmleDist = Actions . GetEnvironmentVariable ( "SEMMLE_DIST" ) ;
0 commit comments