Skip to content

Commit

Permalink
Azure.Provisioning: Avoid excess nulls in BicepStringBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
tg-msft committed Oct 21, 2024
1 parent 3fadc42 commit acbd6e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,12 @@ await test.Define(
infra.Add(new ProvisioningOutput("blobs_endpoint", typeof(string)) { Value = storage.PrimaryEndpoints.Value!.BlobUri });
// Manually compute the public Azure endpoint
string? nothing = null;
BicepValue<string> computed =
new BicepStringBuilder()
.Append("https://")
.Append($"{storage.Name}")
.Append(".blob.core.windows.net");
.Append($".blob.core.windows.net{nothing}");
infra.Add(new ProvisioningOutput("computed_endpoint", typeof(string)) { Value = computed });
return infra;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ public void AppendFormatted<T>(T t)
_expressions.Add(BicepSyntax.Var(v.BicepIdentifier));
_isSecure = _isSecure || v.Value.IsSecure;
}
else
else if (t is not null)
{
_expressions.Add(
t is null ?
BicepSyntax.Null() :
BicepSyntax.Value(t.ToString() ?? ""));
string? s = t.ToString();
if (s is not null)
{
_expressions.Add(BicepSyntax.Value(s));
}
}
}

Expand Down

0 comments on commit acbd6e3

Please sign in to comment.