Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Remove quotes in HashTables Keys when possible #3

Closed

Description

@JohnLeyva

First of all, very nice work

it will be nice if hashtables keys are not quoted when it is not necessary in order to generate cleaner output.

So it can generate output like the following

@{
  ModuleVersion = '1.0.0.95'
  CompanyName = 'Unknown'
  RequiredModules =
    @{
      ModuleName = 'Microsoft.PowerShell.Utility'
      GUID = '1da87e53-152b-403e-98dc-74d7b4d63d59'
      ModuleVersion = '7.0.0.0'
    },
    @{
      ModuleName = 'YYYYYY'
      GUID = 'AAAAAAAAAAAA'
      ModuleVersion = '1.0.0.94'
    },
  FunctionsToExport = 'XXX'
  CmdletsToExport = @()
  VariablesToExport = '*'
  AliasesToExport = @()
}

Activity

  1. iRon7 commented on Jun 19, 2020

    @iRon7
    Owner

    Thanks for raising this issue.
    I am actually not sure about the correct direction for this. I have searched for some guidelines or best practice for this but couldn't find a clear definition. Therefore I have logged an PowerShellPracticeAndStyle issue: Unquoted strings #146.
    Depending on the feedback, I will try to implement your request

  2. added
    enhancement
    on Jun 19, 2020
  3. mklement0 commented on Oct 17, 2020

    @mklement0

    @JohnLeyva, the rules behind whether string keys need quoting and how to determine the need for quoting programmatically is covered in this SO post (@iRon7 himself asked the question and contributed to one of the answers).

  4. iRon7 commented on Oct 17, 2020

    @iRon7
    Owner

    @mklement0, thanks for the comments, I am currently working on a new version which includes this request, I will release this version soon.

  5. self-assigned this
    on Oct 22, 2020
  6. iRon7 commented on Nov 1, 2020

    @iRon7
    Owner

    I have published a new version (3.3.6) that leaves hash table keys unquoted where possible.
    To define which keys can be left unquoted, the regular expression

    -cmatch '^[\p{L}\p{Lt}\p{Lm}\p{Lo}_][\p{L}\p{Lt}\p{Lm}\p{Lo}\p{Nd}_]*$'

    in the Unquoted key rules and best practices answer from @mklement is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions