-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Support WindowStyle without UseShellExecute #82662
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
Conversation
Supports specifying a custom ProcessStartInfo.WindowStyle without having to use UseShellExecute. Fix dotnet#81681
This comment was marked as resolved.
This comment was marked as resolved.
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process Issue DetailsSupports specifying a custom ProcessStartInfo.WindowStyle without having to use UseShellExecute. Fix #81681
|
| startupInfo.dwFlags = Interop.Advapi32.StartupInfoOptions.STARTF_USESTDHANDLES; | ||
| } | ||
|
|
||
| if (startInfo.WindowStyle != ProcessWindowStyle.Normal) |
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.
Is this meant to avoid a breaking change in the default path? Maybe it is a breaking change worth taking.
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.
Actually, the current behavior looks just like as if we were using ProcessWindowStyle.Normal. So, we can safely map ProcessWindowStyle.Normal => SW_SHOWNORMAL.
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.
So specifically this is done to preserve the existing behaviour where ProcessWindowStyle.Normal then no wShowWindow value is set alongside the STARTF_USESHOWWINDOW flag that tells Windows to use the value for wShowWindow. I'm not confident that explicitly setting the normal window style is the same as not setting it at all which is what Normal currently means so I kept it out. I can change the code so it always just sets this value alongside STARTF_USESHOWWINDOW if that's your wish but I was aiming for behaviour that was as close to what it was today.
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 is done to preserve the existing behaviour where ProcessWindowStyle.Normal then no wShowWindow value is set alongside the STARTF_USESHOWWINDOW flag.
@iSazonov would your scenario still be covered?
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.
PowerShell always sets the window so it would technically be a behaviour change on their end. It really depends on whether dotnet wants to be the one to change the behaviour or let PowerShell do it.
It would make sense for dotnet to align to the same behaviour as UseShellExecute = true but I'm just not confident enough to say whether this really matters or not.
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.
Let's keep it this way to avoid the breaking change. We can change it later based on user feedback ie: if someone needs this flag to be set for a specific use case.
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs
Show resolved
Hide resolved
Co-authored-by: David Cantú <[email protected]>
|
@jozkee thanks for the review and suggestions. I've pushed a new commit that implements them. The only thing I held off was the still unresolved comment around always setting |
src/libraries/System.Diagnostics.Process/tests/ProcessStartInfoTests.Windows.cs
Outdated
Show resolved
Hide resolved
jozkee
left a comment
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, thanks @jborean93.
|
Thanks @jozkee for your help in fixing this. |
|
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
|
Breaking change doc created dotnet/docs#37739 |
Supports specifying a custom ProcessStartInfo.WindowStyle without having to use UseShellExecute.
Fix #81681