File tree 1 file changed +9
-5
lines changed
packages/quicktype-core/src/language/CSharp
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -389,19 +389,23 @@ export class CSharpRenderer extends ConvenienceRenderer {
389
389
}
390
390
391
391
protected emitDependencyUsings ( ) : void {
392
- let nameSpaceForTypes : string [ ] = [ ] ;
392
+ let genericEmited : boolean = false ;
393
+ let ensureGenericOnce = ( ) => {
394
+ if ( ! genericEmited ) {
395
+ this . emitUsing ( "System.Collections.Generic" ) ;
396
+ genericEmited = true ;
397
+ }
398
+ }
393
399
this . typeGraph . allTypesUnordered ( ) . forEach ( _ => {
394
400
matchCompoundType (
395
401
_ ,
396
- _arrayType => this . _csOptions . useList ? nameSpaceForTypes . push ( "System.Collections.Generic" ) : undefined ,
402
+ _arrayType => this . _csOptions . useList ? ensureGenericOnce ( ) : undefined ,
397
403
_classType => { } ,
398
- _mapType => nameSpaceForTypes . push ( "System.Collections.Generic" ) ,
404
+ _mapType => ensureGenericOnce ( ) ,
399
405
_objectType => { } ,
400
406
_unionType => { }
401
407
)
402
408
} ) ;
403
- nameSpaceForTypes = nameSpaceForTypes . filter ( ( val , ind ) => nameSpaceForTypes . indexOf ( val ) === ind ) ;
404
- nameSpaceForTypes . forEach ( this . emitUsing . bind ( this ) ) ;
405
409
}
406
410
407
411
}
You can’t perform that action at this time.
0 commit comments