Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"toolName": "gcloud",
"toolVersion": "589.0.0",
"commandTreeSha256": "079bbdca7d4bf50be31bc48a88e110a5aedd7f4ac661fe6fac38418917eca479",
"generatorSourceSha256": "1c0d0e0ea277f58b002d9e56c7d75114e11b4f36a1c5fe979f8532af70e350ce"
"generatorSourceSha256": "2145aa00997a79b868d76196ad387ec1bbf063dfd1827bcb3f19deca4d56b449"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public record GcloudAccessApprovalRequestsListOptions : GcloudOptions, IValidata
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(Folder) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Organization) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Project) ? 1 : 0) > 1)
if ((Folder is not null ? 1 : 0) + (Organization is not null ? 1 : 0) + (Project is not null ? 1 : 0) > 1 || ((Folder is not null || Organization is not null || Project is not null) && !(!string.IsNullOrWhiteSpace(Folder) || !string.IsNullOrWhiteSpace(Organization) || !string.IsNullOrWhiteSpace(Project))))
{
yield return new ValidationResult("At most one of Folder, Organization, or Project may be specified.", [nameof(Folder), nameof(Organization), nameof(Project)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public record GcloudAccessApprovalServiceAccountGetOptions : GcloudOptions, IVal
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(Folder) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Organization) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Project) ? 1 : 0) > 1)
if ((Folder is not null ? 1 : 0) + (Organization is not null ? 1 : 0) + (Project is not null ? 1 : 0) > 1 || ((Folder is not null || Organization is not null || Project is not null) && !(!string.IsNullOrWhiteSpace(Folder) || !string.IsNullOrWhiteSpace(Organization) || !string.IsNullOrWhiteSpace(Project))))
{
yield return new ValidationResult("At most one of Folder, Organization, or Project may be specified.", [nameof(Folder), nameof(Organization), nameof(Project)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public record GcloudAccessApprovalSettingsDeleteOptions : GcloudOptions, IValida
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(Folder) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Organization) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Project) ? 1 : 0) > 1)
if ((Folder is not null ? 1 : 0) + (Organization is not null ? 1 : 0) + (Project is not null ? 1 : 0) > 1 || ((Folder is not null || Organization is not null || Project is not null) && !(!string.IsNullOrWhiteSpace(Folder) || !string.IsNullOrWhiteSpace(Organization) || !string.IsNullOrWhiteSpace(Project))))
{
yield return new ValidationResult("At most one of Folder, Organization, or Project may be specified.", [nameof(Folder), nameof(Organization), nameof(Project)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public record GcloudAccessApprovalSettingsGetOptions : GcloudOptions, IValidatab
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(Folder) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Organization) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Project) ? 1 : 0) > 1)
if ((Folder is not null ? 1 : 0) + (Organization is not null ? 1 : 0) + (Project is not null ? 1 : 0) > 1 || ((Folder is not null || Organization is not null || Project is not null) && !(!string.IsNullOrWhiteSpace(Folder) || !string.IsNullOrWhiteSpace(Organization) || !string.IsNullOrWhiteSpace(Project))))
{
yield return new ValidationResult("At most one of Folder, Organization, or Project may be specified.", [nameof(Folder), nameof(Organization), nameof(Project)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public record GcloudAccessApprovalSettingsUpdateOptions : GcloudOptions, IValida
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(Folder) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Organization) ? 1 : 0) + (!string.IsNullOrWhiteSpace(Project) ? 1 : 0) > 1)
if ((Folder is not null ? 1 : 0) + (Organization is not null ? 1 : 0) + (Project is not null ? 1 : 0) > 1 || ((Folder is not null || Organization is not null || Project is not null) && !(!string.IsNullOrWhiteSpace(Folder) || !string.IsNullOrWhiteSpace(Organization) || !string.IsNullOrWhiteSpace(Project))))
{
yield return new ValidationResult("At most one of Folder, Organization, or Project may be specified.", [nameof(Folder), nameof(Organization), nameof(Project)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private sealed class __SetOrgsSnapshotKeyValue(
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)AddOrgs is not string || !string.IsNullOrWhiteSpace(AddOrgs?.ToString()) : ((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)AddOrgs, static item => item is not null) : (AddOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)AddOrgs), static item => item is not null)))) ? 1 : 0) + (ClearOrgs == true ? 1 : 0) + (((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)RemoveOrgs is not string || !string.IsNullOrWhiteSpace(RemoveOrgs?.ToString()) : ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)RemoveOrgs, static item => item is not null) : (RemoveOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)RemoveOrgs), static item => item is not null)))) ? 1 : 0) + (((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)SetOrgs is not string || !string.IsNullOrWhiteSpace(SetOrgs?.ToString()) : ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)SetOrgs, static item => item is not null) : (SetOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)SetOrgs), static item => item is not null)))) ? 1 : 0) > 1)
if ((((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)AddOrgs is not string || !string.IsNullOrWhiteSpace(AddOrgs?.ToString()) : ((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)AddOrgs, static item => item is not null) : (AddOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)AddOrgs), static item => item is not null)))) ? 1 : 0) + (ClearOrgs == true ? 1 : 0) + (((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)RemoveOrgs is not string || !string.IsNullOrWhiteSpace(RemoveOrgs?.ToString()) : ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)RemoveOrgs, static item => item is not null) : (RemoveOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)RemoveOrgs), static item => item is not null)))) ? 1 : 0) + (((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)SetOrgs is not string || !string.IsNullOrWhiteSpace(SetOrgs?.ToString()) : ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)SetOrgs, static item => item is not null) : (SetOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)SetOrgs), static item => item is not null)))) ? 1 : 0) > 1 || ((((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)AddOrgs is not string || !string.IsNullOrWhiteSpace(AddOrgs?.ToString()) : ((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)AddOrgs, static item => item is not null) : (AddOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)AddOrgs), static item => item is not null)))) || ClearOrgs == true || ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)RemoveOrgs is not string || !string.IsNullOrWhiteSpace(RemoveOrgs?.ToString()) : ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)RemoveOrgs, static item => item is not null) : (RemoveOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)RemoveOrgs), static item => item is not null)))) || ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)SetOrgs is not string || !string.IsNullOrWhiteSpace(SetOrgs?.ToString()) : ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)SetOrgs, static item => item is not null) : (SetOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)SetOrgs), static item => item is not null))))) && !(((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)AddOrgs is not string || !string.IsNullOrWhiteSpace(AddOrgs?.ToString()) : ((object?)AddOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)AddOrgs, static item => item is not null) : (AddOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)AddOrgs), static item => item is not null)))) || ClearOrgs == true || ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)RemoveOrgs is not string || !string.IsNullOrWhiteSpace(RemoveOrgs?.ToString()) : ((object?)RemoveOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)RemoveOrgs, static item => item is not null) : (RemoveOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)RemoveOrgs), static item => item is not null)))) || ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<char> ? (object?)SetOrgs is not string || !string.IsNullOrWhiteSpace(SetOrgs?.ToString()) : ((object?)SetOrgs is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)SetOrgs, static item => item is not null) : (SetOrgs is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)SetOrgs), static item => item is not null)))))))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Collections get checked again

The added clause repeats the same collection tests on both sides of && !, so it cannot reject anything for stable values. It still calls Any again when the earlier count passes. Skip this clause in the generator when rendered presence and meaningful presence are identical. That avoids needless collection scans and makes the generated conditions easier to read.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

{
yield return new ValidationResult("At most one of AddOrgs, ClearOrgs, RemoveOrgs, or SetOrgs may be specified.", [nameof(AddOrgs), nameof(ClearOrgs), nameof(RemoveOrgs), nameof(SetOrgs)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public void Deconstruct(out string Title, out string Level)
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(CustomLevelSpec) ? 1 : 0) + ((!string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null) ? 1 : 0) != 1)
if (!(!string.IsNullOrWhiteSpace(CustomLevelSpec) || !string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null) || (CustomLevelSpec is not null ? 1 : 0) + ((BasicLevelSpec is not null || (object?)CombineFunction is not null) ? 1 : 0) != 1)
{
yield return new ValidationResult("Exactly one of CustomLevelSpec or (BasicLevelSpec or CombineFunction) must be specified.", [nameof(CustomLevelSpec), nameof(BasicLevelSpec), nameof(CombineFunction)]);
}
if ((!string.IsNullOrWhiteSpace(CustomLevelSpec) || !string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null) && (!string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null) && (!(!string.IsNullOrWhiteSpace(BasicLevelSpec))))
if ((CustomLevelSpec is not null || BasicLevelSpec is not null || (object?)CombineFunction is not null) && (BasicLevelSpec is not null || (object?)CombineFunction is not null) && (!(!string.IsNullOrWhiteSpace(BasicLevelSpec))))
{
yield return new ValidationResult("BasicLevelSpec must be specified when other arguments in this group are specified.", [nameof(BasicLevelSpec)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Deconstruct(out string Level)
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if (((!string.IsNullOrWhiteSpace(CustomLevelSpec)) ? 1 : 0) + ((!string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null) ? 1 : 0) > 1)
if (((CustomLevelSpec is not null) ? 1 : 0) + ((BasicLevelSpec is not null || (object?)CombineFunction is not null) ? 1 : 0) > 1 || ((CustomLevelSpec is not null || BasicLevelSpec is not null || (object?)CombineFunction is not null) && !(!string.IsNullOrWhiteSpace(CustomLevelSpec) || !string.IsNullOrWhiteSpace(BasicLevelSpec) || (object?)CombineFunction is not null)))
{
yield return new ValidationResult("At most one of (CustomLevelSpec) or (BasicLevelSpec or CombineFunction) may be specified.", [nameof(CustomLevelSpec), nameof(BasicLevelSpec), nameof(CombineFunction)]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private sealed class __VpcAllowedServicesSnapshotKeyValue(
/// <inheritdoc />
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
if ((!string.IsNullOrWhiteSpace(VpcAccessibleServices) ? 1 : 0) + ((EnableVpcAccessibleServices == true || ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<char> ? (object?)VpcAllowedServices is not string || !string.IsNullOrWhiteSpace(VpcAllowedServices?.ToString()) : ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)VpcAllowedServices, static item => item is not null) : (VpcAllowedServices is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)VpcAllowedServices), static item => item is not null))))) ? 1 : 0) > 1)
if ((VpcAccessibleServices is not null ? 1 : 0) + ((EnableVpcAccessibleServices == true || ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<char> ? (object?)VpcAllowedServices is not string || !string.IsNullOrWhiteSpace(VpcAllowedServices?.ToString()) : ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)VpcAllowedServices, static item => item is not null) : (VpcAllowedServices is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)VpcAllowedServices), static item => item is not null))))) ? 1 : 0) > 1 || ((VpcAccessibleServices is not null || EnableVpcAccessibleServices == true || ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<char> ? (object?)VpcAllowedServices is not string || !string.IsNullOrWhiteSpace(VpcAllowedServices?.ToString()) : ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)VpcAllowedServices, static item => item is not null) : (VpcAllowedServices is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)VpcAllowedServices), static item => item is not null))))) && !(!string.IsNullOrWhiteSpace(VpcAccessibleServices) || EnableVpcAccessibleServices == true || ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<char> ? (object?)VpcAllowedServices is not string || !string.IsNullOrWhiteSpace(VpcAllowedServices?.ToString()) : ((object?)VpcAllowedServices is global::System.Collections.Generic.IEnumerable<KeyValue> ? global::System.Linq.Enumerable.Any((global::System.Collections.Generic.IEnumerable<KeyValue>)(object)VpcAllowedServices, static item => item is not null) : (VpcAllowedServices is not null && global::System.Linq.Enumerable.Any(global::System.Linq.Enumerable.Cast<object>((global::System.Collections.IEnumerable)(object)VpcAllowedServices), static item => item is not null)))))))
{
yield return new ValidationResult("At most one of VpcAccessibleServices or (EnableVpcAccessibleServices or VpcAllowedServices) may be specified.", [nameof(VpcAccessibleServices), nameof(EnableVpcAccessibleServices), nameof(VpcAllowedServices)]);
}
Expand Down
Loading
Loading