Ignore failure attempting to set console window title#16948
Ignore failure attempting to set console window title#16948iSazonov merged 10 commits intoPowerShell:masterfrom
Conversation
krishnayalavarthi
left a comment
There was a problem hiding this comment.
Looks good to me
5fce629 to
dc03d45
Compare
This comment was marked as outdated.
This comment was marked as outdated.
dc03d45 to
dfc5c76
Compare
iSazonov
left a comment
There was a problem hiding this comment.
LGTM with one style comment.
There was a problem hiding this comment.
Our style:
| private static bool dontSetConsoleWindowTitle; | |
| private static bool s_dontSetConsoleWindowTitle; |
There was a problem hiding this comment.
looks like the convention in the codebase is not an s_, but pascal casing instead of camel
There was a problem hiding this comment.
codefactor wants to start with lowercase, so changing back to lowercase but not updating rest of codebase.
There was a problem hiding this comment.
@SteveL-MSFT Please look our guidelines we follow for years https://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/coding-guidelines.md#naming-conventions
Use camelCase to name internal and private fields and use readonly where possible. Prefix instance fields with , static fields with s and thread static fields with t. When used on static fields, readonly should come after static (i.e. static readonly not readonly static).
This says us to use s_dontSetConsoleWindowTitle
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |

PR Summary
Reported by a partner that they are using PowerShell console host in automation where there is no terminal window and SetConsoleWindowTitle call fails and the console host exits. Since this is a useful, but decorative feature, we should handle this gracefully by ignoring the Win32 API error and not attempt to set the window title subsequent times.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).