From 6ecf8b60b6861ce87a2054155612024cd31c29b0 Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Tue, 12 Jan 2021 21:52:17 +0300 Subject: [PATCH] updating: require dotnet >=3.1.10 (#9060) --- .github/actions/spell-check/expect.txt | 17 ++++++-------- src/common/updating/dotnet_installation.cpp | 26 +++++++++++++++++++-- src/common/updating/pch.h | 3 +++ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 124ca0945d..2e2d0f9723 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -38,7 +38,6 @@ AGGREGATABLE AHybrid Aissue akamaihd -alannt ALarger alekhyareddy alertsolid @@ -117,8 +116,8 @@ atlfile atlstr attr Attribs -aumid AUMID +aumid AUTHN AUTOAPPEND autocomplete @@ -222,6 +221,7 @@ CENTERALIGN cfg changecursor Changemove +charconv charset chdir checkbox @@ -279,7 +279,6 @@ codeofconduct codeql codereview COINIT -Colorbrush colorconv colorhistory colorhistorylimit @@ -467,8 +466,8 @@ DISPIDAMBIENTDLCONTROL DISPINFO Displayandhidethedesktop DISPLAYCHANGE -displayname DISPLAYNAME +displayname divyan DLACTIVEXCTLS DLCONTROL @@ -655,7 +654,7 @@ ERASEBKGND EREOF EResize eriawan -ERRORLEVEL +errc errorlevel ERRORMESSAGE ERRORTITLE @@ -797,7 +796,6 @@ globalplugins globals gmx google -gordonwatts GPTR grayscale GText @@ -857,8 +855,8 @@ HLSL hmenu hmodule hmon -hmonitor HMONITOR +hmonitor HOLDENTER HOLDESC homljgmgpmcbpjbnjpfijnhipfkiclkd @@ -1338,7 +1336,6 @@ modulekey MONITORINFO MONITORINFOEX MONITORINFOEXW -MONITORINFOF monitorinfof Monthand Moq @@ -1803,6 +1800,7 @@ resw resx returnvalue retval +rexit rfind rgb RGBQUAD @@ -2003,6 +2001,7 @@ sql src SRCCOPY sre +sregex SResize srme srre @@ -2077,7 +2076,6 @@ SVGIn svgpreviewhandler svgr SVGSVG -SWAPBUTTON Switchbetweenvirtualdesktops SWP swprintf @@ -2167,7 +2165,6 @@ toggleright toggleswitch toolbar Toolchain -Toolset toolset tooltip toolwindow diff --git a/src/common/updating/dotnet_installation.cpp b/src/common/updating/dotnet_installation.cpp index 90a7c75748..40b678d057 100644 --- a/src/common/updating/dotnet_installation.cpp +++ b/src/common/updating/dotnet_installation.cpp @@ -17,8 +17,30 @@ namespace updating { return false; } - const char DESKTOP_DOTNET_RUNTIME_STRING[] = "Microsoft.WindowsDesktop.App 3.1."; - return runtimes->find(DESKTOP_DOTNET_RUNTIME_STRING) != std::string::npos; + constexpr size_t REQUIRED_MINIMAL_PATCH = 10; + std::regex dotnet3_1_x{ R"(Microsoft\.WindowsDesktop\.App\s3\.1\.(\d+))" }; + + size_t latestPatchInstalled = 0; + using rexit = std::sregex_iterator; + for (auto it = rexit{ begin(*runtimes), end(*runtimes), dotnet3_1_x }; it != rexit{}; ++it) + { + if (!it->ready() || it->size() < 2) + { + continue; + } + auto patchNumberGroup = (*it)[1]; + if (!patchNumberGroup.matched) + { + continue; + } + const auto patchString = patchNumberGroup.str(); + size_t patch = 0; + if (auto [_, ec] = std::from_chars(&*begin(patchString), &*end(patchString), patch); ec == std::errc()) + { + latestPatchInstalled = std::max(patch, latestPatchInstalled); + } + } + return latestPatchInstalled >= REQUIRED_MINIMAL_PATCH; } std::optional download_dotnet() diff --git a/src/common/updating/pch.h b/src/common/updating/pch.h index 8eefa4f284..3e2b83fbff 100644 --- a/src/common/updating/pch.h +++ b/src/common/updating/pch.h @@ -7,6 +7,7 @@ #include #pragma warning(default : 5205) #define WIN32_LEAN_AND_MEAN +#define NOMINMAX #include #include #include @@ -19,6 +20,8 @@ #include #include +#include +#include #include