@@ -179,7 +179,7 @@ out var handle
179179 CXDiagnostic_Warning => LogLevel . Warning ,
180180 CXDiagnostic_Error => LogLevel . Error ,
181181 CXDiagnostic_Fatal => LogLevel . Critical ,
182- _ => LogLevel . Trace
182+ _ => LogLevel . Trace ,
183183 } ,
184184 " {0}" ,
185185 diagnostic . Format ( CXDiagnostic . DefaultDisplayOptions ) . ToString ( )
@@ -202,7 +202,14 @@ out var handle
202202 using var translationUnit = TranslationUnit . GetOrCreate ( handle ) ;
203203 Debug . Assert ( translationUnit is not null ) ;
204204
205- logger . LogInformation ( "Generating raw bindings for '{0}' ({1}/{2}) ({3}/{4})" , fileName , index , count , rspIndex , rspCount ) ;
205+ logger . LogInformation (
206+ "Generating raw bindings for '{0}' ({1}/{2}) ({3}/{4})" ,
207+ fileName ,
208+ index ,
209+ count ,
210+ rspIndex ,
211+ rspCount
212+ ) ;
206213 pinvokeGenerator . GenerateBindings (
207214 translationUnit ,
208215 filePath ,
@@ -213,15 +220,14 @@ out var handle
213220
214221 if ( files . Count == 0 )
215222 {
216- logger . LogWarning ( "No files generated for {0}" ,
217- filePath ) ;
223+ logger . LogWarning ( "No files generated for {0}" , filePath ) ;
218224 }
219225 else
220226 {
221227 logger . LogDebug (
222- "Completed generation for {0}, file count: {1}" ,
223- filePath ,
224- files . Count
228+ "Completed generation for {0}, file count: {1}" ,
229+ filePath ,
230+ files . Count
225231 ) ;
226232 }
227233 }
@@ -298,15 +304,19 @@ await Parallel.ForEachAsync(
298304 new ParallelOptions
299305 {
300306 CancellationToken = ct ,
301- MaxDegreeOfParallelism = parallelism
307+ MaxDegreeOfParallelism = parallelism ,
302308 } ,
303309 async ( rsp , innerCt ) =>
304310 await Task . Run (
305311 async ( ) =>
306312 {
307313 int index = Interlocked . Increment ( ref rspIndex ) ;
308314 // Generate the raw bindings.
309- var ( sources , tests , hasErrors ) = ScrapeRawBindings ( rsp , index , rspCount ) ;
315+ var ( sources , tests , hasErrors ) = ScrapeRawBindings (
316+ rsp ,
317+ index ,
318+ rspCount
319+ ) ;
310320
311321 static MemoryStream Reopen ( MemoryStream ms ) =>
312322 ms . TryGetBuffer ( out var buff ) && buff . Array is not null
@@ -334,8 +344,9 @@ static MemoryStream Reopen(MemoryStream ms) =>
334344 // Cache the output.
335345 //TODO: Refactor for better Parallelisation
336346 //Breaks with high concurrency
337- string relativePath = $ "{ ( isTest ? "tests" : "sources" ) } /{ relativeKey } ";
338- if ( cacheKey is not null && ! hasErrors && cfg . CacheOutput )
347+ string relativePath =
348+ $ "{ ( isTest ? "tests" : "sources" ) } /{ relativeKey } ";
349+ if ( cacheKey is not null && ! hasErrors && cfg . CacheOutput )
339350 {
340351 cacheDir ??= (
341352 await cacheProvider ! . GetDirectory (
@@ -359,7 +370,7 @@ static MemoryStream Reopen(MemoryStream ms) =>
359370 logger . LogTrace ( "ClangSharp skipped {0}" , relativePath ) ;
360371 continue ;
361372 }
362-
373+
363374 // Add it to the dictionary.
364375 if (
365376 ! ( isTest ? aggregatedTests : aggregatedSources ) . TryAdd (
@@ -471,7 +482,7 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
471482 // Others
472483 VisualStudioResolver . TryGetVisualStudioInfo ( out _ )
473484 ? "vs"
474- : "!vs"
485+ : "!vs" ,
475486 } ;
476487
477488 // Read the configuration.
@@ -486,19 +497,35 @@ public async Task ExecuteAsync(IModContext ctx, CancellationToken ct = default)
486497 var toRemoveMatcher = new Matcher ( ) ;
487498 if ( cfg . GeneratedToRemove is not null )
488499 {
489- toRemoveMatcher . AddIncludePatterns ( cfg . GeneratedToRemove . Where ( toRemove => ! toRemove . StartsWith ( "!" ) ) . Select ( ResponseFileHandler . PathFixup ) ) ;
490- toRemoveMatcher . AddExcludePatterns ( cfg . GeneratedToRemove . Where ( toRemove => toRemove . StartsWith ( "!" ) ) . Select ( toRemove => toRemove [ 1 ..] ) . Select ( ResponseFileHandler . PathFixup ) ) ;
500+ toRemoveMatcher . AddIncludePatterns (
501+ cfg . GeneratedToRemove . Where ( toRemove => ! toRemove . StartsWith ( "!" ) )
502+ . Select ( ResponseFileHandler . PathFixup )
503+ ) ;
504+ toRemoveMatcher . AddExcludePatterns (
505+ cfg . GeneratedToRemove . Where ( toRemove => toRemove . StartsWith ( "!" ) )
506+ . Select ( toRemove => toRemove [ 1 ..] )
507+ . Select ( ResponseFileHandler . PathFixup )
508+ ) ;
491509 }
492510
493511 if ( rsps . Count == 0 )
494512 {
495513 logger . LogWarning ( "No Response files found for {}" , ctx . JobKey ) ;
496514 }
497515
498- var missingIncludes = rsps . SelectMany < ResponseFile , string > ( rsp => rsp . ClangCommandLineArgs . Where ( arg => arg . StartsWith ( "--include-directory=" ) && ! Directory . Exists ( arg . Substring ( 20 ) ) ) ) . Select ( arg => arg . Substring ( 20 ) ) . Distinct ( ) ;
516+ var missingIncludes = rsps . SelectMany < ResponseFile , string > ( rsp =>
517+ rsp . ClangCommandLineArgs . Where ( arg =>
518+ arg . StartsWith ( "--include-directory=" ) && ! Directory . Exists ( arg . Substring ( 20 ) )
519+ )
520+ )
521+ . Select ( arg => arg . Substring ( 20 ) )
522+ . Distinct ( ) ;
499523 if ( missingIncludes . Count ( ) > 0 )
500524 {
501- logger . LogWarning ( "The following includes are missing and may cause erroneous generation: \n " + string . Join ( "\n " , missingIncludes ) ) ;
525+ logger . LogWarning (
526+ "The following includes are missing and may cause erroneous generation: \n "
527+ + string . Join ( "\n " , missingIncludes )
528+ ) ;
502529 }
503530
504531 // Apply modifications. This is done before the cache key as modifications to the rsps result in different
0 commit comments