-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Exclude -Comobject parameter of New-Object cmdlet on unsupported platforms #4922
Conversation
c94c454
to
baf780f
Compare
else // Parameterset -Com | ||
{ | ||
if (!Platform.IsWindowsDesktop) | ||
{ | ||
Exception exc = new NotSupportedException(NewObjectStrings.ComObjectPlatformIsNotSupported); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COM works on NanoServer as well, as long as it has a workable COM component
PS: the COM support was enabled when powershell core was still NanoServer powershell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I based on current tests. 😕
So should we exclude the parameter only on Unix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The COM components we use in our tests are not available in NanoServer and IoT.
Yes, we should exclude the parameter only for Unix plats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "Shell.Application" work on NanoServer and IoT? can I use this in a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell itself is not available on NanoServer and IoT. You can use it as a test, but just follow the existing tests in test\powershell\engine\COM
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't we targeting our test to NanoServer and IoT?
@@ -465,7 +474,7 @@ private object CreateComObject() | |||
return null; | |||
} | |||
} | |||
|
|||
#endif | |||
#endregion Com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the entire "com" region here should be under the #if !UNIX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
50a3c63
to
84f7a6c
Compare
84f7a6c
to
2af645b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if ($IsLinux -or $IsMacOs ) { | ||
{ New-Object -ComObject "Shell.Application" } | ShouldBeErrorId "NamedParameterNotFound,Microsoft.PowerShell.Commands.NewObjectCommand" | ||
} else { | ||
{ New-Object -ComObject "Shell.Application" } | Should Not Throw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail when running tests on NanoServer ... Maybe change it to check if New-Object
has the parameter ComObject
instead of creating the Shell.Application
object?
$s = gcm New-Object
$s.Parameters.ContainsKey("ComObject")
True
Fix #4897.
New-Object -Comobject is not supported on
NotSupportedException
exception.First commit reformat test file.