Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Oct 3, 2017

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:

  • removed sta/mta switches and code
  • removed psconsolefile switch and code
  • removed importsystemmodules switch and code
  • removed font changing code
  • merged #if CORECLR code

Fix #4987
Fix #4350

Copy link
Collaborator

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?

Copy link
Member Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Closed.

Copy link
Contributor

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);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, will change

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove

Copy link
Contributor

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)

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, will remove

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change

Copy link
Contributor

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.).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove

@SteveL-MSFT SteveL-MSFT force-pushed the remove-apartmentstate branch from e7369ed to 99559fe Compare October 6, 2017 20:14
Copy link
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 7, 2017

@SteveL-MSFT Is the PR ready to merge?

@SteveL-MSFT SteveL-MSFT added Breaking-Change breaking change that may affect users Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Oct 7, 2017
@SteveL-MSFT
Copy link
Member Author

@iSazonov since this is a breaking change (from Windows PowerShell), let me get an ack from @PowerShell/powershell-committee

Copy link
Contributor

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.

Copy link
Member Author

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...

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Member Author

@SteveL-MSFT SteveL-MSFT Oct 10, 2017

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?

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIll fix!

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@lzybkr lzybkr left a 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.

@SteveL-MSFT SteveL-MSFT force-pushed the remove-apartmentstate branch from ca8d4a8 to 940d58d Compare October 10, 2017 00:36
@SteveL-MSFT
Copy link
Member Author

@lzybkr cleaned up the commits to be distinct groups of work

Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove

@SteveL-MSFT
Copy link
Member Author

@lzybkr I believe your feedback has been addressed, can you take another look? Thanks

@SteveL-MSFT
Copy link
Member Author

SteveL-MSFT commented Oct 12, 2017

@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.

@SteveL-MSFT SteveL-MSFT added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Oct 12, 2017
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
removed code to show a GUI prompt for credentials as PSCore6 prompts in console
@SteveL-MSFT SteveL-MSFT force-pushed the remove-apartmentstate branch from 7652075 to 6ca5d51 Compare October 12, 2017 17:19
@SteveL-MSFT
Copy link
Member Author

I believe all feedback has been addressed. @lzybkr can you take another look when you get a chance? Thanks.

@lzybkr
Copy link
Contributor

lzybkr commented Oct 16, 2017

    {

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)

@SteveL-MSFT
Copy link
Member Author

@lzybkr removed that method

@iSazonov
Copy link
Collaborator

@SteveL-MSFT Is the PR ready to merge?

@SteveL-MSFT
Copy link
Member Author

@iSazonov yes, please!

@iSazonov
Copy link
Collaborator

It seems here we should preserve commits by create a merge commit?

@SteveL-MSFT
Copy link
Member Author

@iSazonov yes, I believe that is the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking-Change breaking change that may affect users Committee-Reviewed PS-Committee has reviewed this and made a decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants