-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make PowerShell Core enumerate COM collections #4553
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
15d6ce2
Make PowerShell Core enumerate COM collections
daxian-dbw 3ee11d8
Add tests
daxian-dbw d49de32
Skip COM tests on Unix
daxian-dbw 4d6e365
Add a new line to the end of ComUtil.cs
daxian-dbw 3b53c0f
Fix failing test
daxian-dbw 5490f76
Address 2 more comments
daxian-dbw 1d0ce46
Add more comment for the catch-all-exception block
daxian-dbw 50ae76c
Add comment block for the method
daxian-dbw 864a58d
Address another comment and add one more test
daxian-dbw 7a06a82
Replace shell-windows tests with shell-folder tests
daxian-dbw 459518d
Minor change in test
daxian-dbw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
|
|
||
| try { | ||
| $defaultParamValues = $PSdefaultParameterValues.Clone() | ||
| $PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop | ||
|
|
||
| Describe 'Basic COM Tests' -Tags "CI" { | ||
| BeforeAll { | ||
| $null = New-Item -Path $TESTDRIVE/file1 -ItemType File | ||
| $null = New-Item -Path $TESTDRIVE/file2 -ItemType File | ||
| $null = New-Item -Path $TESTDRIVE/file3 -ItemType File | ||
| } | ||
|
|
||
| It "Should enumerate files from a folder" { | ||
| $shell = New-Object -ComObject "Shell.Application" | ||
| $folder = $shell.Namespace("$TESTDRIVE") | ||
| $items = $folder.Items() | ||
|
|
||
| ## $items is a collection of all items belong to the folder, and it should be enumerated. | ||
| $items | Measure-Object | ForEach-Object Count | Should Be $items.Count | ||
| } | ||
|
|
||
| It "Should enumerate IEnumVariant interface object without exception" { | ||
| $shell = New-Object -ComObject "Shell.Application" | ||
| $folder = $shell.Namespace("$TESTDRIVE") | ||
| $items = $folder.Items() | ||
|
|
||
| ## $enumVariant is an IEnumVariant interface of all items belong to the folder, and it should be enumerated. | ||
| $enumVariant = $items._NewEnum() | ||
| $enumVariant | Measure-Object | ForEach-Object Count | Should Be $items.Count | ||
| } | ||
|
|
||
| It "Should enumerate drives" { | ||
| $fileSystem = New-Object -ComObject scripting.filesystemobject | ||
| $drives = $fileSystem.Drives | ||
|
|
||
| ## $drives is a read-only collection of all available drives, and it should be enumerated. | ||
| $drives | Measure-Object | ForEach-Object Count | Should Be $drives.Count | ||
| ## $element should be the first drive from the enumeration. It shouldn't be the same as $drives, | ||
| ## but it should be the same as '$drives.Item($element.DriveLetter)' | ||
| $element = $drives | Select-Object -First 1 | ||
| [System.Object]::ReferenceEquals($element, $drives) | Should Be $false | ||
| $element | Should Be $drives.Item($element.DriveLetter) | ||
| } | ||
| } | ||
|
|
||
| } finally { | ||
| $global:PSdefaultParameterValues = $defaultParamValues | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.