Support WindowStyle without UseShellExecute#82662
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.
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.
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.
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.
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.
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.
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ú <dacantu@microsoft.com>
|
@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
|
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