GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Clean up ShellExecute code to use the .NET Core implementation by daxian-dbw · Pull Request #4523 · PowerShell/PowerShell Conversation
|
|
|
||
| // -Verb and -WindowStyle are not supported on non-Windows platforms as well as Windows headless SKUs | ||
| if (_isOnFullWinSku) | ||
| if (Platform.IsWindowsDesktop) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe cache the value in a variable instead of looking it up twice in the same method.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Updated the code to cache the value in Platform.IsWindowsDesktop.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Dongbo Wang (@daxian-dbw) This does not seem to be fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The value is cached in a static field in Platform.IsWindowsDesktop property.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| #else | ||
| ShellExecuteHelper.Start(invokeProcess.StartInfo); | ||
| // Use ShellExecute when it's not a headless SKU | ||
| invokeProcess.StartInfo.UseShellExecute = !Platform.IsNanoServer && !Platform.IsIoT; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we use Platform.IsWindowsDesktop here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will update the code.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| xdg-mime default nativeCommandProcessor.desktop text/plain | ||
| } | ||
| } | ||
| elseif ($IsWindows) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can use Platform.IsWindowsDesktop if it is made public.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good point. Will update.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| & $dllFile | ||
| throw "No Exception!" | ||
| } catch { | ||
| $_.FullyQualifiedErrorId | should be "NativeCommandFailed" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use ShouldBeErroId. Example :
| { & $testdrive/test.ps1 } | ShouldBeErrorId "Argument" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
|
|
||
| internal static bool IsWindowsDesktop |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should we consider making this public? This will be very useful in tests.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| & $TestFile | ||
| $startTime = Get-Date | ||
| # It may take time for handler to start | ||
| while (((Get-Date) - $startTime).TotalSeconds -lt 10 -and (-not (Test-Path "$HOME/nativeCommandProcessor.Success"))) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Polling for a file can be a common pattern. Consider implementing a generic file watcher function in HelpersCommon.psm1
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable. Opened #4524. Will address in a separate PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1ffa36b to
7d375eb
Compare
| Get-Process -Name notepad | Stop-Process -Force | ||
| Invoke-Item -Path $notepad | ||
| $notepadProcess = Get-Process -Name notepad | ||
| $notepadProcess.Name | Should Be notepad |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe use quotas - "notepad"?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
OK, will update.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Invoke-Item -Path $notepad | ||
| $notepadProcess = Get-Process -Name notepad | ||
| $notepadProcess.Name | Should Be notepad | ||
| Stop-Process -InputObject $notepadProcess |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should we move this in AfterAll?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it should stay here, as it's specific to this test when running on full desktop.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't like commands after Should 😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There are 2 failures in AppVeyor feature test run and both are related to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Aditya Patwardhan (@adityapatwardhan) Ilya (@iSazonov) Your comments have been addressed. Please take another look. Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| // -Verb and -WindowStyle are not supported on non-Windows platforms as well as Windows headless SKUs | ||
| if (_isOnFullWinSku) | ||
| if (Platform.IsWindowsDesktop) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Dongbo Wang (@daxian-dbw) This does not seem to be fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Since the PR is a cleanup we could add fix - we use "UseShellExecute" constant three times in Process.cs and could move it to private static variable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| catch (Exception) | ||
| { | ||
| // Do the cleanup and rethrow the exception |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It is obvious comment. Please add in the comment why we do this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed. More comment added to Cleanup() to explain what we are cleaning up.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| this.Command.Context.EngineHostInterface.NotifyEndApplication(); | ||
| } | ||
| // Do the clean up... | ||
| // Do the cleanup... |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Again obvious comment. Please remove or enhance.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| #else | ||
| if (Platform.IsNanoServer) | ||
| return false; | ||
| if (!Platform.IsWindowsDesktop) { return false; } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Formatting - Can we use the one line pattern for if?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, as long as the if block is a single simple statement like this one.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Get-Process -Name notepad | Stop-Process -Force | ||
| Invoke-Item -Path $notepad | ||
| $notepadProcess = Get-Process -Name notepad | ||
| $notepadProcess.Name | Should Be "notepad" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We use "notepad" in three lines (66, 68, 69 and maybe 65) so maybe use a variable?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Closed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The "Default" constant string is used in 9 places and should be cleaned too (change to const variable, instead of static). But I think they should be in separate PRs as they will introduce too many diffs and make it hard to see the focus of this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
LGTM. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Aditya Patwardhan (@adityapatwardhan) Thanks for the review! Aditya, can you please merge this PR? My follow-up work on the file watcher test helper needs to update the tests in this PR (#4524). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Shell#4523) * Clean up ShellExecuteHelper and enable ShellExecute in NativeCommandProcessor * Minor fix * [Feature] Fix NativeCommandProcessor to clean up in case an exception is thron * [Feature] Update tests * [Feature] Address comments * address one more comment * Address some more comments
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.