-
Notifications
You must be signed in to change notification settings - Fork 781
fix for bicep issue #15458 #16237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix for bicep issue #15458 #16237
Changes from 1 commit
5dd7d19
a25423b
df3a1b3
eb0673b
1f6df0a
06a4e9e
4bc280e
dea5122
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -97,25 +97,12 @@ private JToken GenerateTemplate(string contentVersion) | |||||||||
{ | ||||||||||
jsonWriter.WritePropertyName(parameterSymbol.Name); | ||||||||||
|
||||||||||
var value = PlaceholderParametersBicepParamWriter.GetValueForParameter(parameterSymbol.DeclaringParameter); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't feel safe to me to depend on this method and then convert from Bicep -> JSON, because it can return invalid Bicep syntax - e.g. here: bicep/src/Bicep.Core/Emit/PlaceholderParametersBicepParamWriter.cs Lines 141 to 144 in eb0673b
My suggestion would probably be to copy the pattern used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is parameterDeclarationSyntax propre to bicep or can also be used by json ? my understanding is that : this.Context.SemanticModel.Root.ParameterDeclarations will be the same whether we are dealing with generating bicep or json file ...am I missing something? the value you pointed out will be handled by the the added if statement you have pointed out with your second comment |
||||||||||
|
||||||||||
jsonWriter.WriteStartObject(); | ||||||||||
switch (parameterSymbol.Type.Name) | ||||||||||
{ | ||||||||||
case "string": | ||||||||||
emitter.EmitProperty("value", ""); | ||||||||||
break; | ||||||||||
case "int": | ||||||||||
emitter.EmitProperty("value", () => jsonWriter.WriteValue(0)); | ||||||||||
break; | ||||||||||
case "bool": | ||||||||||
emitter.EmitProperty("value", () => jsonWriter.WriteValue(false)); | ||||||||||
break; | ||||||||||
case "object": | ||||||||||
emitter.EmitProperty("value", () => { jsonWriter.WriteStartObject(); jsonWriter.WriteEndObject(); }); | ||||||||||
break; | ||||||||||
case "array": | ||||||||||
emitter.EmitProperty("value", () => { jsonWriter.WriteStartArray(); jsonWriter.WriteEndArray(); }); | ||||||||||
break; | ||||||||||
} | ||||||||||
|
||||||||||
emitter.EmitProperty("value", value); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One additional behavior change this will introduce is that a default of param foo {
requiredProperty: string
optionalProperty: string?
} will generate a .bicepparam file of param foo = '' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way to generate .bicepparam should not change. The change is to make .parameters.json consistant with it. Having said that this might be an issue but unrelated to this change |
||||||||||
|
||||||||||
jsonWriter.WriteEndObject(); | ||||||||||
} | ||||||||||
|
||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.