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

Make Profile a WinRT object #7283

Merged
18 commits merged into from
Aug 28, 2020
Merged

Make Profile a WinRT object #7283

18 commits merged into from
Aug 28, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Aug 13, 2020

Profile is now a WinRT object in the TerminalApp project.

As with ColorScheme, all of the serialization logic is not exposed via
the idl. TerminalSetingsModel will handle it when it's all moved over.

I removed the "Get" and "Set" prefixes from all of the Profile
functions. It just makes more sense to use the GETSET_PROPERTY macro
to do most of the work for us.

CloseOnExitMode is now an enum off of the Profile.idl.

std::optional<wstring> got converted to hstring (as opposed to
IReference<hstring>). IReference<hstring> is not valid to MIDL.

References

#7141 - Profile is a settings object
#885 - this new settings object will be moved to a new TerminalSettingsModel project

Validation Steps Performed

  • Tests passed
  • Deployment succeeded

Closes #7435

@carlos-zamora

This comment has been minimized.

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj-prof branch from fde1189 to 5d5ab10 Compare August 13, 2020 21:46
@carlos-zamora carlos-zamora added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Aug 13, 2020
@DHowett
Copy link
Member

DHowett commented Aug 13, 2020

It will be important to retarget this PR before you merge and delete the destination branch (!)

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj-prof branch from 7d81387 to 105183d Compare August 14, 2020 20:30
Copy link
Member Author

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Found a few small typos with massive consequences. Fixed though :)

Now I just have to figure out this one:
Default Profile Warning

src/cascadia/TerminalApp/DefaultProfileUtils.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Profile.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp Outdated Show resolved Hide resolved
Base automatically changed from dev/cazamor/set/winrt-app-obj to master August 15, 2020 00:54
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj-prof branch from 227172f to 17648c7 Compare August 17, 2020 18:02
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.

Okay I'm at 24/29, and i bet you can guess which 5 I haven't been to yet

src/cascadia/TerminalApp/DefaultProfileUtils.cpp Outdated Show resolved Hide resolved
{
const auto profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID,
const winrt::guid profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID,
Copy link
Member

Choose a reason for hiding this comment

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

this could still be auto, right? There should be an magic GUID->winrt::guid conversion already

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 wish. I think that the compiler gets confused with the winrt::Windows::Foundation::IReference<winrt::guid>. :(

1>D:\Terminal\src\cascadia\TerminalApp\DefaultProfileUtils.cpp(22,55): error C2440: 'initializing': cannot convert from 'initializer list' to 'winrt::TerminalApp::Profile'
1>D:\Terminal\src\cascadia\TerminalApp\DefaultProfileUtils.cpp(22,55): message : No constructor could take the source type, or constructor overload resolution was ambiguous
1>D:\Terminal\src\cascadia\TerminalApp\DefaultProfileUtils.cpp(24,32): error C2664: 'auto winrt::impl::consume_TerminalApp_IProfile<winrt::TerminalApp::IProfile>::Guid(const winrt::Windows::Foundation::IReference<winrt::guid> &) const': cannot convert argument 1 from 'const GUID' to 'const winrt::Windows::Foundation::IReference<winrt::guid> &'
1>D:\Terminal\src\cascadia\TerminalApp\DefaultProfileUtils.cpp(24,32): message : Reason: cannot convert from 'const GUID' to 'const winrt::Windows::Foundation::IReference<winrt::guid>'
1>D:\Terminal\src\cascadia\TerminalApp\DefaultProfileUtils.cpp(24,21): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be 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.

This actually seems to be the source of a lot of the comments you made. I've been getting around it by just using winrt::guid instead of GUID, but if you have a better idea in mind, go for it.

Copy link
Member

Choose a reason for hiding this comment

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

oh that makes me unreasonably angry

Copy link
Member

Choose a reason for hiding this comment

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

something something type covariance

src/cascadia/TerminalApp/Profile.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/ut_app/DynamicProfileTests.cpp Outdated Show resolved Hide resolved
src/cascadia/ut_app/DynamicProfileTests.cpp Show resolved Hide resolved
@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 Aug 17, 2020
@carlos-zamora carlos-zamora marked this pull request as ready for review August 18, 2020 21:59
@carlos-zamora carlos-zamora requested a review from a team August 18, 2020 21:59
@carlos-zamora
Copy link
Member Author

@DHowett, you might be interested in 03f6231. Is there a cleaner way to handle this issue with JsonUtils? I made it look a bit messier than before.

@carlos-zamora
Copy link
Member Author

@DHowett, you might be interested in 03f6231. Is there a cleaner way to handle this issue with JsonUtils? I made it look a bit messier than before.

Chatted offline. JsonUtils should be able to handle IReference as a std::optional and uses the same converter between GUID and winrt::guid.

But it looks like IReference<winrt::guid> still gets confused somehow. Check this out:

1>D:\Terminal\src\cascadia\TerminalApp\JsonUtils.h(450,1): error C2679: binary '=': no operator found which takes a right-hand operand of type 'GUID' (or there is no acceptable conversion)
1>D:\Terminal\src\cascadia\TerminalApp\lib\Generated Files\winrt\impl\Windows.Foundation.1.h(156,1): message : could be 'winrt::Windows::Foundation::IReference<winrt::guid> &winrt::Windows::Foundation::IReference<winrt::guid>::operator =(winrt::Windows::Foundation::IReference<winrt::guid> &&)'
1>D:\Terminal\src\cascadia\TerminalApp\lib\Generated Files\winrt\impl\Windows.Foundation.1.h(156,1): message : or       'winrt::Windows::Foundation::IReference<winrt::guid> &winrt::Windows::Foundation::IReference<winrt::guid>::operator =(const winrt::Windows::Foundation::IReference<winrt::guid> &)'
1>D:\Terminal\src\cascadia\TerminalApp\JsonUtils.h(450,1): message : while trying to match the argument list '(T, GUID)'
1>        with
1>        [
1>            T=winrt::Windows::Foundation::IReference<winrt::guid>
1>        ]
1>D:\Terminal\src\cascadia\TerminalApp\JsonUtils.h(473): message : see reference to function template instantiation 'bool TerminalApp::JsonUtils::GetValue<T,_Ty>(const Json::Value &,T &,Converter &&)' being compiled
1>        with
1>        [
1>            T=winrt::Windows::Foundation::IReference<winrt::guid>,
1>            _Ty=TerminalApp::JsonUtils::ConversionTrait<winrt::guid>,
1>            Converter=TerminalApp::JsonUtils::ConversionTrait<winrt::guid>
1>        ]
1>D:\Terminal\src\cascadia\TerminalApp\JsonUtils.h(513): message : see reference to function template instantiation 'bool TerminalApp::JsonUtils::GetValueForKey<T,TerminalApp::JsonUtils::ConversionTrait<winrt::guid>>(const Json::Value &,std::string_view,T &,Converter &&)' being compiled
1>        with
1>        [
1>            T=winrt::Windows::Foundation::IReference<winrt::guid>,
1>            Converter=TerminalApp::JsonUtils::ConversionTrait<winrt::guid>
1>        ]
1>D:\Terminal\src\cascadia\TerminalApp\Profile.cpp(322): message : see reference to function template instantiation 'bool TerminalApp::JsonUtils::GetValueForKey<winrt::Windows::Foundation::IReference<winrt::guid>>(const Json::Value &,std::string_view,T &)' being compiled
1>        with
1>        [
1>            T=winrt::Windows::Foundation::IReference<winrt::guid>
1>        ]

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.

re:

I was considering that for a bit, actually. If we go that route, I think it would make sense to break up

GETSET_PROPERTY(Windows::Foundation::IReference<guid>, Guid, nullptr);

into

// return/accept guid instead of IReference<guid>
bool HasGuid();
guid Guid();
void Guid(guid);

Honestly, that feels better to me, but I know how much annoying work that is. IMO, it seems like external to the deserialization of the settings, a profile should always have a GUID. Kinda like how right now we just throw if a profile ever doesn't. That'll prevent the need for all the other classes to do the if (profile.Guid() != nullptr) { profile.Guid().Value(); } dance.

src/cascadia/ut_app/DynamicProfileTests.cpp Show resolved Hide resolved
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj-prof branch from b8f476b to 1a20cb3 Compare August 20, 2020 06:21
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj-prof branch from 6051822 to 8396b2d Compare August 21, 2020 03:59
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.

Alright, these are all only nits, so I won't block over them.

src/cascadia/TerminalApp/Profile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Profile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Profile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Profile.h Outdated Show resolved Hide resolved
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 26, 2020
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 don't feel confident enough in WinRT-isms to sign off here, but I didn't see a whole lot out of order. Just left a few small comments.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

NAK because of the null discussion and change in behavior

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 26, 2020
@DHowett DHowett removed their assignment Aug 26, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 26, 2020
@carlos-zamora
Copy link
Member Author

I still want/need to double check if there is similar behavior with making the other settings null. Assigning to myself to do that. So this PR is not ready to go yet.

@carlos-zamora
Copy link
Member Author

The latest commit closes #7435 as well.

@ghost ghost added the Area-Settings Issues related to settings and customizability, for console or terminal label Aug 27, 2020
src/cascadia/TerminalApp/Profile.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Profile.cpp Outdated Show resolved Hide resolved
@DHowett
Copy link
Member

DHowett commented Aug 28, 2020

@msftbot merge this in 1 minute

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 28, 2020
@ghost
Copy link

ghost commented Aug 28, 2020

Hello @DHowett!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Fri, 28 Aug 2020 01:08:45 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit a51091c into master Aug 28, 2020
@ghost ghost deleted the dev/cazamor/set/winrt-app-obj-prof branch August 28, 2020 01:09
@ghost
Copy link

ghost commented Sep 22, 2020

🎉Windows Terminal Preview v1.4.2652.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling Nullable Profile Settings
4 participants