Skip to content

Commit 015886f

Browse files
authored
[csharp][netcore] Update type "String" to "string" for consistent type (#9713)
* Updated 'String' to 'string' for consistent use of keyword * Build project and update samples for csharp-netcore
1 parent c5405aa commit 015886f

File tree

162 files changed

+2679
-2679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+2679
-2679
lines changed

modules/openapi-generator/src/main/resources/csharp-netcore/ApiClient.mustache

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace {{packageName}}.Client
106106
var bytes = response.RawBytes;
107107
if (response.Headers != null)
108108
{
109-
var filePath = String.IsNullOrEmpty(_configuration.TempFolderPath)
109+
var filePath = string.IsNullOrEmpty(_configuration.TempFolderPath)
110110
? Path.GetTempPath()
111111
: _configuration.TempFolderPath;
112112
var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
@@ -130,7 +130,7 @@ namespace {{packageName}}.Client
130130
return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind);
131131
}
132132

133-
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
133+
if (type == typeof(string) || type.Name.StartsWith("System.Nullable")) // return primitive type
134134
{
135135
return Convert.ChangeType(response.Content, type);
136136
}
@@ -163,7 +163,7 @@ namespace {{packageName}}.Client
163163
/// </summary>
164164
{{>visibility}} partial class ApiClient : ISynchronousClient{{#supportsAsync}}, IAsynchronousClient{{/supportsAsync}}
165165
{
166-
private readonly String _baseUrl;
166+
private readonly string _baseUrl;
167167
168168
/// <summary>
169169
/// Specifies the settings on a <see cref="JsonSerializer" /> object.
@@ -208,7 +208,7 @@ namespace {{packageName}}.Client
208208
/// </summary>
209209
/// <param name="basePath">The target service's base path in URL format.</param>
210210
/// <exception cref="ArgumentException"></exception>
211-
public ApiClient(String basePath)
211+
public ApiClient(string basePath)
212212
{
213213
if (string.IsNullOrEmpty(basePath))
214214
throw new ArgumentException("basePath cannot be empty");
@@ -269,7 +269,7 @@ namespace {{packageName}}.Client
269269
/// <exception cref="ArgumentNullException"></exception>
270270
private RestRequest NewRequest(
271271
HttpMethod method,
272-
String path,
272+
string path,
273273
RequestOptions options,
274274
IReadableConfiguration configuration)
275275
{

modules/openapi-generator/src/main/resources/csharp-netcore/ApiResponse.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace {{packageName}}.Client
3636
/// <summary>
3737
/// Gets or sets any error text defined by the calling client.
3838
/// </summary>
39-
String ErrorText { get; set; }
39+
string ErrorText { get; set; }
4040

4141
/// <summary>
4242
/// Gets or sets any cookies passed along on the response.
@@ -77,7 +77,7 @@ namespace {{packageName}}.Client
7777
/// <summary>
7878
/// Gets or sets any error text defined by the calling client.
7979
/// </summary>
80-
public String ErrorText { get; set; }
80+
public string ErrorText { get; set; }
8181

8282
/// <summary>
8383
/// Gets or sets any cookies passed along on the response.

modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace {{packageName}}.Client
120120
/// URL encode a string
121121
/// Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50
122122
/// </summary>
123-
/// <param name="input">String to be URL encoded</param>
123+
/// <param name="input">string to be URL encoded</param>
124124
/// <returns>Byte array</returns>
125125
public static string UrlEncode(string input)
126126
{
@@ -154,7 +154,7 @@ namespace {{packageName}}.Client
154154
/// <summary>
155155
/// Encode string in base64 format.
156156
/// </summary>
157-
/// <param name="text">String to be encoded.</param>
157+
/// <param name="text">string to be encoded.</param>
158158
/// <returns>Encoded string.</returns>
159159
public static string Base64Encode(string text)
160160
{
@@ -182,7 +182,7 @@ namespace {{packageName}}.Client
182182
/// </summary>
183183
/// <param name="contentTypes">The Content-Type array to select from.</param>
184184
/// <returns>The Content-Type header to use.</returns>
185-
public static String SelectHeaderContentType(String[] contentTypes)
185+
public static string SelectHeaderContentType(string[] contentTypes)
186186
{
187187
if (contentTypes.Length == 0)
188188
return null;
@@ -203,15 +203,15 @@ namespace {{packageName}}.Client
203203
/// </summary>
204204
/// <param name="accepts">The accepts array to select from.</param>
205205
/// <returns>The Accept header to use.</returns>
206-
public static String SelectHeaderAccept(String[] accepts)
206+
public static string SelectHeaderAccept(string[] accepts)
207207
{
208208
if (accepts.Length == 0)
209209
return null;
210210
211211
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
212212
return "application/json";
213213
214-
return String.Join(",", accepts);
214+
return string.Join(",", accepts);
215215
}
216216

217217
/// <summary>
@@ -229,9 +229,9 @@ namespace {{packageName}}.Client
229229
/// </summary>
230230
/// <param name="mime">MIME</param>
231231
/// <returns>Returns True if MIME type is json.</returns>
232-
public static bool IsJsonMime(String mime)
232+
public static bool IsJsonMime(string mime)
233233
{
234-
if (String.IsNullOrWhiteSpace(mime)) return false;
234+
if (string.IsNullOrWhiteSpace(mime)) return false;
235235
236236
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
237237
}

modules/openapi-generator/src/main/resources/csharp-netcore/Configuration.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace {{packageName}}.Client
6868
/// Defines the base path of the target API server.
6969
/// Example: http://localhost:3000/v1/
7070
/// </summary>
71-
private String _basePath;
71+
private string _basePath;
7272

7373
/// <summary>
7474
/// Gets or sets the API key based on the authentication name.
@@ -496,9 +496,9 @@ namespace {{packageName}}.Client
496496
/// <summary>
497497
/// Returns a string with essential information for debugging.
498498
/// </summary>
499-
public static String ToDebugReport()
499+
public static string ToDebugReport()
500500
{
501-
String report = "C# SDK ({{{packageName}}}) Debug Report:\n";
501+
string report = "C# SDK ({{{packageName}}}) Debug Report:\n";
502502
report += " OS: " + System.Environment.OSVersion + "\n";
503503
report += " .NET Framework Version: " + System.Environment.Version + "\n";
504504
report += " Version of the API: {{{version}}}\n";

modules/openapi-generator/src/main/resources/csharp-netcore/HttpSigningConfiguration.mustache

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace {{packageName}}.Client
120120
}
121121
}
122122

123-
var httpValues = HttpUtility.ParseQueryString(String.Empty);
123+
var httpValues = HttpUtility.ParseQueryString(string.Empty);
124124
foreach (var parameter in requestOptions.QueryParameters)
125125
{
126126
#if (NETCOREAPP)
@@ -153,7 +153,7 @@ namespace {{packageName}}.Client
153153
uriBuilder.Query = httpValues.ToString().Replace("+", "%20");
154154

155155
var dateTime = DateTime.Now;
156-
String Digest = String.Empty;
156+
string Digest = string.Empty;
157157

158158
//get the body
159159
string requestBody = string.Empty;
@@ -230,7 +230,7 @@ namespace {{packageName}}.Client
230230
}
231231

232232
}
233-
var headersKeysString = String.Join(" ", HttpSignatureHeader.Keys);
233+
var headersKeysString = string.Join(" ", HttpSignatureHeader.Keys);
234234
var headerValuesList = new List<string>();
235235

236236
foreach (var keyVal in HttpSignatureHeader)
@@ -411,10 +411,10 @@ namespace {{packageName}}.Client
411411
return derBytes.ToArray();
412412
}
413413

414-
private RSACryptoServiceProvider GetRSAProviderFromPemFile(String pemfile, SecureString keyPassPharse = null)
414+
private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, SecureString keyPassPharse = null)
415415
{
416-
const String pempubheader = "-----BEGIN PUBLIC KEY-----";
417-
const String pempubfooter = "-----END PUBLIC KEY-----";
416+
const string pempubheader = "-----BEGIN PUBLIC KEY-----";
417+
const string pempubfooter = "-----END PUBLIC KEY-----";
418418
bool isPrivateKeyFile = true;
419419
byte[] pemkey = null;
420420
@@ -441,11 +441,11 @@ namespace {{packageName}}.Client
441441
return null;
442442
}
443443

444-
private byte[] ConvertPrivateKeyToBytes(String instr, SecureString keyPassPharse = null)
444+
private byte[] ConvertPrivateKeyToBytes(string instr, SecureString keyPassPharse = null)
445445
{
446-
const String pemprivheader = "-----BEGIN RSA PRIVATE KEY-----";
447-
const String pemprivfooter = "-----END RSA PRIVATE KEY-----";
448-
String pemstr = instr.Trim();
446+
const string pemprivheader = "-----BEGIN RSA PRIVATE KEY-----";
447+
const string pemprivfooter = "-----END RSA PRIVATE KEY-----";
448+
string pemstr = instr.Trim();
449449
byte[] binkey;
450450
451451
if (!pemstr.StartsWith(pemprivheader) || !pemstr.EndsWith(pemprivfooter))
@@ -456,7 +456,7 @@ namespace {{packageName}}.Client
456456
StringBuilder sb = new StringBuilder(pemstr);
457457
sb.Replace(pemprivheader, "");
458458
sb.Replace(pemprivfooter, "");
459-
String pvkstr = sb.ToString().Trim();
459+
string pvkstr = sb.ToString().Trim();
460460

461461
try
462462
{ // if there are no PEM encryption info lines, this is an UNencrypted PEM private key
@@ -472,12 +472,12 @@ namespace {{packageName}}.Client
472472
{
473473
return null;
474474
}
475-
String saltline = str.ReadLine();
475+
string saltline = str.ReadLine();
476476
if (!saltline.StartsWith("DEK-Info: DES-EDE3-CBC,"))
477477
{
478478
return null;
479479
}
480-
String saltstr = saltline.Substring(saltline.IndexOf(",") + 1).Trim();
480+
string saltstr = saltline.Substring(saltline.IndexOf(",") + 1).Trim();
481481
byte[] salt = new byte[saltstr.Length / 2];
482482
for (int i = 0; i < salt.Length; i++)
483483
salt[i] = Convert.ToByte(saltstr.Substring(i * 2, 2), 16);
@@ -487,7 +487,7 @@ namespace {{packageName}}.Client
487487
}
488488

489489
//------ remaining b64 data is encrypted RSA key ----
490-
String encryptedstr = str.ReadToEnd();
490+
string encryptedstr = str.ReadToEnd();
491491

492492
try
493493
{ //should have b64 encrypted RSA key now

modules/openapi-generator/src/main/resources/csharp-netcore/IApiAccessor.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace {{packageName}}.Client
1919
/// Gets the base path of the API client.
2020
/// </summary>
2121
/// <value>The base path</value>
22-
String GetBasePath();
22+
string GetBasePath();
2323

2424
/// <summary>
2525
/// Provides a factory method hook for the creation of exceptions.

modules/openapi-generator/src/main/resources/csharp-netcore/IAsynchronousClient.mustache

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace {{packageName}}.Client
2121
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
2222
/// <typeparam name="T">The return type.</typeparam>
2323
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
24-
Task<ApiResponse<T>> GetAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
24+
Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
2525
2626
/// <summary>
2727
/// Executes a non-blocking call to some <paramref name="path"/> using the POST http verb.
@@ -32,7 +32,7 @@ namespace {{packageName}}.Client
3232
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
3333
/// <typeparam name="T">The return type.</typeparam>
3434
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
35-
Task<ApiResponse<T>> PostAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
35+
Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
3636
3737
/// <summary>
3838
/// Executes a non-blocking call to some <paramref name="path"/> using the PUT http verb.
@@ -43,7 +43,7 @@ namespace {{packageName}}.Client
4343
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
4444
/// <typeparam name="T">The return type.</typeparam>
4545
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
46-
Task<ApiResponse<T>> PutAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
46+
Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
4747
4848
/// <summary>
4949
/// Executes a non-blocking call to some <paramref name="path"/> using the DELETE http verb.
@@ -54,7 +54,7 @@ namespace {{packageName}}.Client
5454
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
5555
/// <typeparam name="T">The return type.</typeparam>
5656
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
57-
Task<ApiResponse<T>> DeleteAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
57+
Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
5858
5959
/// <summary>
6060
/// Executes a non-blocking call to some <paramref name="path"/> using the HEAD http verb.
@@ -65,7 +65,7 @@ namespace {{packageName}}.Client
6565
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
6666
/// <typeparam name="T">The return type.</typeparam>
6767
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
68-
Task<ApiResponse<T>> HeadAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
68+
Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
6969
7070
/// <summary>
7171
/// Executes a non-blocking call to some <paramref name="path"/> using the OPTIONS http verb.
@@ -76,7 +76,7 @@ namespace {{packageName}}.Client
7676
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
7777
/// <typeparam name="T">The return type.</typeparam>
7878
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
79-
Task<ApiResponse<T>> OptionsAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
79+
Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
8080
8181
/// <summary>
8282
/// Executes a non-blocking call to some <paramref name="path"/> using the PATCH http verb.
@@ -87,6 +87,6 @@ namespace {{packageName}}.Client
8787
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
8888
/// <typeparam name="T">The return type.</typeparam>
8989
/// <returns>A task eventually representing the response data, decorated with <see cref="ApiResponse{T}"/></returns>
90-
Task<ApiResponse<T>> PatchAsync<T>(String path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
90+
Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
9191
}
9292
}

0 commit comments

Comments
 (0)