Skip to content

Commit

Permalink
InsertResource - correctly strip read-only properties (#15689)
Browse files Browse the repository at this point in the history
Looks like this was inadvertently changed with #13290 (screenshot
below). This PR restores the old behavior:

![image](https://github.com/user-attachments/assets/dba22f2f-45fd-454e-ab6c-9f8fbd09d092)

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15689)
  • Loading branch information
anthony-c-martin authored Nov 26, 2024
1 parent ca3b137 commit 95ede42
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public async Task Insert_resource_command_should_insert_basic_resource()
resource myName 'My.Rp/myTypes@2020-01-01' = {
name: 'myName'
properties: {
readOnlyProp: 'abc'
readWriteProp: 'def'
writeOnlyProp: 'ghi'
int64Prop: 9223372036854775807
Expand Down Expand Up @@ -286,7 +285,6 @@ public async Task Insert_resource_command_should_insert_resource_group()
resource myRg 'Microsoft.Resources/resourceGroups@2020-01-01' = {
name: 'myRg'
properties: {
readOnlyProp: 'abc'
readWriteProp: 'def'
writeOnlyProp: 'ghi'
}
Expand Down Expand Up @@ -359,7 +357,6 @@ public async Task Insert_resource_command_should_insert_child_resource()
resource childName 'My.Rp/myTypes/childType@2020-01-01' = {
name: 'myName/childName'
properties: {
readOnlyProp: 'abc'
readWriteProp: 'def'
writeOnlyProp: 'ghi'
}
Expand Down Expand Up @@ -512,7 +509,6 @@ public async Task Insert_resource_command_should_try_to_fetch_without_apiVersion
resource myName 'My.Rp/myTypes@2020-01-01' = {
name: 'myName'
properties: {
readOnlyProp: 'abc'
readWriteProp: 'def'
writeOnlyProp: 'ghi'
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bicep.LangServer/Handlers/InsertResourceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static CodeReplacement GenerateCodeReplacement(BicepCompiler compiler, R
model => new ReadOnlyPropertyRemovalRewriter(model));

var printerOptions = configuration.Formatting.Data;
var printed = PrettyPrinterV2.PrintValid(program, printerOptions);
var printed = PrettyPrinterV2.PrintValid(bicepFile.ProgramSyntax, printerOptions);

var newline = printerOptions.NewlineKind.ToEscapeSequence();
var newlineCharacters = newline.ToCharArray();
Expand Down

0 comments on commit 95ede42

Please sign in to comment.