diff --git a/.pipelines/ESRPSigning_core.json b/.pipelines/ESRPSigning_core.json index 615b5633bf..0c65bf339b 100644 --- a/.pipelines/ESRPSigning_core.json +++ b/.pipelines/ESRPSigning_core.json @@ -221,6 +221,7 @@ "PowerToys.CmdPalModuleInterface.dll", "CmdPalKeyboardService.dll", + "CmdPalCalculator.dll", "*Microsoft.CmdPal.UI_*.msix" ], "SigningInfo": { diff --git a/PowerToys.sln b/PowerToys.sln index 780c731b30..50df9c43d8 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -628,6 +628,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.Apps", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.Bookmarks", "src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.Bookmark\Microsoft.CmdPal.Ext.Bookmarks.csproj", "{E09AA983-C755-474F-83D6-A5CDF528C070}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.Calc", "src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.Calc\Microsoft.CmdPal.Ext.Calc.csproj", "{6D56B64D-FF1F-488F-AFED-9B9854A5D399}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.Registry", "src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.Registry\Microsoft.CmdPal.Ext.Registry.csproj", "{92EC89E4-9972-453A-8A1A-3A9E230C146A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.Ext.WindowsServices", "src\modules\cmdpal\ext\Microsoft.CmdPal.Ext.WindowsServices\Microsoft.CmdPal.Ext.WindowsServices.csproj", "{51939B4F-1F62-4BFF-A6A2-C08646E5BE95}" @@ -2280,6 +2282,14 @@ Global {E09AA983-C755-474F-83D6-A5CDF528C070}.Release|ARM64.Build.0 = Release|ARM64 {E09AA983-C755-474F-83D6-A5CDF528C070}.Release|x64.ActiveCfg = Release|x64 {E09AA983-C755-474F-83D6-A5CDF528C070}.Release|x64.Build.0 = Release|x64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Debug|ARM64.Build.0 = Debug|ARM64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Debug|x64.ActiveCfg = Debug|x64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Debug|x64.Build.0 = Debug|x64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Release|ARM64.ActiveCfg = Release|ARM64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Release|ARM64.Build.0 = Release|ARM64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Release|x64.ActiveCfg = Release|x64 + {6D56B64D-FF1F-488F-AFED-9B9854A5D399}.Release|x64.Build.0 = Release|x64 {92EC89E4-9972-453A-8A1A-3A9E230C146A}.Debug|ARM64.ActiveCfg = Debug|ARM64 {92EC89E4-9972-453A-8A1A-3A9E230C146A}.Debug|ARM64.Build.0 = Debug|ARM64 {92EC89E4-9972-453A-8A1A-3A9E230C146A}.Debug|x64.ActiveCfg = Debug|x64 @@ -2831,6 +2841,7 @@ Global {367D7543-7DBA-4381-99F1-BF6142A996C4} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF} {2CAC093E-5FCF-4102-9C2C-AC7DD5D9EB96} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF} {37D07516-4185-43A4-924F-3C7A5D95ECF6} = {A2221D7E-55E7-4BEA-90D1-4F162D670BBF} + {6D56B64D-FF1F-488F-AFED-9B9854A5D399} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2} {8F021B46-362B-485C-BFBA-CCF83E820CBD} = {8F62026A-294B-41C6-8839-87463613F216} {66614C26-314C-4B91-9071-76133422CFEF} = {B6C42F16-73EB-477E-8B0D-4E6CF6C20AAC} {3846508C-77EB-4034-A702-F8BB263C4F79} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} diff --git a/src/modules/cmdpal/CmdPalCalculator/Calculator.cpp b/src/modules/cmdpal/CmdPalCalculator/Calculator.cpp index 38dde2e28d..206ace4c4a 100644 --- a/src/modules/cmdpal/CmdPalCalculator/Calculator.cpp +++ b/src/modules/cmdpal/CmdPalCalculator/Calculator.cpp @@ -5,11 +5,13 @@ namespace winrt::CmdPalCalculator::implementation { - Calculator::Calculator(Windows::Foundation::Collections::IMap const& constants) + Calculator::Calculator(winrt::Windows::Foundation::Collections::IPropertySet const& constants) { - for (auto const& [k, v] : constants) + for (auto const& pair : constants) { - m_constants.emplace(k.c_str(), v); + auto key = pair.Key(); + auto value = winrt::unbox_value(pair.Value()); + m_constants.emplace(key.c_str(), value); } } diff --git a/src/modules/cmdpal/CmdPalCalculator/Calculator.h b/src/modules/cmdpal/CmdPalCalculator/Calculator.h index 6446134366..444ba2a492 100644 --- a/src/modules/cmdpal/CmdPalCalculator/Calculator.h +++ b/src/modules/cmdpal/CmdPalCalculator/Calculator.h @@ -8,7 +8,7 @@ namespace winrt::CmdPalCalculator::implementation { Calculator() = default; - Calculator(Windows::Foundation::Collections::IMap const& constants); + Calculator(winrt::Windows::Foundation::Collections::IPropertySet const& constants); winrt::hstring EvaluateExpression(winrt::hstring const& expression); diff --git a/src/modules/cmdpal/CmdPalCalculator/Calculator.idl b/src/modules/cmdpal/CmdPalCalculator/Calculator.idl index 8e6df8afb2..d045557b1c 100644 --- a/src/modules/cmdpal/CmdPalCalculator/Calculator.idl +++ b/src/modules/cmdpal/CmdPalCalculator/Calculator.idl @@ -4,7 +4,7 @@ namespace CmdPalCalculator runtimeclass Calculator { Calculator(); - Calculator(IMap constants); + Calculator(Windows.Foundation.Collections.IPropertySet constants); String EvaluateExpression(String expression); } } diff --git a/src/modules/cmdpal/CmdPalCalculator/CmdPalCalculator.vcxproj b/src/modules/cmdpal/CmdPalCalculator/CmdPalCalculator.vcxproj index b8d49e841a..308ed22c0d 100644 --- a/src/modules/cmdpal/CmdPalCalculator/CmdPalCalculator.vcxproj +++ b/src/modules/cmdpal/CmdPalCalculator/CmdPalCalculator.vcxproj @@ -66,7 +66,7 @@ CmdPalCalculator - ..\..\..\..\$(Platform)\$(Configuration)\WinUI3Apps\ + ..\..\..\..\$(Platform)\$(Configuration)\ diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs index d410c7b526..440a9e7b91 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/App.xaml.cs @@ -7,6 +7,7 @@ using Microsoft.CmdPal.Common.Helpers; using Microsoft.CmdPal.Common.Services; using Microsoft.CmdPal.Ext.Apps; using Microsoft.CmdPal.Ext.Bookmarks; +using Microsoft.CmdPal.Ext.Calc; using Microsoft.CmdPal.Ext.ClipboardHistory; using Microsoft.CmdPal.Ext.Indexer; using Microsoft.CmdPal.Ext.Registry; @@ -103,6 +104,7 @@ public partial class App : Application services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // GH #38440: Users might not have WinGet installed! Or they might have // a ridiculously old version. Or might be running as admin. diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index a5d605239d..220b3f87c9 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -132,7 +132,7 @@ - + True True diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculateEngine.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculateEngine.cs index 5af2b50eb6..65121af049 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculateEngine.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Helper/CalculateEngine.cs @@ -7,16 +7,19 @@ using System.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; using CmdPalCalculator; +using Windows.Foundation.Collections; namespace Microsoft.CmdPal.Ext.Calc.Helper; public static class CalculateEngine { - private static readonly Calculator _calculator = new Calculator(new Dictionary - { - { "pi", Math.PI }, - { "e", Math.E }, - }); + private static readonly PropertySet _constants = new() + { + { "pi", Math.PI }, + { "e", Math.E }, + }; + + private static readonly Calculator _calculator = new Calculator(_constants); public const int RoundingDigits = 10; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj index 37f7012609..940b171d3d 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Calc/Microsoft.CmdPal.Ext.Calc.csproj @@ -3,7 +3,7 @@ @@ -26,11 +26,11 @@ - - + + PreserveNewest - + PreserveNewest