Skip to content

Commit 8897cd4

Browse files
authored
Azure.Provisioning: Avoid excess nulls in BicepStringBuilder (Azure#46742)
1 parent 2deb63c commit 8897cd4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

sdk/provisioning/Azure.Provisioning.Storage/tests/BasicStorageTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,12 @@ await test.Define(
270270
infra.Add(new ProvisioningOutput("blobs_endpoint", typeof(string)) { Value = storage.PrimaryEndpoints.Value!.BlobUri });
271271

272272
// Manually compute the public Azure endpoint
273+
string? nothing = null;
273274
BicepValue<string> computed =
274275
new BicepStringBuilder()
275276
.Append("https://")
276277
.Append($"{storage.Name}")
277-
.Append(".blob.core.windows.net");
278+
.Append($".blob.core.windows.net{nothing}");
278279
infra.Add(new ProvisioningOutput("computed_endpoint", typeof(string)) { Value = computed });
279280

280281
return infra;

sdk/provisioning/Azure.Provisioning/src/Expressions/BicepStringBuilder.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ public void AppendFormatted<T>(T t)
102102
}
103103
else
104104
{
105-
_expressions.Add(
106-
t is null ?
107-
BicepSyntax.Null() :
108-
BicepSyntax.Value(t.ToString() ?? ""));
105+
string? s = t?.ToString();
106+
if (s is not null)
107+
{
108+
_expressions.Add(BicepSyntax.Value(s));
109+
}
109110
}
110111
}
111112

0 commit comments

Comments
 (0)