Skip to content
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

Support single-line objects/arrays #586

Closed
alex-frankel opened this issue Sep 30, 2020 · 8 comments · Fixed by #5830
Closed

Support single-line objects/arrays #586

alex-frankel opened this issue Sep 30, 2020 · 8 comments · Fixed by #5830
Labels
enhancement New feature or request revisit

Comments

@alex-frankel
Copy link
Collaborator

This could be implemented by #498, but the other option is to somehow do this without ,

@alex-frankel alex-frankel added the enhancement New feature or request label Sep 30, 2020
@ghost ghost added the Needs: Triage 🔍 label Sep 30, 2020
@alex-frankel alex-frankel added this to the v0.3 milestone Oct 1, 2020
@benc-uk
Copy link

benc-uk commented Nov 5, 2020

Please... especially when LoC and verbosity are some of the advantages of Bicep

By single line assume we mean allowing something like

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16' ]
    }

@TSunny007 TSunny007 self-assigned this Dec 12, 2020
@TSunny007 TSunny007 removed their assignment Jan 4, 2021
@ChristopherGLewis
Copy link
Contributor

One comment I'd have is that as you start to think about single line objects, consider what would happen if you have a bicep linter and your linter converts from single-line to multi-line.

With single line, these would be the same in bicep:

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16', '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16'
        '10.1.0.0/16'
      ]
    }

However, a simple code formatting tool may have issues converting between the two since there's not just a white space change.
The linting tool would have to know that the comma is needed in single-line, but not needed in multi-line.

Give that changing lines involved more than just white-space, my suggestion is that you either support just a white-space separator or support both white-space and comma.

This would mean that this would be valid syntax:

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16' '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16'
        '10.1.0.0/16'
      ]
    }

Along with

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16', '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16',
        '10.1.0.0/16'
      ]
    }

Personally, I support the second syntax (commas) because then each object is a (semi) valid JSON primitive. It would be super nice if it was a valid primitive, but that would require supporting real quote characters :-)

@alex-frankel alex-frankel changed the title Support single-line objects arrays Support single-line objects/arrays Feb 23, 2021
@alex-frankel alex-frankel modified the milestones: v0.3, Committed Backlog Mar 8, 2021
@dciborow
Copy link
Collaborator

dciborow commented Aug 27, 2021

An alternative could be simply providing a folding option in VS Code, which also shows the "folded" contents in a csv list.

Here is an example of how PyCharm does this folding docstrings.
image

image

@MariusStorhaug
Copy link

MariusStorhaug commented Mar 5, 2022

Seems the same applies for the contains() function.

Instead of writing

var supportsBlobService = storageAccountKind == 'BlockBlobStorage' || storageAccountKind == 'BlobStorage' || storageAccountKind == 'StorageV2' || storageAccountKind == 'Storage'

I would rather be able to write:

var supportsBlobService = contains(['BlockBlobStorage', 'BlobStorage', 'StorageV2', 'Storage'], storageAccountKind)

@ChristopherGLewis
Copy link
Contributor

I get around the || with another var and a contains:

param subnetName string

var specialSubnet = [
  'GatewaySubnet'
  'AzureBastionSubnet'
  'AzureFirewallSubnet'
]

var isSpecial = contains(specialSubnet, subnetName )

@miqm
Copy link
Collaborator

miqm commented Jun 20, 2022

@anthony-c-martin - we can probably remove this from the limitation list in Readme.md :)

@HenrikSommer-Energinet
Copy link

@anthony-c-martin
Copy link
Member

@HenrikSommer-eng, thanks for reminding me - I have raised MicrosoftDocs/azure-docs#95371 for our docs team to pick up.

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request revisit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants