diff --git a/src/cascadia/TerminalApp/AzureCloudShellGenerator.cpp b/src/cascadia/TerminalApp/AzureCloudShellGenerator.cpp index d4ea5c099c5..e1b4204c7df 100644 --- a/src/cascadia/TerminalApp/AzureCloudShellGenerator.cpp +++ b/src/cascadia/TerminalApp/AzureCloudShellGenerator.cpp @@ -40,7 +40,7 @@ std::vector AzureCloudShellGenerator::GenerateProfiles() azureCloudShellProfile.ColorSchemeName({ L"Vintage" }); azureCloudShellProfile.AcrylicOpacity(0.6); azureCloudShellProfile.UseAcrylic(true); - azureCloudShellProfile.ConnectionType({ AzureConnectionType }); + azureCloudShellProfile.ConnectionType(winrt::guid(AzureConnectionType)); profiles.emplace_back(azureCloudShellProfile); } diff --git a/src/cascadia/TerminalApp/CascadiaSettings.cpp b/src/cascadia/TerminalApp/CascadiaSettings.cpp index c16c4d23c4b..fe3c309ca60 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettings.cpp @@ -93,7 +93,7 @@ const Profile CascadiaSettings::FindProfile(GUID profileGuid) const noexcept // - // Return Value: // - an iterable collection of all of our Profiles. -gsl::span CascadiaSettings::GetProfiles() const noexcept +gsl::span CascadiaSettings::GetProfiles() const noexcept { return { &_profiles[0], _profiles.size() }; } @@ -244,7 +244,7 @@ void CascadiaSettings::_ResolveDefaultProfile() // warnings if we failed to find the default. void CascadiaSettings::_ValidateDefaultProfileExists() { - const winrt::guid defaultProfileGuid = GlobalSettings().DefaultProfile(); + const auto defaultProfileGuid = winrt::guid(GlobalSettings().DefaultProfile()); const bool nullDefaultProfile = defaultProfileGuid == winrt::guid{}; bool defaultProfileNotInProfiles = true; for (const auto& profile : _profiles) @@ -263,7 +263,7 @@ void CascadiaSettings::_ValidateDefaultProfileExists() // _temporarily_ set the default profile to the first profile. Because // we're adding a warning, this settings change won't be re-serialized. - GlobalSettings().DefaultProfile(_profiles[0].Guid().Value()); + GlobalSettings().DefaultProfile(GUID(_profiles[0].Guid().Value())); } } @@ -279,7 +279,7 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles() std::vector indicesToDelete; - std::set uniqueGuids; + std::set uniqueGuids; // Try collecting all the unique guids. If we ever encounter a guid that's // already in the set, then we need to delete that profile. @@ -316,8 +316,8 @@ void CascadiaSettings::_ValidateNoDuplicateProfiles() // - void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder() { - std::set uniqueGuids; - std::deque guidOrder; + std::set uniqueGuids; + std::deque guidOrder; auto collectGuids = [&](const auto& json) { for (auto profileJson : _GetProfilesJsonObject(json)) @@ -338,7 +338,7 @@ void CascadiaSettings::_ReorderProfilesToMatchUserSettingsOrder() // Push all the defaultSettings profiles' GUIDS into the set collectGuids(_defaultSettings); - std::equal_to equals; + std::equal_to equals; // Re-order the list of _profiles to match that ordering // for (gIndex=0 -> uniqueGuids.size) // pIndex = the pIndex of the profile with guid==guids[gIndex] @@ -529,7 +529,7 @@ std::tuple CascadiaSettings::BuildSettings(const NewTerm // Arguments: // - profileGuid: The GUID of a profile to use to create a settings object for. // Return Value: -// - the GUID of the created profile, and a fully initialized TerminalSettings object +// - a fully initialized TerminalSettings object TerminalSettings CascadiaSettings::BuildSettings(GUID profileGuid) const { const auto profile = FindProfile(profileGuid); @@ -607,7 +607,7 @@ try // lookup a profile. Instead, try using the string to look the // Profile up by name. const auto profileIterator{ std::find_if(_profiles.cbegin(), _profiles.cend(), [&](auto&& profile) { - return profile.Name() == name; + return profile.Name().c_str() == name; }) }; if (profileIterator != _profiles.cend()) diff --git a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp index 76720759f12..7ac363b685f 100644 --- a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp @@ -481,7 +481,7 @@ bool CascadiaSettings::_AppendDynamicProfilesToUserSettings() for (const auto& profile : _profiles) { - if (profile.Guid() != nullptr) + if (profile.Guid() == nullptr) { // If the profile doesn't have a guid, it's a name-only profile. // During validation, we'll generate a GUID for the profile, but diff --git a/src/cascadia/TerminalApp/DefaultProfileUtils.cpp b/src/cascadia/TerminalApp/DefaultProfileUtils.cpp index 358406c992f..521af12c6a6 100644 --- a/src/cascadia/TerminalApp/DefaultProfileUtils.cpp +++ b/src/cascadia/TerminalApp/DefaultProfileUtils.cpp @@ -17,12 +17,11 @@ static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" }; // - A Profile, ready to be filled in winrt::TerminalApp::Profile CreateDefaultProfile(const std::wstring_view name) { - const auto profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, + const winrt::guid profileGuid{ Microsoft::Console::Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(name))) }; - //auto newProfile = winrt::make(profileGuid); - winrt::TerminalApp::Profile newProfile; - newProfile.Guid({ profileGuid }); - + winrt::TerminalApp::Profile newProfile{profileGuid}; + //auto newProfile = winrt::make(); + newProfile.Guid(profileGuid); newProfile.Name(name); std::wstring iconPath{ PACKAGED_PROFILE_ICON_PATH }; diff --git a/src/cascadia/TerminalApp/IDynamicProfileGenerator.h b/src/cascadia/TerminalApp/IDynamicProfileGenerator.h index e5ba73c256d..22940364a26 100644 --- a/src/cascadia/TerminalApp/IDynamicProfileGenerator.h +++ b/src/cascadia/TerminalApp/IDynamicProfileGenerator.h @@ -20,7 +20,7 @@ Author(s): --*/ #pragma once -#include "Profile.g.h" +#include "Profile.h" namespace TerminalApp { diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp index 687c457e282..c50f654e425 100644 --- a/src/cascadia/TerminalApp/Profile.cpp +++ b/src/cascadia/TerminalApp/Profile.cpp @@ -383,11 +383,11 @@ void Profile::LayerJson(const Json::Value& json) // - this profile's icon path, if one is set. Otherwise returns the empty string. winrt::hstring Profile::GetExpandedIconPath() const { - if (!_Icon.empty()) + if (_Icon.empty()) { return { L"" }; } - winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW(_Icon.data()) }; + winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW(_Icon.c_str()) }; return envExpandedPath; } @@ -398,14 +398,12 @@ winrt::hstring Profile::GetExpandedIconPath() const // - This profile's expanded background image path / the empty string. winrt::hstring Profile::GetExpandedBackgroundImagePath() const { - winrt::hstring result{}; - - if (!_BackgroundImage.empty()) + if (_BackgroundImage.empty()) { - result = wil::ExpandEnvironmentStringsW(_BackgroundImage.data()); + return { L"" }; } - - return result; + winrt::hstring envExpandedPath{ wil::ExpandEnvironmentStringsW(_BackgroundImage.c_str()) }; + return envExpandedPath; } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 72226aabfb1..01a453e2e0f 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -777,13 +777,13 @@ namespace winrt::TerminalApp::implementation GUID connectionType{ 0 }; GUID sessionGuid{ 0 }; - if (profile.ConnectionType()) + if (profile.ConnectionType() != nullptr) { connectionType = profile.ConnectionType().Value(); } - if (profile.ConnectionType() && - profile.ConnectionType().Value() == winrt::guid{AzureConnectionType} && + if (profile.ConnectionType() != nullptr && + profile.ConnectionType().Value() == winrt::guid{ AzureConnectionType } && TerminalConnection::AzureConnection::IsAzureConnectionAvailable()) { // TODO GH#4661: Replace this with directly using the AzCon when our VT is better @@ -1995,7 +1995,7 @@ namespace winrt::TerminalApp::implementation auto profiles = _settings->GetProfiles(); for (auto& profile : profiles) { - const GUID profileGuid = GUID(profile.Guid().Value()) ; + const GUID profileGuid = GUID(profile.Guid().Value()); try {