11
11
12
12
namespace KubernetesWatchGenerator
13
13
{
14
- class Program
14
+ internal class Program
15
15
{
16
16
private static HashSet < string > _classesWithValidation ;
17
- static readonly Dictionary < string , string > ClassNameMap = new Dictionary < string , string > ( ) ;
17
+ private static readonly Dictionary < string , string > ClassNameMap = new Dictionary < string , string > ( ) ;
18
18
private static Dictionary < JsonSchema4 , string > _schemaToNameMap ;
19
19
private static HashSet < string > _schemaDefinitionsInMultipleGroups ;
20
20
private static Dictionary < string , string > _classNameToPluralMap ;
21
21
22
- static async Task Main ( string [ ] args )
22
+ private static async Task Main ( string [ ] args )
23
23
{
24
24
if ( args . Length < 2 )
25
25
{
@@ -31,7 +31,7 @@ static async Task Main(string[] args)
31
31
32
32
// Read the spec trimmed
33
33
// here we cache all name in gen project for later use
34
- var swagger = await SwaggerDocument . FromFileAsync ( Path . Combine ( args [ 1 ] , "swagger.json" ) ) ;
34
+ var swagger = await SwaggerDocument . FromFileAsync ( Path . Combine ( args [ 1 ] , "swagger.json" ) ) . ConfigureAwait ( false ) ;
35
35
foreach ( var ( k , v ) in swagger . Definitions )
36
36
{
37
37
if ( v . ExtensionData ? . TryGetValue ( "x-kubernetes-group-version-kind" , out var _ ) == true )
@@ -46,9 +46,8 @@ static async Task Main(string[] args)
46
46
}
47
47
}
48
48
49
-
50
49
// gen project removed all watch operations, so here we switch back to unprocessed version
51
- swagger = await SwaggerDocument . FromFileAsync ( Path . Combine ( args [ 1 ] , "swagger.json.unprocessed" ) ) ;
50
+ swagger = await SwaggerDocument . FromFileAsync ( Path . Combine ( args [ 1 ] , "swagger.json.unprocessed" ) ) . ConfigureAwait ( false ) ;
52
51
_schemaToNameMap = swagger . Definitions . ToDictionary ( x => x . Value , x => x . Key ) ;
53
52
_schemaDefinitionsInMultipleGroups = _schemaToNameMap . Values . Select ( x =>
54
53
{
@@ -90,7 +89,6 @@ static async Task Main(string[] args)
90
89
. Union ( _classNameToPluralMap )
91
90
. ToDictionary ( x => x . Key , x => x . Value ) ;
92
91
93
-
94
92
// Register helpers used in the templating.
95
93
Helpers . Register ( nameof ( ToXmlDoc ) , ToXmlDoc ) ;
96
94
Helpers . Register ( nameof ( GetClassName ) , GetClassName ) ;
@@ -166,12 +164,9 @@ static async Task Main(string[] args)
166
164
167
165
Render . FileToFile ( "VersionConverter.cs.template" , versionConverterPairs , Path . Combine ( outputDirectory , "VersionConverter.cs" ) ) ;
168
166
Render . FileToFile ( "ModelOperators.cs.template" , typePairs , Path . Combine ( outputDirectory , "ModelOperators.cs" ) ) ;
169
-
170
167
}
171
168
172
-
173
-
174
- static void ToXmlDoc ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
169
+ private static void ToXmlDoc ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
175
170
RenderBlock fn , RenderBlock inverse )
176
171
{
177
172
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is string )
@@ -199,7 +194,7 @@ static void ToXmlDoc(RenderContext context, IList<object> arguments, IDictionary
199
194
}
200
195
}
201
196
202
- static void GetTuple ( RenderContext context , IList < object > arguments , IDictionary < string , object > options , RenderBlock fn , RenderBlock inverse )
197
+ private static void GetTuple ( RenderContext context , IList < object > arguments , IDictionary < string , object > options , RenderBlock fn , RenderBlock inverse )
203
198
{
204
199
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] is ITuple && options . TryGetValue ( "index" , out var indexObj ) && int . TryParse ( indexObj ? . ToString ( ) , out var index ) )
205
200
{
@@ -209,9 +204,7 @@ static void GetTuple(RenderContext context, IList<object> arguments, IDictionary
209
204
}
210
205
}
211
206
212
-
213
-
214
- static void GetClassName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
207
+ private static void GetClassName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
215
208
RenderBlock fn , RenderBlock inverse )
216
209
{
217
210
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is SwaggerOperation )
@@ -224,7 +217,7 @@ static void GetClassName(RenderContext context, IList<object> arguments, IDictio
224
217
}
225
218
}
226
219
227
- static string GetClassName ( SwaggerOperation watchOperation )
220
+ private static string GetClassName ( SwaggerOperation watchOperation )
228
221
{
229
222
var groupVersionKind =
230
223
( Dictionary < string , object > ) watchOperation . ExtensionData [ "x-kubernetes-group-version-kind" ] ;
@@ -257,7 +250,7 @@ private static void GetInterfaceName(RenderContext context, IList<object> argume
257
250
}
258
251
}
259
252
260
- static string GetClassNameForSchemaDefinition ( JsonSchema4 definition )
253
+ private static string GetClassNameForSchemaDefinition ( JsonSchema4 definition )
261
254
{
262
255
if ( definition . ExtensionData != null &&
263
256
definition . ExtensionData . ContainsKey ( "x-kubernetes-group-version-kind" ) )
@@ -280,7 +273,7 @@ static string GetClassNameForSchemaDefinition(JsonSchema4 definition)
280
273
return className ;
281
274
}
282
275
283
- static string GetInterfaceName ( JsonSchema4 definition )
276
+ private static string GetInterfaceName ( JsonSchema4 definition )
284
277
{
285
278
var groupVersionKindElements = ( object [ ] ) definition . ExtensionData [ "x-kubernetes-group-version-kind" ] ;
286
279
var groupVersionKind = ( Dictionary < string , object > ) groupVersionKindElements [ 0 ] ;
@@ -321,8 +314,7 @@ static string GetInterfaceName(JsonSchema4 definition)
321
314
return result ;
322
315
}
323
316
324
-
325
- static void GetKind ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
317
+ private static void GetKind ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
326
318
RenderBlock fn , RenderBlock inverse )
327
319
{
328
320
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema4 )
@@ -339,7 +331,7 @@ private static string GetKind(JsonSchema4 definition)
339
331
return groupVersionKind [ "kind" ] as string ;
340
332
}
341
333
342
- static void GetPlural ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
334
+ private static void GetPlural ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
343
335
RenderBlock fn , RenderBlock inverse )
344
336
{
345
337
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema4 )
@@ -362,7 +354,7 @@ private static string GetPlural(JsonSchema4 definition)
362
354
return _classNameToPluralMap . GetValueOrDefault ( className , null ) ;
363
355
}
364
356
365
- static void GetGroup ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
357
+ private static void GetGroup ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
366
358
RenderBlock fn , RenderBlock inverse )
367
359
{
368
360
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema4 )
@@ -379,7 +371,7 @@ private static string GetGroup(JsonSchema4 definition)
379
371
return groupVersionKind [ "group" ] as string ;
380
372
}
381
373
382
- static void GetMethodName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
374
+ private static void GetMethodName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
383
375
RenderBlock fn , RenderBlock inverse )
384
376
{
385
377
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is SwaggerOperation )
@@ -388,8 +380,7 @@ static void GetMethodName(RenderContext context, IList<object> arguments, IDicti
388
380
}
389
381
}
390
382
391
-
392
- static string GetMethodName ( SwaggerOperation watchOperation )
383
+ private static string GetMethodName ( SwaggerOperation watchOperation )
393
384
{
394
385
var tag = watchOperation . Tags [ 0 ] ;
395
386
tag = tag . Replace ( "_" , string . Empty ) ;
@@ -402,7 +393,7 @@ static string GetMethodName(SwaggerOperation watchOperation)
402
393
return methodName ;
403
394
}
404
395
405
- static void GetDotNetType ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
396
+ private static void GetDotNetType ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
406
397
RenderBlock fn , RenderBlock inverse )
407
398
{
408
399
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is SwaggerParameter )
@@ -463,7 +454,7 @@ private static string GetDotNetType(JsonObjectType jsonType, string name, bool r
463
454
}
464
455
}
465
456
466
- static void GetDotNetName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
457
+ private static void GetDotNetName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
467
458
RenderBlock fn , RenderBlock inverse )
468
459
{
469
460
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is SwaggerParameter )
@@ -492,7 +483,7 @@ private static string GetDotNetName(string jsonName)
492
483
return jsonName ;
493
484
}
494
485
495
- static void GetPathExpression ( RenderContext context , IList < object > arguments ,
486
+ private static void GetPathExpression ( RenderContext context , IList < object > arguments ,
496
487
IDictionary < string , object > options , RenderBlock fn , RenderBlock inverse )
497
488
{
498
489
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null &&
@@ -516,7 +507,7 @@ private static string GetPathExpression(SwaggerOperationDescription operation)
516
507
return pathExpression ;
517
508
}
518
509
519
- static void GetApiVersion ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
510
+ private static void GetApiVersion ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
520
511
RenderBlock fn , RenderBlock inverse )
521
512
{
522
513
if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema4 )
0 commit comments