-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Clean up console code #4995
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
Clean up console code #4995
Conversation
9bc0001 to
183a164
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.
Do we use first parameter? Can we remove it?
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 first param is RunspaceConfiguration. It's being removed as part of #4942
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.
Thanks!
Closed.
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.
Since this method now only returns OEM_CHARSET, I think we should remove it and just set this value in the one place it is called (and add a comment as to why we use a fixed char set).
private static bool IsAvailableFarEastCodePage(uint codePage)
{
const uint OEM_CHARSET = 255;
return IsAnyDBCSCharSet(OEM_CHARSET);
}
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.
Makes sense, will change
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.
It seems like we should also remove NativeMethods.GetStdHandle() declaration since it is only used here.
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.
Will remove
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.
You should verify the hang doesn't repro in Core. It looks like I did not add a test (probably because the simplest repro required installing Ruby on Windows), but with all the changes in the CLR, it seems prudent to verify we still don't need this code before removing.
In reply to: 143062595 [](ancestors = 143062595)
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 code wasn't being used since it's in the #else statement.
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.
@SteveL-MSFT - I know. That doesn't change my feedback. The code was originally added for Full CLR, but with the significant work that went into Core CLR 2.0, I think we need to revisit the issue in case the code is needed in Core now.
If you remove this code, you'll lose the context, and if it's still an issue, investigation will be much more difficult because nobody will remember the change I made that introduced the problem in the first place.
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.
Since we now always prompt using console we can get rid of this method since it will never be used.
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.
PromptForCredential() can be simplified since it now always prompts from console. Also we can remove the HostUtilities.CredUIPromptForCredential() method since it also will no longer be used.
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.
Agree, will remove
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.
We can remove this method and simply the conditional code in the two places it is called.
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.
Will change
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.
We should remove all unused NativeMethods declarations (TranslateCharsetInfo, GetConsoleWindow, etc.).
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.
Will remove
e7369ed to
99559fe
Compare
PaulHigin
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
|
@SteveL-MSFT Is the PR ready to merge? |
|
@iSazonov since this is a breaking change (from Windows PowerShell), let me get an ack from @PowerShell/powershell-committee |
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.
As I understand this code - somebody is screen scraping, there is a wide character (2 cells), and the font in use can't render the character, so conhost used 1 cell.
This seems like an extreme corner case, but the code seems correct to me and I don't any value in removing the code.
Also - the PR description should be improved - there is no link to an issue providing more detail.
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 the PR description as I did not originally intend for this PR to be so extensive. I simply started down the path of removing the -mta/-sta code since we weren't using it and then noticed the ConsoleFile code which wasn't being used, then the Font code... ugh...
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 think we still need LengthInBufferCells - but if you want to make a simplifying assumption when you can't know the font, you can use this code from PSReadline.
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 just use the code from PSReadline. I ended up removing all this code as the fundamental assumption in the code is that we are using a specific codePage so all the calculations ended up returning a width of 1 anyways as all the other supporting code only applied to Windows PowerShell.
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 removal intentional? I think if that's not set, we create a new thread every time you execute a new command line.
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.
Will put back the ReuseThread line
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.
@lzybkr Actually, this line was only within the staMode which was not enabled for the user to set. So currently, we use the default which is to use a new thread for each pipeline. Do we want to change this behavior?
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.
staMode = true was the default even if the user couldn't set it, right?
At any rate, I do think we want to reuse the thread.
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.
No, we defaulted to MTA in PSCore
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 see. We defaulted to STA on Windows for many years, so reusing the thread seems preferable.
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.
@SteveL-MSFT - are you putting it back?
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 need to verify something on Windows (was using a Mac for the changes) before I put it back. With my other uber PR to remove apartmentstate all-up, the WSMan provider didn't work correctly.
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.
Looks good on my Windows box, will run through the tests and push the change.
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 wrong, plain and simple.
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.
WIll fix!
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.
Deleting this code makes the comment above very confusing.
It also implies you are introducing a potential security risk.
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.
Will remove the comment since it only applied to the GUI prompt.
lzybkr
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.
There are several distinct changes in this PR, some of which don't feel like "clean up".
I think the commits should be cleaned up with better messages (reset and git add -p) and when merging, we should not squash this PR.
ca8d4a8 to
940d58d
Compare
|
@lzybkr cleaned up the commits to be distinct groups of work |
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.
If I understand correctly - we default to STA and remove the option to use MTA, correct?
Assuming so, this line should probably stay, but I don't quite understand why it's here.
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.
No, we defaulted to MTA and removing option to use STA
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 condition only applies to PSReadline.
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.
will remove
|
@lzybkr I believe your feedback has been addressed, can you take another look? Thanks |
|
@PowerShell/powershell-committee discussed this and was fine with all the changes except for removing the STA code. Resolution is to leave the STA code #ifdef'd out in case we have valid use cases on Windows on the future requiring support. |
removed -importsystemmodules switch from powershell.exe and related code removed -consolefile parameter from powershell.exe and related code
…ndows PowerShell replaced LengthInBufferCells() method with Unicode adapted code from PSReadline
7652075 to
6ca5d51
Compare
|
I believe all feedback has been addressed. @lzybkr can you take another look when you get a chance? Thanks. |
This code is not called anymore, and is a slight variant of the version you added from PSReadLine below (which my version should be fine, it's more recent and has better comments.) :) Refers to: src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs:2736 in 6ca5d51. [](commit_id = 6ca5d51, deletion_comment = False) |
|
@lzybkr removed that method |
|
@SteveL-MSFT Is the PR ready to merge? |
|
@iSazonov yes, please! |
|
It seems here we should preserve commits by create a merge commit? |
|
@iSazonov yes, I believe that is the case |
These are features we haven't been supporting already (for PowerShell Core) and no plans to support as they exist for legacy reasons only for Windows PowerShell:
#if CORECLRcodeFix #4987
Fix #4350