@@ -39,19 +39,22 @@ public static class CodeGenerator
39
39
{
40
40
public static string CatFormatPropertyGenerator ( string type , string name , string key , string setter ) =>
41
41
$ "public { type } { name } {{ "
42
- + $ " get => Q<{ type } >(\" { key } \" );"
42
+ + $ " get => Q<{ type } >(\" { key } \" );{ Environment . NewLine } "
43
43
+ $ " set {{ Q(\" { key } \" , { setter } ); SetAcceptHeader({ setter } ); }}"
44
44
+ $ "}}";
45
45
46
46
public static string PropertyGenerator ( string type , string name , string key , string setter ) =>
47
- $ "public { type } { name } {{ get => Q<{ type } >(\" { key } \" ); set => Q(\" { key } \" , { setter } ); }}";
47
+ $ "public { type } { name } {{ get => Q<{ type } >(\" { key } \" );{ Environment . NewLine } set => Q(\" { key } \" , { setter } ); }}";
48
48
49
49
public static string Property ( string @namespace , string type , string name , string key , string setter , string obsolete , Version versionAdded , params string [ ] doc )
50
50
{
51
51
var components = new List < string > ( ) ;
52
- foreach ( var d in RenderDocumentation ( doc ) ) A ( d ) ;
53
- if ( versionAdded != null ) A ( $ "/// <remarks>Supported by OpenSearch servers of version { versionAdded } or greater.</remarks>") ;
54
- if ( ! string . IsNullOrWhiteSpace ( obsolete ) ) A ( $ "[Obsolete(\" { obsolete } \" )]") ;
52
+ foreach ( var d in RenderDocumentation ( doc ) )
53
+ A ( d ) ;
54
+ if ( versionAdded != null )
55
+ A ( $ "/// <remarks>Supported by OpenSearch servers of version { versionAdded } or greater.</remarks>") ;
56
+ if ( ! string . IsNullOrWhiteSpace ( obsolete ) )
57
+ A ( $ "[Obsolete(\" { obsolete } \" )]") ;
55
58
56
59
var generated = @namespace != null && @namespace == "Cat" && name == "Format"
57
60
? CatFormatPropertyGenerator ( type , name , key , setter )
@@ -69,12 +72,16 @@ void A(string s)
69
72
public static string Constructor ( Constructor c )
70
73
{
71
74
var components = new List < string > ( ) ;
72
- if ( ! c . Description . IsNullOrEmpty ( ) ) A ( c . Description ) ;
75
+ if ( ! c . Description . IsNullOrEmpty ( ) )
76
+ A ( c . Description ) ;
73
77
var generated = c . Generated ;
74
- if ( c . Body . IsNullOrEmpty ( ) ) generated += "{}" ;
78
+ if ( c . Body . IsNullOrEmpty ( ) )
79
+ generated += "{}" ;
75
80
A ( generated ) ;
76
- if ( ! c . Body . IsNullOrEmpty ( ) ) A ( c . Body ) ;
77
- if ( ! c . AdditionalCode . IsNullOrEmpty ( ) ) A ( c . AdditionalCode ) ;
81
+ if ( ! c . Body . IsNullOrEmpty ( ) )
82
+ A ( c . Body ) ;
83
+ if ( ! c . AdditionalCode . IsNullOrEmpty ( ) )
84
+ A ( c . AdditionalCode ) ;
78
85
return string . Join ( $ "{ Environment . NewLine } \t \t ", components ) ;
79
86
80
87
void A ( string s )
@@ -88,15 +95,17 @@ private static IEnumerable<string> RenderDocumentation(params string[] doc)
88
95
doc = ( doc ? . SelectMany ( WrapDocumentation ) ?? Enumerable . Empty < string > ( ) ) . ToArray ( ) ;
89
96
switch ( doc . Length )
90
97
{
91
- case 0 : yield break ;
98
+ case 0 :
99
+ yield break ;
92
100
case 1 :
93
101
yield return $ "/// <summary>{ doc [ 0 ] } </summary>";
94
102
95
103
yield break ;
96
104
default :
97
105
yield return "/// <summary>" ;
98
106
99
- foreach ( var d in doc ) yield return $ "/// { d } ";
107
+ foreach ( var d in doc )
108
+ yield return $ "/// { d } ";
100
109
101
110
yield return "/// </summary>" ;
102
111
@@ -106,7 +115,8 @@ private static IEnumerable<string> RenderDocumentation(params string[] doc)
106
115
107
116
private static string [ ] WrapDocumentation ( string documentation )
108
117
{
109
- if ( string . IsNullOrWhiteSpace ( documentation ) ) return Array . Empty < string > ( ) ;
118
+ if ( string . IsNullOrWhiteSpace ( documentation ) )
119
+ return Array . Empty < string > ( ) ;
110
120
const int max = 140 ;
111
121
var lines = documentation . Split ( new [ ] { ' ' } , StringSplitOptions . RemoveEmptyEntries ) ;
112
122
var charCount = 0 ;
0 commit comments