-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Enable UseShellExecute on all platforms #7198
Conversation
31436bc
to
143ba8e
Compare
143ba8e
to
1fe5fea
Compare
@@ -219,4 +189,26 @@ Describe "Invoke-Item tests on Windows" -Tags "CI","RequireAdminOnWindows" { | |||
Start-Process $testfilepath -Wait | |||
Test-Path $renamedtestfilepath | Should -BeTrue | |||
} | |||
|
|||
It "Should invoke an executable file without error" -Skip:(!$IsWindows) { |
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.
Please clarify why we remove previous all-platform test and add this new for Windows only?
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 previous test expected UseShellExecute to only be available on Windows and the previous code was checking for different behavior on non-Windows. Since I've changed it to only use ShellExecute on non-Windows if the target is not an executable, I should put back this test.
cefd7a9
to
b2a5a6f
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 with minor comment.
//so don't use ShellExecute if arguments are specified | ||
|
||
//Linux relies on `xdg-open` and macOS relies on `open` which behave differently than Windows ShellExecute when running console commands | ||
//as a new console will be opened. So to avoid that, we only use ShellExecute on non-Windows if the filename is not an actual command (like a URI) |
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.
Please add space after //
in comments.
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 was following the existing comments
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.
Yes, I see. But if we continue use CodeFactor we have to fix every code block without following file style.
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'll update this file with whitespace as a separate commit so it doesn't make the overall code review noisy
@@ -428,7 +428,7 @@ internal static bool TryHasExited(Process process) | |||
} | |||
|
|||
#endregion Internal | |||
}//ProcessBaseCommand | |||
} // ProcessBaseCommand |
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 would delete such comments. They are useless in modern IDEs.
@@ -520,7 +520,7 @@ public SwitchParameter IncludeUserName | |||
private bool _includeUserName = false; | |||
|
|||
///<summary> | |||
///To display the modules of a process | |||
/// To display the modules of a process |
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.
Please add final dot.
@@ -530,7 +530,7 @@ public SwitchParameter IncludeUserName | |||
public SwitchParameter Module { get; set; } | |||
|
|||
///<summary> | |||
///To display the fileversioninfo of the main module of a process | |||
/// To display the fileversioninfo of the main module of a process |
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.
Please add final dot.
…nd adding period to end of summaries
@iSazonov did a pass through the comments, removed a bunch of unnecessary ones and added punctuation to the summaries. However, this PR has grown much larger than the original issue. I think in general, we want CodeFactor issues outside of the changes to be a separate PR. |
@SteveL-MSFT I agree that large style fixes we should place in separate PR. A separate style fix commit is suitable for small changes. |
PR Summary
Previously, we limited use of UseShellExecute when starting a new process to only Windows Desktop. However, corefx now supports UseShellExecute (appropriately calling
open
on macOS andxdg-open
on Linux) so we can have consistent code and remove some of the existing redundant code or unnecessary limiting code.There is a bug in corefx where Arguments is passed to the executable used to
ShellExecute
such asopen
on macOS instead of the FileName intended to be started, so don't useShellExecute
if arguments is passed.Also, because of difference in behavior with using
ShellExecute
with console apps compared to Windows where a new console window is opened, we only useShellExecute
ifFileName
doesn't refer to an actual command, like a URL.Fix #5715
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.[feature]
if the change is significant or affects feature tests