Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h (C/C++)

Code before:

    bool CanConvert(const Json::Value& json)
    {
        return BaseEnumMapper::CanConvert(json) || json.isUInt();
    }

    std::string TypeDescription() const
    {
        return EnumMapper::TypeDescription() + " or number";
    }
};

JSON_ENUM_MAPPER(::winrt::Windows::UI::Xaml::ElementTheme)
{
    JSON_MAPPINGS(3) = {
        pair_type{ "system", ValueType::Default },
        pair_type{ "light", ValueType::Light },
        pair_type{ "dark", ValueType::Dark },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::NewTabPosition)
{
    JSON_MAPPINGS(2) = {
        pair_type{ "atTheEnd", ValueType::AtTheEnd },
        pair_type{ "afterCurrentTab", ValueType::AfterCurrentTab },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::FirstWindowPreference)
{
    JSON_MAPPINGS(2) = {
        pair_type{ "defaultProfile", ValueType::DefaultProfile },
        pair_type{ "persistedWindowLayout", ValueType::PersistedWindowLayout },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::LaunchMode)
{
    JSON_MAPPINGS(8) = {
        pair_type{ "default", ValueType::DefaultMode },
        pair_type{ "maximized", ValueType::MaximizedMode },
        pair_type{ "fullscreen", ValueType::FullscreenMode },
        pair_type{ "maximizedFullscreen", ValueType::MaximizedMode | ValueType::FullscreenMode },
        pair_type{ "focus", ValueType::FocusMode },
        pair_type{ "maximizedFocus", ValueType::MaximizedFocusMode },
        pair_type{ "fullscreenFocus", ValueType::FullscreenMode | ValueType::FocusMode },
        pair_type{ "maximizedFullscreenFocus", ValueType::MaximizedMode | ValueType::FullscreenMode | ValueType::FocusMode },
    };
};


Review comment (suggestion):
We should keep an `atTheEnd` entry here to ensure that existing users' settings still work:
```cpp
pair_type{ "atTheEnd", ValueType::AfterLastTab },
```

We can ensure that `afterLastTab` is preferred over `atTheEnd` by putting that legacy mapping after the new one (for instance at the end of the list).

Code after:

    bool CanConvert(const Json::Value& json)
    {
        return BaseEnumMapper::CanConvert(json) || json.isUInt();
    }

    std::string TypeDescription() const
    {
        return EnumMapper::TypeDescription() + " or number";
    }
};

JSON_ENUM_MAPPER(::winrt::Windows::UI::Xaml::ElementTheme)
{
    JSON_MAPPINGS(3) = {
        pair_type{ "system", ValueType::Default },
        pair_type{ "light", ValueType::Light },
        pair_type{ "dark", ValueType::Dark },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::NewTabPosition)
{
    JSON_MAPPINGS(2) = {
        pair_type{ "afterLastTab", ValueType::AfterLastTab },
        pair_type{ "afterCurrentTab", ValueType::AfterCurrentTab },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::FirstWindowPreference)
{
    JSON_MAPPINGS(2) = {
        pair_type{ "defaultProfile", ValueType::DefaultProfile },
        pair_type{ "persistedWindowLayout", ValueType::PersistedWindowLayout },
    };
};

JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::LaunchMode)
{
    JSON_MAPPINGS(8) = {
        pair_type{ "default", ValueType::DefaultMode },
        pair_type{ "maximized", ValueType::MaximizedMode },
        pair_type{ "fullscreen", ValueType::FullscreenMode },
        pair_type{ "maximizedFullscreen", ValueType::MaximizedMode | ValueType::FullscreenMode },
        pair_type{ "focus", ValueType::FocusMode },
        pair_type{ "maximizedFocus", ValueType::MaximizedFocusMode },
        pair_type{ "fullscreenFocus", ValueType::FullscreenMode | ValueType::FocusMode },
        pair_type{ "maximizedFullscreenFocus", ValueType::MaximizedMode | ValueType::FullscreenMode | ValueType::FocusMode },
    };
};