terminal/src
Dustin L. Howett 3a5c33b005
Rework JsonUtils' optional handling to let Converters see null (#8175)
The JsonUtils changes in #8018 revealed that we need more robust,
configurable optional handling. We learned that there's a class of
values that was previously underrepresented in our API: _strings that
have an explicit empty value_.

The Settings model supports starting directory, icon, background image
et al values that are empty. That emptiness _overrides_ a value set in a
lower layer, so it is not sufficient to represent the empty value for
any one of those fields as an unset optional.

There are a couple other settings for which we've implemented a
hand-rolled option type (for roughly the same reason): foreground,
background, any color fields that override values from the color scheme
_or_ the lower layer profile.

These requirements are best fulfilled by better optional support in
JsonUtils. Where the library would originally detect known types of
optional and pre-filter them out during `GetValue` and `SetValue`, it
will now defer to another conversion trait.

This commit introduces a helper conversion trait and an "option oracle".
The conversion trait will use the option oracle to detect emptiness,
generate empty option values, and read values out of option types. In so
doing, the trait is insulated from the implementation details of any
specific option type.

Any special logic for handling JSON null and option types has been
stripped from GetValue. Due to this, there is an express change in
behavior for some converters:

* `GetValue<T>(jsonNull)` where `T` is **not** an option type[1] has
  been upgraded from a silent no-op to an exception.

Further, I took the opportunity to replace NullableSetting with
std::optional<std::optional<T>>, which accurately represents "setting
that the user might explicitly clear". I've added a test to
JsonUtilsTests to make sure it can serialize/deserialize double
optionals the way we expect it to.

Tests (Local, Unit for TerminalApp/SettingsModel):
Summary: Total=140, Passed=140, Failed=0, Blocked=0, Not Run=0, Skipped=0

[1]: Explicitly, if `T` is not an option type _and the converter does
not support null_.
2020-11-09 15:13:02 -08:00
..
buffer Consider the GlyphWidth when calculate the postion of matched word in URL detecting (#8124) 2020-11-03 20:40:58 +00:00
cascadia Rework JsonUtils' optional handling to let Converters see null (#8175) 2020-11-09 15:13:02 -08:00
dep Move all wildcards into targets or expand them (#6406) 2020-06-08 14:01:47 -07:00
host Add support for autodetecting URLs and making hyperlinks (#7691) 2020-10-28 20:24:43 +00:00
inc Add support for autodetecting URLs and making hyperlinks (#7691) 2020-10-28 20:24:43 +00:00
interactivity Fix UIA ScrollIntoView at EndExclusive (#7868) 2020-10-09 20:27:13 +00:00
internal Merged PR 4271163: [Git2Git] Remove use of private theme APIs 2020-02-03 23:13:31 +00:00
propsheet Merged PR 5131018: [Git2Git] Migrate OS changes to console property sheet manifest 2020-09-03 21:38:04 +00:00
propslib Find icon from shortcut target if shortcut doesn't specify it (#6277) 2020-06-01 17:19:05 +00:00
renderer Prevent leftover cursor fragments when scrolling in PowerShell (#8173) 2020-11-05 19:21:34 +00:00
server Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
terminal Added Types project reference to the FuzzWrapper project (#8041) 2020-10-26 22:42:16 +00:00
testlist inbox: Merge accumulated build fixes from RS_ONECORE_DEP_ACIOSS (#1002) 2019-05-24 12:28:30 -07:00
til Add support for autodetecting URLs and making hyperlinks (#7691) 2020-10-28 20:24:43 +00:00
tools Run all images through ImgBot (#8169) 2020-11-05 18:03:40 -08:00
tsf Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
types UIA: throw E_FAIL for out-of-bounds text (#8052) 2020-10-27 22:45:23 +00:00
winconpty conpty: fall back to conhost if OpenConsole is missing (#7741) 2020-10-15 11:50:27 -07:00
common.build.post.props Move CI and audit build to the WinDev scale set pool (#8080) 2020-10-28 20:49:13 +00:00
common.build.pre.props Use LanguageStandard over explicit compiler flag for C++17 (#8150) 2020-11-03 15:20:48 -08:00
common.build.tests.props Update TAEF to 10.57.200731005-develop (#7164) 2020-08-03 20:47:02 +00:00
ConsolePerf.regions.xml Tab to spaces (#578) 2019-05-13 18:06:36 -07:00
ConsolePerf.wprp Fix the WPR profile (#4007) 2019-12-17 17:14:15 -08:00
cppwinrt.build.post.props Remove all our path antics; force native projects to bin/, obj/ (#8062) 2020-10-27 15:00:41 -07:00
cppwinrt.build.pre.props Fix the WINRT_NO_MAKE_DETECTION build break (#8067) 2020-10-27 17:56:09 -07:00
dirs build: move oss required to build conhost out of dep/ (#5451) 2020-04-21 14:43:09 -07:00
project.inc Merged PR 4963673: OS-side build fixes for 09471c375 (gsl-3.1.0 update) 2020-07-30 22:48:48 +00:00
project.unittest.inc Merged PR 4915530: Reflect OS Build fixes on top of 58f5d7c7 2020-07-13 23:00:53 +00:00
StaticAnalysis.ruleset Combined changes to make the build work again (see inside) (#2945) 2019-09-30 10:39:55 -07:00
unit.tests.x64.runsettings Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
unit.tests.x86.runsettings Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
wap-common.build.post.props Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
wap-common.build.pre.props Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00