File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
Tocsoft.GraphQLCodeGen.Cli Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -101,16 +101,23 @@ public static void MainApplication(CommandLineApplication app)
101101
102102 IEnumerable < CodeGeneratorSettings > settings = settingsLoader . GenerateSettings ( loaderSettings , sourceArgument . Values ) ;
103103 HashSet < string > generatedFiles = new HashSet < string > ( ) ;
104- foreach ( CodeGeneratorSettings s in settings )
105- {
106- CodeGenerator generator = new CodeGenerator ( consoleLoger , s ) ;
107104
108- if ( await generator . GenerateAsync ( ) )
105+ var tasks = settings . Select ( Generate ) . ToList ( ) ;
106+ Task Generate ( CodeGeneratorSettings s )
107+ {
108+ return Task . Run ( async ( ) =>
109109 {
110- // generated code in here
111- generatedFiles . Add ( s . OutputPath ) ;
112- }
110+ CodeGenerator generator = new CodeGenerator ( consoleLoger , s ) ;
111+ if ( await generator . GenerateAsync ( ) )
112+ {
113+ // generated code in here
114+ generatedFiles . Add ( s . OutputPath ) ;
115+ }
116+ } ) ;
113117 }
118+
119+ await Task . WhenAll ( tasks ) ;
120+
114121 if ( inMsbuildMode )
115122 {
116123 foreach ( string result in generatedFiles )
Original file line number Diff line number Diff line change @@ -18,8 +18,14 @@ public Task<string> LoadSchema(SchemaSource source)
1818 {
1919 if ( ! parseCache . TryGetValue ( source . Location , out var schema ) )
2020 {
21- schema = ConvertJsonToSchema ( File . ReadAllText ( source . Location ) ) ;
22- parseCache . Add ( source . Location , schema ) ;
21+ lock ( parseCache )
22+ {
23+ if ( ! parseCache . TryGetValue ( source . Location , out schema ) )
24+ {
25+ schema = ConvertJsonToSchema ( File . ReadAllText ( source . Location ) ) ;
26+ parseCache . Add ( source . Location , schema ) ;
27+ }
28+ }
2329 }
2430 return Task . FromResult ( schema ) ;
2531 }
You can’t perform that action at this time.
0 commit comments