Skip to content

Commit 9616526

Browse files
committed
chore(repo): code cleanup
1 parent 4e49838 commit 9616526

9 files changed

Lines changed: 163 additions & 222 deletions

File tree

examples/GoAffPro.Client.Example/Worker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
3030
return;
3131
}
3232

33-
await client.LoginAsync(_options.Email, _options.Password, stoppingToken).ConfigureAwait(false);
33+
_ = await client.LoginAsync(_options.Email, _options.Password, stoppingToken).ConfigureAwait(false);
3434
LogAuthenticated(logger);
3535
}
3636

src/GoAffPro.Client.Generator/GeneratorRunner.cs

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
using System.Security.Cryptography;
21
using System.Diagnostics;
2+
using System.Security.Cryptography;
33
using System.Text;
44
using System.Text.Json;
55
using System.Text.Json.Nodes;
6-
using System.Linq;
76
using NJsonSchema.CodeGeneration.CSharp;
87
using NSwag;
9-
using NSwag.CodeGeneration;
108
using NSwag.CodeGeneration.CSharp;
119
using NSwag.CodeGeneration.OperationNameGenerators;
1210

@@ -35,9 +33,9 @@ public static async Task RunAsync(GeneratorOptions options, CancellationToken ca
3533
string generatedDirectory = Path.Combine(projectDirectory, "Generated");
3634
string intermediateDirectory = Path.Combine(projectDirectory, "obj");
3735

38-
Directory.CreateDirectory(openApiDirectory);
39-
Directory.CreateDirectory(generatedDirectory);
40-
Directory.CreateDirectory(intermediateDirectory);
36+
_ = Directory.CreateDirectory(openApiDirectory);
37+
_ = Directory.CreateDirectory(generatedDirectory);
38+
_ = Directory.CreateDirectory(intermediateDirectory);
4139

4240
string lockFilePath = Path.Combine(intermediateDirectory, LockFileName);
4341
using FileStream generatorLock = await AcquireGeneratorLockAsync(lockFilePath, TimeSpan.FromMinutes(2), cancellationToken)
@@ -122,7 +120,7 @@ await File.WriteAllTextAsync(
122120

123121
private static async Task<FileStream> AcquireGeneratorLockAsync(string lockFilePath, TimeSpan timeout, CancellationToken cancellationToken)
124122
{
125-
Stopwatch stopwatch = Stopwatch.StartNew();
123+
var stopwatch = Stopwatch.StartNew();
126124

127125
while (true)
128126
{
@@ -258,19 +256,19 @@ private static void NormalizeParameters(JsonObject operation)
258256
if (typeNode is not null)
259257
{
260258
schema["type"] = typeNode.DeepClone();
261-
parameter.Remove("type");
259+
_ = parameter.Remove("type");
262260
}
263261

264262
if (parameter.TryGetPropertyValue("enum", out JsonNode? enumNode) && enumNode is not null)
265263
{
266264
schema["enum"] = enumNode.DeepClone();
267-
parameter.Remove("enum");
265+
_ = parameter.Remove("enum");
268266
}
269267

270268
if (parameter.TryGetPropertyValue("items", out JsonNode? itemsNode) && itemsNode is not null)
271269
{
272270
schema["items"] = itemsNode.DeepClone();
273-
parameter.Remove("items");
271+
_ = parameter.Remove("items");
274272
}
275273

276274
parameter["schema"] = schema;
@@ -347,44 +345,41 @@ private static JsonObject CreateResponseSchema(string path)
347345
_ => null,
348346
};
349347

350-
if (feedProperty is null)
351-
{
352-
return new JsonObject
348+
return feedProperty is null
349+
? new JsonObject
353350
{
354351
["type"] = "object",
355352
["additionalProperties"] = true,
356-
};
357-
}
358-
359-
return new JsonObject
360-
{
361-
["type"] = "object",
362-
["properties"] = new JsonObject
353+
}
354+
: new JsonObject
363355
{
364-
[feedProperty] = new JsonObject
356+
["type"] = "object",
357+
["properties"] = new JsonObject
365358
{
366-
["type"] = "array",
367-
["items"] = new JsonObject
359+
[feedProperty] = new JsonObject
368360
{
369-
["type"] = "object",
370-
["additionalProperties"] = true,
361+
["type"] = "array",
362+
["items"] = new JsonObject
363+
{
364+
["type"] = "object",
365+
["additionalProperties"] = true,
366+
},
367+
},
368+
["limit"] = new JsonObject
369+
{
370+
["type"] = "integer",
371+
},
372+
["offset"] = new JsonObject
373+
{
374+
["type"] = "integer",
375+
},
376+
["count"] = new JsonObject
377+
{
378+
["type"] = "integer",
371379
},
372380
},
373-
["limit"] = new JsonObject
374-
{
375-
["type"] = "integer",
376-
},
377-
["offset"] = new JsonObject
378-
{
379-
["type"] = "integer",
380-
},
381-
["count"] = new JsonObject
382-
{
383-
["type"] = "integer",
384-
},
385-
},
386-
["additionalProperties"] = true,
387-
};
381+
["additionalProperties"] = true,
382+
};
388383
}
389384

390385
private static async Task<string> GenerateClientAsync(
@@ -424,14 +419,14 @@ private static async Task<string> GenerateClientAsync(
424419
private static string AddAutoGeneratedHeader(string generatedCode, string source)
425420
{
426421
StringBuilder builder = new();
427-
builder.AppendLine("// <auto-generated>");
428-
builder.AppendLine("// This file was generated by GoAffPro.Client.Generator.");
429-
builder.Append("// Source: ").AppendLine(source);
430-
builder.Append("// Generated: ").AppendLine(DateTimeOffset.UtcNow.ToString("O"));
431-
builder.AppendLine("// Do not edit manually.");
432-
builder.AppendLine("// </auto-generated>");
433-
builder.AppendLine();
434-
builder.Append(generatedCode);
422+
_ = builder.AppendLine("// <auto-generated>");
423+
_ = builder.AppendLine("// This file was generated by GoAffPro.Client.Generator.");
424+
_ = builder.Append("// Source: ").AppendLine(source);
425+
_ = builder.Append("// Generated: ").AppendLine(DateTimeOffset.UtcNow.ToString("O"));
426+
_ = builder.AppendLine("// Do not edit manually.");
427+
_ = builder.AppendLine("// </auto-generated>");
428+
_ = builder.AppendLine();
429+
_ = builder.Append(generatedCode);
435430
return builder.ToString();
436431
}
437432

src/GoAffPro.Client.Generator/GoAffProClientGeneratorTask.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.Build.Framework;
2-
using Microsoft.Build.Utilities;
32

43
namespace GoAffPro.Client.Generator;
54

0 commit comments

Comments
 (0)