Skip to content

Commit 12fc1cf

Browse files
Rename CLICheckResponse as PackageCheckResponse (#12733)
1 parent 0735d19 commit 12fc1cf

File tree

9 files changed

+183
-183
lines changed

9 files changed

+183
-183
lines changed

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Models/Responses/Package/CLICheckResponse.cs renamed to tools/azsdk-cli/Azure.Sdk.Tools.Cli/Models/Responses/Package/PackageCheckResponse.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Azure.Sdk.Tools.Cli.Models.Responses.Package;
77
/// <summary>
88
/// Base class for CLI check responses with exit code and output.
99
/// </summary>
10-
public class CLICheckResponse : PackageResponseBase
10+
public class PackageCheckResponse : PackageResponseBase
1111
{
1212
// Map ExitCode to CliExitCode for JSON serialization
1313
[JsonPropertyName("exit_code")]
@@ -16,9 +16,9 @@ public class CLICheckResponse : PackageResponseBase
1616
[JsonPropertyName("check_status_details")]
1717
public string CheckStatusDetails { get; set; }
1818

19-
public CLICheckResponse() { }
19+
public PackageCheckResponse() { }
2020

21-
public CLICheckResponse(int exitCode, string checkStatusDetails, string error = null)
21+
public PackageCheckResponse(int exitCode, string checkStatusDetails, string error = null)
2222
{
2323
ExitCode = exitCode;
2424
CheckStatusDetails = checkStatusDetails;
@@ -28,7 +28,7 @@ public CLICheckResponse(int exitCode, string checkStatusDetails, string error =
2828
}
2929
}
3030

31-
public CLICheckResponse(ProcessResult processResult)
31+
public PackageCheckResponse(ProcessResult processResult)
3232
{
3333
ExitCode = processResult.ExitCode;
3434
CheckStatusDetails = processResult.Output;
@@ -45,14 +45,14 @@ protected override string Format()
4545
}
4646

4747
/// <summary>
48-
/// CLI check response for cookbook/documentation reference responses.
48+
/// Package check response for cookbook/documentation reference responses.
4949
/// </summary>
50-
public class CookbookCLICheckResponse : CLICheckResponse
50+
public class CookbookPackageCheckResponse : PackageCheckResponse
5151
{
5252
[JsonPropertyName("cookbook_reference")]
5353
public string CookbookReference { get; set; }
5454

55-
public CookbookCLICheckResponse(int exitCode, string checkStatusDetails, string cookbookReference) : base(exitCode, checkStatusDetails)
55+
public CookbookPackageCheckResponse(int exitCode, string checkStatusDetails, string cookbookReference) : base(exitCode, checkStatusDetails)
5656
{
5757
CookbookReference = cookbookReference;
5858
}

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/Languages/DotNetLanguageSpecificChecks.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public DotNetLanguageSpecificChecks(
3131
_logger = logger;
3232
}
3333

34-
public async Task<CLICheckResponse> CheckGeneratedCode(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
34+
public async Task<PackageCheckResponse> CheckGeneratedCode(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
3535
{
3636
try
3737
{
@@ -48,15 +48,15 @@ public async Task<CLICheckResponse> CheckGeneratedCode(string packagePath, bool
4848
if (serviceDirectory == null)
4949
{
5050
_logger.LogError("Failed to determine service directory from package path: {PackagePath}", packagePath);
51-
return new CLICheckResponse(1, "", "Failed to determine service directory from the provided package path.");
51+
return new PackageCheckResponse(1, "", "Failed to determine service directory from the provided package path.");
5252
}
5353

5454
var repoRoot = _gitHelper.DiscoverRepoRoot(packagePath);
5555
var scriptPath = Path.Combine(repoRoot, "eng", "scripts", "CodeChecks.ps1");
5656
if (!File.Exists(scriptPath))
5757
{
5858
_logger.LogError("Code checks script not found at: {ScriptPath}", scriptPath);
59-
return new CLICheckResponse(1, "", $"Code checks script not found at: {scriptPath}");
59+
return new PackageCheckResponse(1, "", $"Code checks script not found at: {scriptPath}");
6060
}
6161

6262
var args = new[] { scriptPath, "-ServiceDirectory", serviceDirectory, "-SpellCheckPublicApiSurface" };
@@ -66,22 +66,22 @@ public async Task<CLICheckResponse> CheckGeneratedCode(string packagePath, bool
6666
if (result.ExitCode == 0)
6767
{
6868
_logger.LogInformation("Generated code checks completed successfully");
69-
return new CLICheckResponse(result.ExitCode, result.Output);
69+
return new PackageCheckResponse(result.ExitCode, result.Output);
7070
}
7171
else
7272
{
7373
_logger.LogWarning("Generated code checks for package at {PackagePath} failed with exit code {ExitCode}", packagePath, result.ExitCode);
74-
return new CLICheckResponse(result.ExitCode, result.Output, "Generated code checks failed");
74+
return new PackageCheckResponse(result.ExitCode, result.Output, "Generated code checks failed");
7575
}
7676
}
7777
catch (Exception ex)
7878
{
7979
_logger.LogError(ex, "Error running generated code checks at {PackagePath}", packagePath);
80-
return new CLICheckResponse(1, "", $"Error running generated code checks: {ex.Message}");
80+
return new PackageCheckResponse(1, "", $"Error running generated code checks: {ex.Message}");
8181
}
8282
}
8383

84-
public async Task<CLICheckResponse> CheckAotCompat(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
84+
public async Task<PackageCheckResponse> CheckAotCompat(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
8585
{
8686
try
8787
{
@@ -99,22 +99,22 @@ public async Task<CLICheckResponse> CheckAotCompat(string packagePath, bool fixC
9999
if (serviceDirectory == null || packageName == null)
100100
{
101101
_logger.LogError("Failed to determine service directory or package name from package path: {PackagePath}", packagePath);
102-
return new CLICheckResponse(1, "", "Failed to determine service directory or package name from the provided package path.");
102+
return new PackageCheckResponse(1, "", "Failed to determine service directory or package name from the provided package path.");
103103
}
104104

105105
var isAotOptedOut = await CheckAotCompatOptOut(packagePath, packageName, ct);
106106
if (isAotOptedOut)
107107
{
108108
_logger.LogInformation("AOT compatibility check skipped - AotCompatOptOut is set to true in project file");
109-
return new CLICheckResponse(0, "AOT compatibility check skipped - AotCompatOptOut is set to true in project file");
109+
return new PackageCheckResponse(0, "AOT compatibility check skipped - AotCompatOptOut is set to true in project file");
110110
}
111111

112112
var repoRoot = _gitHelper.DiscoverRepoRoot(packagePath);
113113
var scriptPath = Path.Combine(repoRoot, "eng", "scripts", "compatibility", "Check-AOT-Compatibility.ps1");
114114
if (!File.Exists(scriptPath))
115115
{
116116
_logger.LogError("AOT compatibility script not found at: {ScriptPath}", scriptPath);
117-
return new CLICheckResponse(1, "", $"AOT compatibility script not found at: {scriptPath}");
117+
return new PackageCheckResponse(1, "", $"AOT compatibility script not found at: {scriptPath}");
118118
}
119119

120120
var workingDirectory = Path.Combine(repoRoot, "eng", "scripts", "compatibility");
@@ -126,28 +126,28 @@ public async Task<CLICheckResponse> CheckAotCompat(string packagePath, bool fixC
126126
if (result.ExitCode == 0)
127127
{
128128
_logger.LogInformation("AOT compatibility check completed successfully");
129-
return new CLICheckResponse(result.ExitCode, result.Output);
129+
return new PackageCheckResponse(result.ExitCode, result.Output);
130130
}
131131
else
132132
{
133133
_logger.LogWarning("AOT compatibility check failed with exit code {ExitCode}", result.ExitCode);
134-
return new CLICheckResponse(result.ExitCode, result.Output, "AOT compatibility check failed");
134+
return new PackageCheckResponse(result.ExitCode, result.Output, "AOT compatibility check failed");
135135
}
136136
}
137137
catch (Exception ex)
138138
{
139139
_logger.LogError(ex, "Error running AOT compatibility check at {PackagePath}", packagePath);
140-
return new CLICheckResponse(1, "", $"Error running AOT compatibility check: {ex.Message}");
140+
return new PackageCheckResponse(1, "", $"Error running AOT compatibility check: {ex.Message}");
141141
}
142142
}
143143

144-
private async ValueTask<CLICheckResponse> VerifyDotnetVersion()
144+
private async ValueTask<PackageCheckResponse> VerifyDotnetVersion()
145145
{
146146
var dotnetSDKCheck = await _processHelper.Run(new ProcessOptions(DotNetCommand, ["--list-sdks"]), CancellationToken.None);
147147
if (dotnetSDKCheck.ExitCode != 0)
148148
{
149149
_logger.LogError(".NET SDK is not installed or not available in PATH");
150-
return new CLICheckResponse(dotnetSDKCheck.ExitCode, $"dotnet --list-sdks failed with an error: {dotnetSDKCheck.Output}");
150+
return new PackageCheckResponse(dotnetSDKCheck.ExitCode, $"dotnet --list-sdks failed with an error: {dotnetSDKCheck.Output}");
151151
}
152152

153153
var dotnetVersions = dotnetSDKCheck.Output.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
@@ -159,18 +159,18 @@ private async ValueTask<CLICheckResponse> VerifyDotnetVersion()
159159
if (installedVersion >= minimumVersion)
160160
{
161161
_logger.LogInformation(".NET SDK version {InstalledVersion} meets minimum requirement of {RequiredVersion}", latestVersionNumber, RequiredDotNetVersion);
162-
return new CLICheckResponse(0, $".NET SDK version {latestVersionNumber} meets minimum requirement of {RequiredDotNetVersion}");
162+
return new PackageCheckResponse(0, $".NET SDK version {latestVersionNumber} meets minimum requirement of {RequiredDotNetVersion}");
163163
}
164164
else
165165
{
166166
_logger.LogError(".NET SDK version {InstalledVersion} is below minimum requirement of {RequiredVersion}", latestVersionNumber, RequiredDotNetVersion);
167-
return new CLICheckResponse(1, "", $".NET SDK version {latestVersionNumber} is below minimum requirement of {RequiredDotNetVersion}");
167+
return new PackageCheckResponse(1, "", $".NET SDK version {latestVersionNumber} is below minimum requirement of {RequiredDotNetVersion}");
168168
}
169169
}
170170
else
171171
{
172172
_logger.LogError("Failed to parse .NET SDK version: {VersionString}", latestVersionNumber);
173-
return new CLICheckResponse(1, "", $"Failed to parse .NET SDK version: {latestVersionNumber}");
173+
return new PackageCheckResponse(1, "", $"Failed to parse .NET SDK version: {latestVersionNumber}");
174174
}
175175
}
176176

tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/Languages/GoLanguageSpecificChecks.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,44 @@ public async Task<bool> CheckDependencies(CancellationToken ct)
5353
}
5454
}
5555

56-
public async Task<CLICheckResponse> CreateEmptyPackage(string packagePath, string moduleName, CancellationToken ct)
56+
public async Task<PackageCheckResponse> CreateEmptyPackage(string packagePath, string moduleName, CancellationToken ct)
5757
{
5858
try
5959
{
6060
var result = await _processHelper.Run(new ProcessOptions(compilerName, ["mod", "init", moduleName], compilerNameWindows, ["mod", "init", moduleName], workingDirectory: packagePath), ct);
61-
return new CLICheckResponse(result);
61+
return new PackageCheckResponse(result);
6262
}
6363
catch (Exception ex)
6464
{
6565
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(CreateEmptyPackage));
66-
return new CLICheckResponse(1, "", $"{nameof(CreateEmptyPackage)} failed with an exception: {ex.Message}");
66+
return new PackageCheckResponse(1, "", $"{nameof(CreateEmptyPackage)} failed with an exception: {ex.Message}");
6767
}
6868
}
6969

7070
#endregion
7171

72-
public async Task<CLICheckResponse> AnalyzeDependenciesAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
72+
public async Task<PackageCheckResponse> AnalyzeDependenciesAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
7373
{
7474
try
7575
{
7676
// Update all dependencies to the latest first
7777
var updateResult = await _processHelper.Run(new ProcessOptions(compilerName, ["get", "-u", "all"], compilerNameWindows, ["get", "-u", "all"], workingDirectory: packagePath), ct);
7878
if (updateResult.ExitCode != 0)
7979
{
80-
return new CLICheckResponse(updateResult);
80+
return new PackageCheckResponse(updateResult);
8181
}
8282

8383
// Now tidy, to cleanup any deps that aren't needed
8484
var tidyResult = await _processHelper.Run(new ProcessOptions(compilerName, ["mod", "tidy"], compilerNameWindows, ["mod", "tidy"], workingDirectory: packagePath), ct);
85-
return new CLICheckResponse(tidyResult);
85+
return new PackageCheckResponse(tidyResult);
8686
}
8787
catch (Exception ex)
8888
{
8989
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(AnalyzeDependenciesAsync));
90-
return new CLICheckResponse(1, "", $"{nameof(AnalyzeDependenciesAsync)} failed with an exception: {ex.Message}");
90+
return new PackageCheckResponse(1, "", $"{nameof(AnalyzeDependenciesAsync)} failed with an exception: {ex.Message}");
9191
}
9292
}
93-
public async Task<CLICheckResponse> FormatCodeAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
93+
public async Task<PackageCheckResponse> FormatCodeAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
9494
{
9595
try
9696
{
@@ -99,54 +99,54 @@ public async Task<CLICheckResponse> FormatCodeAsync(string packagePath, bool fix
9999
formatterNameWindows, ["-w", "."],
100100
workingDirectory: packagePath
101101
), ct);
102-
return new CLICheckResponse(result);
102+
return new PackageCheckResponse(result);
103103
}
104104
catch (Exception ex)
105105
{
106106
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(FormatCodeAsync));
107-
return new CLICheckResponse(1, "", $"{nameof(FormatCodeAsync)} failed with an exception: {ex.Message}");
107+
return new PackageCheckResponse(1, "", $"{nameof(FormatCodeAsync)} failed with an exception: {ex.Message}");
108108
}
109109
}
110110

111-
public async Task<CLICheckResponse> LintCodeAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
111+
public async Task<PackageCheckResponse> LintCodeAsync(string packagePath, bool fixCheckErrors = false, CancellationToken ct = default)
112112
{
113113
try
114114
{
115115
var result = await _processHelper.Run(new ProcessOptions(linterName, ["run"], linterNameWindows, ["run"], workingDirectory: packagePath), ct);
116-
return new CLICheckResponse(result);
116+
return new PackageCheckResponse(result);
117117
}
118118
catch (Exception ex)
119119
{
120120
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(LintCodeAsync));
121-
return new CLICheckResponse(1, "", $"{nameof(LintCodeAsync)} failed with an exception: {ex.Message}");
121+
return new PackageCheckResponse(1, "", $"{nameof(LintCodeAsync)} failed with an exception: {ex.Message}");
122122
}
123123
}
124124

125-
public async Task<CLICheckResponse> RunTestsAsync(string packagePath, CancellationToken ct)
125+
public async Task<PackageCheckResponse> RunTestsAsync(string packagePath, CancellationToken ct)
126126
{
127127
try
128128
{
129129
var result = await _processHelper.Run(new ProcessOptions(compilerName, ["test", "-v", "-timeout", "1h", "./..."], compilerNameWindows, ["test", "-v", "-timeout", "1h", "./..."], workingDirectory: packagePath), ct);
130-
return new CLICheckResponse(result);
130+
return new PackageCheckResponse(result);
131131
}
132132
catch (Exception ex)
133133
{
134134
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(RunTestsAsync));
135-
return new CLICheckResponse(1, "", $"{nameof(RunTestsAsync)} failed with an exception: {ex.Message}");
135+
return new PackageCheckResponse(1, "", $"{nameof(RunTestsAsync)} failed with an exception: {ex.Message}");
136136
}
137137
}
138138

139-
public async Task<CLICheckResponse> BuildProjectAsync(string packagePath, CancellationToken ct)
139+
public async Task<PackageCheckResponse> BuildProjectAsync(string packagePath, CancellationToken ct)
140140
{
141141
try
142142
{
143143
var result = await _processHelper.Run(new ProcessOptions(compilerName, ["build"], compilerNameWindows, ["build"], workingDirectory: packagePath), ct);
144-
return new CLICheckResponse(result);
144+
return new PackageCheckResponse(result);
145145
}
146146
catch (Exception ex)
147147
{
148148
_logger.LogError(ex, "{MethodName} failed with an exception", nameof(BuildProjectAsync));
149-
return new CLICheckResponse(1, "", $"{nameof(BuildProjectAsync)} failed with an exception: {ex.Message}");
149+
return new PackageCheckResponse(1, "", $"{nameof(BuildProjectAsync)} failed with an exception: {ex.Message}");
150150
}
151151
}
152152

@@ -163,8 +163,8 @@ public async Task<string> GetSDKPackageName(string repo, string packagePath, Can
163163
return await Task.FromResult(relativePath.Replace(Path.DirectorySeparatorChar, '/'));
164164
}
165165

166-
public async Task<CLICheckResponse> UpdateSnippetsAsync(string packagePath, bool fixCheckErrors = false, CancellationToken cancellationToken = default)
166+
public async Task<PackageCheckResponse> UpdateSnippetsAsync(string packagePath, bool fixCheckErrors = false, CancellationToken cancellationToken = default)
167167
{
168-
return await Task.FromResult(new CLICheckResponse());
168+
return await Task.FromResult(new PackageCheckResponse());
169169
}
170170
}

0 commit comments

Comments
 (0)