Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit e5e18b7

Browse files
committed
Always create ResponseResult instead of returning null
1 parent 9f8b411 commit e5e18b7

28 files changed

Lines changed: 48 additions & 103 deletions

File tree

src/Areas/AppConfig/Commands/Account/AccountListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4646
options.Tenant,
4747
options.RetryPolicy);
4848

49-
context.Response.Results = accounts?.Count > 0 ?
50-
ResponseResult.Create(
49+
context.Response.Results = ResponseResult.Create(
5150
new AccountListCommandResult(accounts),
52-
AppConfigJsonContext.Default.AccountListCommandResult) :
53-
null;
51+
AppConfigJsonContext.Default.AccountListCommandResult);
5452
}
5553
catch (Exception ex)
5654
{

src/Areas/AppConfig/Commands/KeyValue/KeyValueListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6969
options.Tenant,
7070
options.RetryPolicy);
7171

72-
context.Response.Results = settings?.Count > 0 ?
73-
ResponseResult.Create(
72+
context.Response.Results = ResponseResult.Create(
7473
new KeyValueListCommandResult(settings),
75-
AppConfigJsonContext.Default.KeyValueListCommandResult) :
76-
null;
74+
AppConfigJsonContext.Default.KeyValueListCommandResult);
7775
}
7876
catch (Exception ex)
7977
{

src/Areas/Authorization/Commands/RoleAssignmentListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6262
options.Tenant,
6363
options.RetryPolicy);
6464

65-
context.Response.Results = assignments?.Count > 0 ?
66-
ResponseResult.Create(
65+
context.Response.Results = ResponseResult.Create(
6766
new RoleAssignmentListCommandResult(assignments),
68-
AuthorizationJsonContext.Default.RoleAssignmentListCommandResult) :
69-
null;
67+
AuthorizationJsonContext.Default.RoleAssignmentListCommandResult);
7068
}
7169
catch (Exception ex)
7270
{

src/Areas/Cosmos/Commands/AccountListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4545
options.Tenant,
4646
options.RetryPolicy);
4747

48-
context.Response.Results = accounts?.Count > 0 ?
49-
ResponseResult.Create(
48+
context.Response.Results = ResponseResult.Create(
5049
new AccountListCommandResult(accounts),
51-
CosmosJsonContext.Default.AccountListCommandResult) :
52-
null;
50+
CosmosJsonContext.Default.AccountListCommandResult);
5351
}
5452
catch (Exception ex)
5553
{

src/Areas/Cosmos/Commands/ContainerListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4848
options.Tenant,
4949
options.RetryPolicy);
5050

51-
context.Response.Results = containers?.Count > 0 ?
52-
ResponseResult.Create(
51+
context.Response.Results = ResponseResult.Create(
5352
new ContainerListCommandResult(containers),
54-
CosmosJsonContext.Default.ContainerListCommandResult) :
55-
null;
53+
CosmosJsonContext.Default.ContainerListCommandResult);
5654
}
5755
catch (Exception ex)
5856
{

src/Areas/Cosmos/Commands/DatabaseListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4646
options.Tenant,
4747
options.RetryPolicy);
4848

49-
context.Response.Results = databases?.Count > 0 ?
50-
ResponseResult.Create(
49+
context.Response.Results = ResponseResult.Create(
5150
new DatabaseListCommandResult(databases),
52-
CosmosJsonContext.Default.DatabaseListCommandResult) :
53-
null;
51+
CosmosJsonContext.Default.DatabaseListCommandResult);
5452
}
5553
catch (Exception ex)
5654
{

src/Areas/Group/Commands/GroupListCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4747
options.Tenant,
4848
options.RetryPolicy);
4949

50-
context.Response.Results = groups?.Count > 0 ?
51-
ResponseResult.Create(new Result(groups), JsonSourceGenerationContext.Default.Result) :
52-
null;
50+
context.Response.Results = ResponseResult.Create(new Result(groups), JsonSourceGenerationContext.Default.Result);
5351
}
5452
catch (Exception ex)
5553
{

src/Areas/KeyVault/Commands/Key/KeyListCommand.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6969
options.Tenant,
7070
options.RetryPolicy);
7171

72-
context.Response.Results = keys?.Count > 0 ?
73-
ResponseResult.Create(
72+
context.Response.Results = ResponseResult.Create(
7473
new KeyListCommandResult(keys),
75-
KeyVaultJsonContext.Default.KeyListCommandResult) :
76-
null;
74+
KeyVaultJsonContext.Default.KeyListCommandResult);
7775
}
7876
catch (Exception ex)
7977
{

src/Areas/Kusto/Commands/ClusterListCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
4646
options.Tenant,
4747
options.RetryPolicy);
4848

49-
context.Response.Results = clusterNames?.Count > 0 ?
50-
ResponseResult.Create(new ClusterListCommandResult(clusterNames), KustoJsonContext.Default.ClusterListCommandResult) :
51-
null;
49+
context.Response.Results = ResponseResult.Create(new ClusterListCommandResult(clusterNames), KustoJsonContext.Default.ClusterListCommandResult);
5250
}
5351
catch (Exception ex)
5452
{

src/Areas/Kusto/Commands/DatabaseListCommand.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,
6161
options.RetryPolicy);
6262
}
6363

64-
context.Response.Results = databasesNames?.Count > 0 ?
65-
ResponseResult.Create(new DatabaseListCommandResult(databasesNames), KustoJsonContext.Default.DatabaseListCommandResult) :
66-
null;
64+
context.Response.Results = ResponseResult.Create(new DatabaseListCommandResult(databasesNames), KustoJsonContext.Default.DatabaseListCommandResult);
6765
}
6866
catch (Exception ex)
6967
{

0 commit comments

Comments
 (0)