Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix how COM objects are enumerated#11795

Merged
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
daxian-dbw:comdaxian-dbw/PowerShell:comCopy head branch name to clipboard
Feb 10, 2020
Merged

Fix how COM objects are enumerated#11795
adityapatwardhan merged 3 commits into
PowerShell:masterPowerShell/PowerShell:masterfrom
daxian-dbw:comdaxian-dbw/PowerShell:comCopy head branch name to clipboard

Conversation

@daxian-dbw

@daxian-dbw daxian-dbw commented Feb 7, 2020

Copy link
Copy Markdown
Member

PR Summary

Fix #11782

The ComEnumerator was introduced back in early .NET Core 2.0 preview period of time (#4553), because GetEnumerator() didn't work on COM object even if the object can be cast to IEnumerable and .NET Core team said it was by design at the time (dotnet/runtime#21690).
With .NET Core 3.1, GetEnumerator() works on the COM objects that can be cast to IEnumerable 🎉
So we can directly use the .NET Core support to get the enumerator for a COM object that implements IEnumerable.

However, for the COM object that can be cast to IEnumerator, exception is thrown when calling MoveNext() on it.
So we still need the ComEnumerator, but much simplified to just cover the case that the COM object implements COM.IEnumVARIANT interface.

PR Context

PR Checklist

@ghost ghost assigned adityapatwardhan Feb 7, 2020
@daxian-dbw daxian-dbw added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Feb 7, 2020
@daxian-dbw daxian-dbw added this to the GA-consider milestone Feb 7, 2020
$group = [ADSI]"WinNT://./Users,Group"
$members = $group.Invoke('Members')
$names = $members | ForEach-Object { $_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null) }
$names | Should -Not -BeNullOrEmpty

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there any specific names we can validate against that are always expected for this COM object?

@daxian-dbw daxian-dbw Feb 7, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess 'Authenticated Users' and 'INTERACTIVE'. Let me update and test it out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Test updated.

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Feb 7, 2020
Comment thread src/System.Management.Automation/engine/COM/ComUtil.cs

@PaulHigin PaulHigin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread src/System.Management.Automation/engine/COM/ComUtil.cs
@adityapatwardhan

Copy link
Copy Markdown
Member

@SteveL-MSFT please update your review

@adityapatwardhan adityapatwardhan merged commit 35c7b78 into PowerShell:master Feb 10, 2020
@daxian-dbw daxian-dbw deleted the com branch February 10, 2020 23:52
@TravisEz13 TravisEz13 modified the milestones: GA-consider, GA-approved, 7.0.0 Feb 11, 2020
adityapatwardhan pushed a commit to adityapatwardhan/PowerShell that referenced this pull request Feb 18, 2020
@ghost

ghost commented Feb 21, 2020

Copy link
Copy Markdown

🎉v7.0.0-rc.3 has been released which incorporates this pull request.:tada:

Handy links:

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

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code OK on V5.1 does not run on V7.0.0RC2

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.