Skip to content

[Ast]/[ScriptBlock].IsEmpty #494

Closed

Description

@StartAutomating

We should add a ScriptProperty to standardize a definition of ScriptBlock AST emptiness (as this is the source of small errors).

Activity

  1. ninmonkey commented on Jul 10, 2023

    @ninmonkey
    Contributor

    Which kinds of empty? Ex:

    • Empty Literal,
    • Empty expression,
    • or whitespace only
    • or empty result?
    • empty [FunctionInfo] verses a [ScriptBlock]

    I tried some conditions that don't touch AST.

    • {} is empty
    • { } is not

    I guess that makes sense - if it's doing ([string]{}).Length .

    Name Value
    IsNullOrEmpty {} True
    IsNullOrEmpty { } False
    IsNullOrWhiteSpace {} True
    IsNullOrWhiteSpace { } True
    IsNullOrEmpty $sb True
    IsNullOrEmpty $sb2 False
    IsNullOrWhiteSpace $sb True
    IsNullOrWhiteSpace $sb2 True
    $sb = {}
    $sb2 = { }
    [ordered]@{
        'IsNullOrEmpty {} '        = [String]::IsNullOrEmpty( {} )
        'IsNullOrEmpty { } '       = [String]::IsNullOrEmpty( { } )
        'IsNullOrWhiteSpace {} '   = [String]::IsNullOrWhiteSpace( {} )
        'IsNullOrWhiteSpace { } '  = [String]::IsNullOrWhiteSpace( { } )
        'IsNullOrEmpty $sb '       = [String]::IsNullOrEmpty( $sb )
        'IsNullOrEmpty $sb2 '      = [String]::IsNullOrEmpty( $sb2 )
        'IsNullOrWhiteSpace $sb '  = [String]::IsNullOrWhiteSpace( $sb )
        'IsNullOrWhiteSpace $sb2 ' = [String]::IsNullOrWhiteSpace( $sb2 )
    }|ft -auto
  2. changed the title [-][ScriptBlock].IsEmpty[/-] [+]`[Ast]`.IsEmpty[/+] on Nov 12, 2023
  3. changed the title [-]`[Ast]`.IsEmpty[/-] [+]`[ScriptBlock]`.IsEmpty[/+] on Nov 18, 2023
  4. changed the title [-]`[ScriptBlock]`.IsEmpty[/-] [+]`[AST]/[ScriptBlock]`.IsEmpty[/+] on Nov 18, 2023
  5. changed the title [-]`[AST]/[ScriptBlock]`.IsEmpty[/-] [+]`[ScriptBlockAst]/[ScriptBlock]`.IsEmpty[/+] on Nov 18, 2023
  6. added a commit that references this issue on Nov 18, 2023
    b9de731
  7. added 9 commits that reference this issue on Nov 18, 2023
    332acfa
    8af7dc7
    22a4522
    49140fc
    6b19b96
    e162c9e
    f14ef3c
    a859c82
    3ab0a0e
  8. changed the title [-]`[ScriptBlockAst]/[ScriptBlock]`.IsEmpty[/-] [+]`[Ast]/[ScriptBlock]`.IsEmpty[/+] on Nov 29, 2023
  9. added a commit that references this issue on Nov 29, 2023
    6e1fcf1
  10. added 6 commits that reference this issue on Nov 29, 2023
    c5d8145
    12a716c
    80f36cd
    929ed5e
    d7a36ff
    846c9a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions