Skip to content
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

Code to add WSLProfiles. #1050

Merged
merged 11 commits into from
Jun 7, 2019
Merged

Code to add WSLProfiles. #1050

merged 11 commits into from
Jun 7, 2019

Conversation

JBanks
Copy link
Contributor

@JBanks JBanks commented May 29, 2019

Summary of the Pull Request

This code generates a list of WSL Distributions to be added to the drop down list. It was tested manually with a setup holding a single WSL distribution.

References

PR Checklist

  • Closes Does not detect wsl distro #441
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: Does not detect wsl distro #441

Detailed Description of the Pull Request / Additional comments

While implementing the stream I was getting stuck in a loop inside of the wfstream functions when I ran past the end of the output. None of the wfstream's health functions seemed to be working properly (::rdstate(), ::eof(), etc) so I used peeknamedpipe to get the length and stopped reading from the pipe before this became an issue. I'd like to find a more clean method

src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalApp.vcxproj Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
…moved the try block to the calling function)
@JBanks JBanks marked this pull request as ready for review June 4, 2019 19:39
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

I am OK with this.

I see pros and cons to shelling out to the wsl.exe to get the list of distributions.

On the pro side, you don't have to be responsible for knowing where the distribution information is stored, how it is parsed, or any of that. Especially as it has the potential to change going forward.

On the con side, it feels very hacky to be running another utility and scraping the output it gives because the format of that output now becomes sort of an API or a protocol itself.

Overall, I am fine with this for now because it gets us a step closer to what we want and I'm not sure the other solutions aren't without pitfalls as well. This method is very easy to understand and easy to fix. And if someone has a major qualm, it's not hard to replace the body of the _AppendWslProfiles method with something else.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

I'm largely okay with this, though I kinda want an answer on the icon before I'll sign-off

src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
DWORD exitCode;
if ((GetExitCodeProcess(pi.hProcess, &exitCode) == false) || (exitCode != 0))
{
THROW_HR(E_INVALIDARG);
Copy link
Member

Choose a reason for hiding this comment

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

A non-zero exit code will indicate that there are no distribuitons. This is not an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you rather have this throw something so that it gets logged CATCHLOG()? I'm thinking ERROR_NO_DATA would be descriptive enough as to what's happening.

For the time being, I've changed it to return without error.

src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 6, 2019
…ment variable. Removed incorrect error useage. Removed variable that was not required.
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 6, 2019
@zadjii-msft
Copy link
Member

I think we're all pretty happy with this change, so I'm going to merge it. If anyone has any remaining qualms, lets file follow-up issues

@zadjii-msft zadjii-msft merged commit 31b614d into microsoft:master Jun 7, 2019
@JBanks JBanks deleted the WSLProfiles branch June 10, 2019 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does not detect wsl distro
7 participants