Skip to content

Commit 73e6fa4

Browse files
HavenDVclaude
andcommitted
fix: Resolve CA1849 and null dereference warnings
Use WriteLineAsync in TrimCommand async method to fix CA1849 warnings. Replace .Where(x => x is not null) with .OfType<>() in DocsSynchronizer to fix null dereference warnings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 44a355f commit 73e6fa4

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/libs/AutoSDK.CLI/Commands/TrimCommand.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private async Task HandleAsync(ParseResult parseResult)
5757
var fullCsprojPath = Path.GetFullPath(csprojPath);
5858
if (!File.Exists(fullCsprojPath))
5959
{
60-
Console.Error.WriteLine($"Error: File not found: {fullCsprojPath}");
60+
await Console.Error.WriteLineAsync($"Error: File not found: {fullCsprojPath}").ConfigureAwait(false);
6161
return;
6262
}
6363

@@ -153,7 +153,7 @@ await File.WriteAllTextAsync(
153153
using var process = Process.Start(psi);
154154
if (process == null)
155155
{
156-
Console.Error.WriteLine("Error: Failed to start dotnet process.");
156+
await Console.Error.WriteLineAsync("Error: Failed to start dotnet process.").ConfigureAwait(false);
157157
return;
158158
}
159159

@@ -169,7 +169,7 @@ await File.WriteAllTextAsync(
169169
}
170170
if (!string.IsNullOrWhiteSpace(stderr))
171171
{
172-
Console.Error.WriteLine(stderr);
172+
await Console.Error.WriteLineAsync(stderr).ConfigureAwait(false);
173173
}
174174
}
175175

@@ -201,18 +201,18 @@ await File.WriteAllTextAsync(
201201
{
202202
if (errors.Count > 0)
203203
{
204-
Console.Error.WriteLine($"Build failed with {errors.Count} error(s):");
205-
Console.Error.WriteLine();
204+
await Console.Error.WriteLineAsync($"Build failed with {errors.Count} error(s):").ConfigureAwait(false);
205+
await Console.Error.WriteLineAsync().ConfigureAwait(false);
206206
foreach (var error in errors)
207207
{
208-
Console.Error.WriteLine($" {error}");
208+
await Console.Error.WriteLineAsync($" {error}").ConfigureAwait(false);
209209
}
210-
Console.Error.WriteLine();
210+
await Console.Error.WriteLineAsync().ConfigureAwait(false);
211211
}
212212
else if (!verbose)
213213
{
214-
Console.Error.WriteLine("Build failed. Run with --verbose for details.");
215-
Console.Error.WriteLine();
214+
await Console.Error.WriteLineAsync("Build failed. Run with --verbose for details.").ConfigureAwait(false);
215+
await Console.Error.WriteLineAsync().ConfigureAwait(false);
216216
}
217217

218218
Environment.ExitCode = 1;

src/libs/AutoSDK.Docs/DocsSynchronizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static async Task<DocsSyncResult> SyncLegacyExamplesAsync(
9797
.EnumerateFiles(project.ExampleSourceDirectory, "Tests.*.cs", SearchOption.AllDirectories)
9898
.OrderBy(Path.GetFileName, StringComparer.Ordinal)
9999
.Select(path => TryLoadLegacySample(path, project.ClientClassName, project.ApiKeyVariableName, project.ClientReplacements))
100-
.Where(x => x is not null)
100+
.OfType<LegacyExampleDocument>()
101101
.ToList()
102102
: [];
103103

0 commit comments

Comments
 (0)