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

Replace ExpandEnvironmentStrings double calling with wil helper #3198

Merged
merged 1 commit into from
Oct 15, 2019

Conversation

skyline75489
Copy link
Collaborator

Summary of the Pull Request

References

#2097

PR Checklist

  • Closes use wil::ExpandEnvironmentStrings where possible #2097

  • 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: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@@ -67,7 +65,7 @@ void CanaryTests::LaunchV1Console()

wil::unique_process_information ProcessInformation;
VERIFY_WIN32_BOOL_SUCCEEDED(CreateProcessW(NULL,
CmdLineMutable.get(),
const_cast<LPWSTR>(CmdLine.c_str()),
Copy link
Contributor

Choose a reason for hiding this comment

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

So this one should definitely use .data() -- CreateProcessW requires a mutable string (!) and since data is the mutable variety of c_str, it's a better fit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A mutable string, huh. That's not what I'd expected. You learn something everyday.

// Call create process
wil::unique_process_information ProcessInformation;
RETURN_IF_WIN32_BOOL_FALSE(CreateProcessW(NULL,
CmdLineMutable.get(),
const_cast<LPWSTR>(cmdLine.c_str()),
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Copy link
Contributor

Choose a reason for hiding this comment

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

and, bonus, no need for a const_cast!

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 15, 2019
Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

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

Love it! One note: I just realized that you use rebase and force push. I love that too, however(!), it doesn't generate an e-mail when you submit a new iteration. Would you mind commenting to let us know that you've got another iteration ready?

I know I've missed a couple of your pull requests because of that 😄

@skyline75489
Copy link
Collaborator Author

@DHowett-MSFT I didn't realize force-push doesn't generate email notification till now. Thanks for the heads up

// Call create process
wil::unique_process_information ProcessInformation;
RETURN_IF_WIN32_BOOL_FALSE(CreateProcessW(NULL,
CmdLineMutable.get(),
cmdLine.data(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the way, should this be capital or not? In the aspect of modern C++, I'd say cmdLine is better.

Copy link
Member

Choose a reason for hiding this comment

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

Personally, I like cmdLine more

// Call create process
wil::unique_process_information ProcessInformation;
RETURN_IF_WIN32_BOOL_FALSE(CreateProcessW(NULL,
CmdLineMutable.get(),
cmdLine.data(),
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I like cmdLine more

@carlos-zamora carlos-zamora added the Needs-Second It's a PR that needs another sign-off label Oct 15, 2019
@ghost ghost requested review from zadjii-msft and miniksa October 15, 2019 17:57
@DHowett-MSFT DHowett-MSFT changed the title Replace ExpandEnvironmentStrings double calling with wil helper method Replace ExpandEnvironmentStrings double calling with wil helper Oct 15, 2019
@DHowett-MSFT DHowett-MSFT merged commit 12c2819 into microsoft:master Oct 15, 2019
@DHowett-MSFT
Copy link
Contributor

Thanks for the contribution!

@skyline75489 skyline75489 deleted the fix/2097 branch October 21, 2019 07:01
@ghost
Copy link

ghost commented Oct 23, 2019

🎉Windows Terminal Preview v0.6.2951.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Second It's a PR that needs another sign-off
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use wil::ExpandEnvironmentStrings where possible
3 participants