| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
LGTM with minor comment
Sorry, something went wrong.
|
|
||
| return enumVariant != null ? new ComEnumerator(enumVariant) : null; | ||
| } | ||
| } |
There was a problem hiding this comment.
Add extra line at the end.
Sorry, something went wrong.
There was a problem hiding this comment.
Added a new line.
Sorry, something went wrong.
|
I should use Measure-Object in the test but instead used Measure-Command, which pops for mandatory parameter input and thus caused the build to hang. It's fixed now. |
Sorry, something went wrong.
|
|
||
| internal static ComEnumerator Create(object comObject) | ||
| { | ||
| if (!comObject.GetType().IsCOMObject) { return null; } |
There was a problem hiding this comment.
Should we check comObject != null ?
Sorry, something went wrong.
There was a problem hiding this comment.
Will add a null check here.
Sorry, something went wrong.
There was a problem hiding this comment.
Closed.
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| return enumVariant != null ? new ComEnumerator(enumVariant) : null; |
There was a problem hiding this comment.
Maybe use else to exclude duplicate check with line 399?
Sorry, something went wrong.
There was a problem hiding this comment.
It's not a duplicate check, line 416 could make enumVariant not null or continue to be null.
Sorry, something went wrong.
There was a problem hiding this comment.
I meant that here slightly hidden logic. Maybe:
// if IEnumVARIANT interface
var enumVariant = comObject as COM.IEnumVARIANT;
if (enumVariant != null)
{
return new ComEnumerator(enumVariant);
}
// if a collection
var enumerable = comObject as IEnumerable;
...
enumVariant = result as COM.IEnumVARIANT;
if (enumVariant != null)
{
return new ComEnumerator(enumVariant);
}
...
return null; // any warnings for users?
Sorry, something went wrong.
There was a problem hiding this comment.
This is more of a coding style rather than an issue that needs to be corrected.
Sorry, something went wrong.
There was a problem hiding this comment.
Wait, I see your point now -- there will be one more null check if the COM object is already an enum variant. Will update the code.
Sorry, something went wrong.
There was a problem hiding this comment.
Code updated.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for understanding and sorry that I was unclear.
Sorry, something went wrong.
| Describe 'Basic COM Tests' -Tags "CI" { | ||
| It "Should enumerate ShellWindows" { | ||
| $shell = New-Object -ComObject "Shell.Application" | ||
| $windows = $shell.Windows() |
There was a problem hiding this comment.
Is it work on Core and IoT?
Sorry, something went wrong.
There was a problem hiding this comment.
Good catch. NanoServer and IoT don't have the shell, so these tests don't apply. Will update.
Sorry, something went wrong.
|
Ilya (@iSazonov) I have addressed your comments. Please take another look. Thanks! |
Sorry, something went wrong.
We have new commits - please take another look.
|
Jason Shirk (@lzybkr) Aditya Patwardhan (@adityapatwardhan) We have new commits - please take another look. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| } | ||
| } | ||
|
|
||
| return enumVariant != null ? new ComEnumerator(enumVariant) : null; |
There was a problem hiding this comment.
I meant that here slightly hidden logic. Maybe:
// if IEnumVARIANT interface
var enumVariant = comObject as COM.IEnumVARIANT;
if (enumVariant != null)
{
return new ComEnumerator(enumVariant);
}
// if a collection
var enumerable = comObject as IEnumerable;
...
enumVariant = result as COM.IEnumVARIANT;
if (enumVariant != null)
{
return new ComEnumerator(enumVariant);
}
...
return null; // any warnings for users?
Sorry, something went wrong.
| } | ||
| catch (Exception) | ||
| { | ||
| /* Catch all exception. */ |
There was a problem hiding this comment.
Obvious comment and typo (exception -> exceptions). Catch all exceptions - why? Please enhance the comment or remove.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Sorry, something went wrong.
|
Jason Shirk (@lzybkr) Can you approve? |
Sorry, something went wrong.
|
Ilya (@iSazonov) Jason probably doesn't have time to come back and approve it again, so it's up to the maintainer's judgment to see if it's necessary for reviewers who had approved to approve again. There are some guidelines you can use, for example:
Certainly, you will get your own guidelines as you become more experienced in this role. |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) Thank you for the helpful comment! In this case, it's more of a courtesy - I have to show respect and ask him after I formally dismissed his approval. |
Sorry, something went wrong.
|
Ilya (@iSazonov) Another related comment. I usually don't dismiss a reviewer's approval unless the PR needs some fundamental changes (e.g. design flaw, logic changes and etc.). If the following-up changes are touch-ups or minor fixes (like typo, a null condition check, test fix-up), I think it's fine to keep the previous approval, and once the minor issues are addressed, you can approve the PR and merge it. |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) I wonder why CI AppVeyor failed? |
Sorry, something went wrong.
|
I have investigated the failure, it actually a bug in Binder, more specifically at here, the restriction generated in the call to this.DeferForPSObject doesn't respect the fact that the baseobject needs to be a COM object. A repro would be: $shell = New-Object -ComObject "Shell.Application"
$folder = $shell.Namespace("F:\tmp")
#$item = $folder.Items().Item(0)
$item = $folder.Items() | select -Last 1
$item.Name
$members = new-object System.Collections.ObjectModel.Collection[System.Management.Automation.PSMemberInfo]
$n=new-object Management.Automation.PSNoteProperty a,1
$members.Add($n)
$r=add-member -InputObject a -MemberType MemberSet -Name Name -Value $members -passthru
$r.Name.a
The $r.Name.a is supposed to return 1. If you run the lower part first then upper part, then all work fine. I cannot open an issue until this PR is merged because the repro requires enumerating a COM collection. |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) Maybe made two commits for code and tests before rebase and merge? |
Sorry, something went wrong.
|
Ilya (@iSazonov) Please just choose 'Squash and merge'. It's a simple fix and there is no need to keep history commits. |
Sorry, something went wrong.
|
A follow-up of the binder bug: |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) Merged. |
Sorry, something went wrong.
|
Ilya (@iSazonov) Thank you for the review and good work as a maintainer 😄 Here are some of my experiences to choose among Squash and merge, Rebase and merge and Create a merge commit:
As you can see from the main branch history, most of time we use (and prefer to) squash and merge. As for what is a simple/complex/non-trivial fix/work, it's hard to describe but you will have your judgement call as you gain more expeirences. |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) Thanks for sharing your experience! |
Sorry, something went wrong.
Make PowerShell Core enumerate COM collections
| Back | FazBrowse Home | New Git URL |
Fix #3775
'GetEnumerator()' is not supported on COM collections in .NET Core (see https://github.com/dotnet/corefx/issues/19731), so we need to have our own implementation to enumerate COM collections.