Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Count and Length properties to [PSCustomobject]#5745

Merged
iSazonov merged 2 commits intoPowerShell:masterfrom
iSazonov:pscustomobject-count
Dec 28, 2017
Merged

Add Count and Length properties to [PSCustomobject]#5745
iSazonov merged 2 commits intoPowerShell:masterfrom
iSazonov:pscustomobject-count

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Dec 26, 2017

PR Summary

Related #3671

  • Add Count and Length properties to [PSCustomobject].
    Now following works with singletons and returns 1:
    ([pscustomobject] @{ foo = 'bar' }).Count
    ([pscustomobject] @{ foo = 'bar' }).Length
  • Add tests

PR Checklist

Note: Please mark anything not applicable to this PR NA.

@iSazonov iSazonov force-pushed the pscustomobject-count branch from b927644 to 51b2a00 Compare December 26, 2017 13:38
(10).Length | Should Be 1

("a").Count | Should Be 1
("a").Length | Should Be 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Length property exists for strings, so this isn't (shouldn't be) testing singletons.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

([psobject] @{ foo = 'bar' }).Length | Should Be 1

([pscustomobject] @{ foo = 'bar' }).Count | Should Be 1
([pscustomobject] @{ foo = 'bar' }).Length | Should Be 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also test when a pscustomobject has a count or length property to make sure we return the correct value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@lzybkr lzybkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved w/ a couple test suggestions.

@iSazonov iSazonov self-assigned this Dec 28, 2017
@iSazonov iSazonov merged commit 7257404 into PowerShell:master Dec 28, 2017
@iSazonov iSazonov deleted the pscustomobject-count branch December 28, 2017 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants