From 3409ad0af11671193470c02e7aeff3a8cadabe20 Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Fri, 23 Sep 2022 09:37:30 -0400 Subject: [PATCH 1/5] fixed decimal usability in converter section --- src/CalcViewModel/UnitConverterViewModel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 478485381..34ebed0bd 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -177,6 +177,8 @@ void UnitConverterViewModel::ResetCategory() IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded; IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT; + IsDecimalEnabled = true; + UnitChanged->Execute(nullptr); } From 4ffca0cd04a92acee00422a11ea62be69857900c Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Mon, 26 Sep 2022 07:59:47 -0400 Subject: [PATCH 2/5] fixed UpdateIsDecimalEnabled --- src/CalcViewModel/UnitConverterViewModel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 34ebed0bd..56eec6540 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -177,7 +177,7 @@ void UnitConverterViewModel::ResetCategory() IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded; IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT; - IsDecimalEnabled = true; + UpdateIsDecimalEnabled(); UnitChanged->Execute(nullptr); } @@ -873,7 +873,8 @@ void UnitConverterViewModel::UpdateCurrencyFormatter() void UnitConverterViewModel::UpdateIsDecimalEnabled() { if (!IsCurrencyCurrentCategory || CurrencyFormatterFrom == nullptr) - return; + IsDecimalEnabled = true; + else IsDecimalEnabled = CurrencyFormatterFrom->FractionDigits > 0; } From 2b3e4f4aad098005416da30a603f21d780a24d18 Mon Sep 17 00:00:00 2001 From: Declan Gazil Date: Mon, 26 Sep 2022 08:17:34 -0400 Subject: [PATCH 3/5] fixed decimal resetting upon category change --- README.md | 2 +- src/CalcManager/CEngine/Number.cpp | 3 +- src/CalcManager/CEngine/calc.cpp | 2 +- src/CalcManager/CEngine/scicomm.cpp | 34 +++++++++++++------ src/CalcManager/CEngine/sciset.cpp | 6 ++-- src/CalcManager/Header Files/CalcEngine.h | 2 +- src/CalcManager/Ratpack/CalcErr.h | 2 +- src/CalcManager/UnitConverter.h | 9 +++-- .../Common/LocalizationStringUtil.h | 2 +- src/CalcViewModel/UnitConverterViewModel.cpp | 4 +-- src/CalcViewModel/pch.h | 11 ------ src/Calculator/Calculator.csproj | 4 +-- .../CalculatorUITestFramework.csproj | 4 +-- .../WindowsDriverServiceBuilder.cs | 4 --- .../CalculatorUITests.csproj | 8 ++--- src/GraphingInterfaces/IGraphAnalyzer.h | 2 +- 16 files changed, 48 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 5582b1724..cc68ddb1f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Calculator ships regularly with new features and bug fixes. You can get the late ## Getting started Prerequisites: -- Your computer must be running Windows 10, version 1809 or newer. Windows 11 is recommended. +- Your computer must be running Windows 11, build 22000 or newer. - Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient). - Install the "Universal Windows Platform Development" workload. - Install the optional "C++ Universal Windows Platform tools" component. diff --git a/src/CalcManager/CEngine/Number.cpp b/src/CalcManager/CEngine/Number.cpp index 7b3be21b6..da443b122 100644 --- a/src/CalcManager/CEngine/Number.cpp +++ b/src/CalcManager/CEngine/Number.cpp @@ -22,10 +22,9 @@ namespace CalcEngine Number::Number(PNUMBER p) noexcept : m_sign{ p->sign } , m_exp{ p->exp } - , m_mantissa{} { m_mantissa.reserve(p->cdigit); - copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa)); + copy_n(p->mant, p->cdigit, back_inserter(m_mantissa)); } PNUMBER Number::ToPNUMBER() const diff --git a/src/CalcManager/CEngine/calc.cpp b/src/CalcManager/CEngine/calc.cpp index dd70fb634..713a661c4 100644 --- a/src/CalcManager/CEngine/calc.cpp +++ b/src/CalcManager/CEngine/calc.cpp @@ -101,7 +101,7 @@ CCalcEngine::CCalcEngine( { InitChopNumbers(); - m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(m_numwidth); + m_dwWordBitWidth = DwWordBitWidthFromNumWidth(m_numwidth); m_maxTrigonometricNum = RationalMath::Pow(10, 100); diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index 4d671fbd6..dcf1c44fc 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -30,17 +30,31 @@ namespace // 0 is returned. Higher the number, higher the precedence of the operator. int NPrecedenceOfOp(int nopCode) { - static uint16_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_NAND, 1, IDC_NOR, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF, 3, - IDC_LSHF, 3, IDC_RSHFL, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4, IDC_LOGBASEY, 4 }; - - for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2) + switch (nopCode) { - if (nopCode == rgbPrec[iPrec]) - { - return rgbPrec[iPrec + 1]; - } + default: + case IDC_OR: + case IDC_XOR: + return 0; + case IDC_AND: + case IDC_NAND: + case IDC_NOR: + return 1; + case IDC_ADD: + case IDC_SUB: + return 2; + case IDC_LSHF: + case IDC_RSHF: + case IDC_RSHFL: + case IDC_MOD: + case IDC_DIV: + case IDC_MUL: + return 3; + case IDC_PWR: + case IDC_ROOT: + case IDC_LOGBASEY: + return 4; } - return 0; } } @@ -518,7 +532,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam) if (wParam == IDC_OPENP) { - // if there's an omitted multiplication sign + // if there's an omitted multiplication sign if (IsDigitOpCode(m_nLastCom) || IsUnaryOpCode(m_nLastCom) || m_nLastCom == IDC_PNT || m_nLastCom == IDC_CLOSEP) { ProcessCommand(IDC_MUL); diff --git a/src/CalcManager/CEngine/sciset.cpp b/src/CalcManager/CEngine/sciset.cpp index cb1435593..57aeda3bd 100644 --- a/src/CalcManager/CEngine/sciset.cpp +++ b/src/CalcManager/CEngine/sciset.cpp @@ -39,7 +39,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt if (numwidth >= NUM_WIDTH::QWORD_WIDTH && numwidth <= NUM_WIDTH::BYTE_WIDTH) { m_numwidth = numwidth; - m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth); + m_dwWordBitWidth = DwWordBitWidthFromNumWidth(numwidth); } // inform ratpak that a change in base or precision has occurred @@ -50,7 +50,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt DisplayNum(); } -int32_t CCalcEngine::DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth) +int32_t CCalcEngine::DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth) { switch (numwidth) { @@ -85,7 +85,7 @@ uint32_t CCalcEngine::NRadixFromRadixType(RadixType radixtype) // Toggles a given bit into the number representation. returns true if it changed it actually. bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno) { - uint32_t wmax = DwWordBitWidthFromeNumWidth(m_numwidth); + uint32_t wmax = DwWordBitWidthFromNumWidth(m_numwidth); if (wbitno >= wmax) { return false; // ignore error cant happen diff --git a/src/CalcManager/Header Files/CalcEngine.h b/src/CalcManager/Header Files/CalcEngine.h index 7709cf61d..f387c020a 100644 --- a/src/CalcManager/Header Files/CalcEngine.h +++ b/src/CalcManager/Header Files/CalcEngine.h @@ -179,7 +179,7 @@ class CCalcEngine CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op); CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs); void SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidth); - int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth); + int32_t DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth); uint32_t NRadixFromRadixType(RadixType radixtype); double GenerateRandomNumber(); diff --git a/src/CalcManager/Ratpack/CalcErr.h b/src/CalcManager/Ratpack/CalcErr.h index 9e4223e64..5f7ae524f 100644 --- a/src/CalcManager/Ratpack/CalcErr.h +++ b/src/CalcManager/Ratpack/CalcErr.h @@ -38,7 +38,7 @@ // This format is based loosely on an OLE HRESULT and is compatible with the // SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro -typedef int32_t ResultCode; +using ResultCode = int32_t; // CALC_E_DIVIDEBYZERO // diff --git a/src/CalcManager/UnitConverter.h b/src/CalcManager/UnitConverter.h index 0ee06ae3e..44255816b 100644 --- a/src/CalcManager/UnitConverter.h +++ b/src/CalcManager/UnitConverter.h @@ -156,13 +156,12 @@ namespace UnitConversionManager std::wstring targetCurrencyCode; }; - typedef std::tuple, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer; - typedef std::unordered_map< + using CategorySelectionInitializer = std::tuple, UnitConversionManager::Unit, UnitConversionManager::Unit>; + using UnitToUnitToConversionDataMap = std::unordered_map< UnitConversionManager::Unit, std::unordered_map, - UnitConversionManager::UnitHash> - UnitToUnitToConversionDataMap; - typedef std::unordered_map> CategoryToUnitVectorMap; + UnitConversionManager::UnitHash>; + using CategoryToUnitVectorMap = std::unordered_map>; class IViewModelCurrencyCallback { diff --git a/src/CalcViewModel/Common/LocalizationStringUtil.h b/src/CalcViewModel/Common/LocalizationStringUtil.h index 33aa482d9..d7e080328 100644 --- a/src/CalcViewModel/Common/LocalizationStringUtil.h +++ b/src/CalcViewModel/Common/LocalizationStringUtil.h @@ -16,7 +16,7 @@ namespace CalculatorApp::ViewModel { std::wstring returnString = L""; const UINT32 length = 1024; - std::unique_ptr spBuffer = std::unique_ptr(new wchar_t[length]); + std::unique_ptr spBuffer = std::make_unique(length); va_list args = NULL; va_start(args, pMessage); DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args); diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 56eec6540..9f70c799f 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -174,11 +174,11 @@ void UnitConverterViewModel::ResetCategory() m_isInputBlocked = false; SetSelectedUnits(); + UpdateIsDecimalEnabled(); + IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded; IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT; - UpdateIsDecimalEnabled(); - UnitChanged->Execute(nullptr); } diff --git a/src/CalcViewModel/pch.h b/src/CalcViewModel/pch.h index 6d4cd9c21..5b188017f 100644 --- a/src/CalcViewModel/pch.h +++ b/src/CalcViewModel/pch.h @@ -42,14 +42,3 @@ #include "winrt/Windows.UI.Xaml.h" #include "winrt/Windows.Foundation.Metadata.h" #include "winrt/Windows.Management.Policies.h" - -// The following namespaces exist as a convenience to resolve -// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers -// namespace that only exist on RS3. -// Once the app switches to min version RS3, the namespaces can be removed. -// TODO - MSFT 12735088 -namespace StandardPeers = Windows::UI::Xaml::Automation::Peers; -namespace CalculatorApp::ViewModel::Common::Automation -{ -} -namespace CustomPeers = CalculatorApp::ViewModel::Common::Automation; diff --git a/src/Calculator/Calculator.csproj b/src/Calculator/Calculator.csproj index f47de8372..aa7e1f175 100644 --- a/src/Calculator/Calculator.csproj +++ b/src/Calculator/Calculator.csproj @@ -792,9 +792,9 @@ - 6.2.10 + 6.2.14 - + diff --git a/src/CalculatorUITestFramework/CalculatorUITestFramework.csproj b/src/CalculatorUITestFramework/CalculatorUITestFramework.csproj index 0fc0236fa..dc33a259f 100644 --- a/src/CalculatorUITestFramework/CalculatorUITestFramework.csproj +++ b/src/CalculatorUITestFramework/CalculatorUITestFramework.csproj @@ -3,7 +3,7 @@ net6.0 - - + + \ No newline at end of file diff --git a/src/CalculatorUITestFramework/WindowsDriverServiceBuilder.cs b/src/CalculatorUITestFramework/WindowsDriverServiceBuilder.cs index bdf605742..dec24fe0b 100644 --- a/src/CalculatorUITestFramework/WindowsDriverServiceBuilder.cs +++ b/src/CalculatorUITestFramework/WindowsDriverServiceBuilder.cs @@ -45,10 +45,6 @@ public WindowsDriverServiceBuilder WithFileInfo(FileInfo fileInfo) public WindowsDriverServiceBuilder WithStartUpTimeOut(TimeSpan startUpTimeout) { - if (startUpTimeout == null) - { - throw new ArgumentNullException("A startup timeout should not be NULL"); - } this.StartUpTimeout = startUpTimeout; return this; } diff --git a/src/CalculatorUITests/CalculatorUITests.csproj b/src/CalculatorUITests/CalculatorUITests.csproj index 1d4416e64..984842cd7 100644 --- a/src/CalculatorUITests/CalculatorUITests.csproj +++ b/src/CalculatorUITests/CalculatorUITests.csproj @@ -4,10 +4,10 @@ false - - - - + + + + diff --git a/src/GraphingInterfaces/IGraphAnalyzer.h b/src/GraphingInterfaces/IGraphAnalyzer.h index 5e6233b60..0e8321636 100644 --- a/src/GraphingInterfaces/IGraphAnalyzer.h +++ b/src/GraphingInterfaces/IGraphAnalyzer.h @@ -11,7 +11,7 @@ namespace Graphing::Analyzer { - typedef unsigned int NativeAnalysisType; // PerformAnalysisType + using NativeAnalysisType = unsigned int; // PerformAnalysisType struct IGraphAnalyzer : public NonCopyable, public NonMoveable { From 22db281fa6073ae49da8c72bdb5550a7e0830421 Mon Sep 17 00:00:00 2001 From: Declan Gazil <92892710+DeclanGazil02@users.noreply.github.com> Date: Tue, 27 Sep 2022 12:20:59 -0400 Subject: [PATCH 4/5] Create build.yml --- .github/workflows/build.yml | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..287168c56 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build + runs-on: windows-latest + env: + SONAR_SCANNER_VERSION: 4.7.0.2747 + SONAR_SERVER_URL: "https://sonarcloud.io" + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Download and set up sonar-scanner + env: + SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-windows.zip + run: | + New-Item -Force -ItemType directory -Path $HOME\.sonar + curl -sSLo $HOME\.sonar\sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} + unzip -o $HOME\.sonar\sonar-scanner.zip -d $HOME\.sonar\ + echo "$HOME\.sonar\sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 + - name: Download and set up build-wrapper + env: + BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-win-x86.zip + run: | + curl -sSLo $HOME\.sonar\build-wrapper.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} + unzip -o $HOME\.sonar\build-wrapper.zip -d $HOME\.sonar\ + echo "$HOME\.sonar\build-wrapper-win-x86" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 + - name: Run build-wrapper + run: | + build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} + - name: Run sonar-scanner + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: | + sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" From 01f5a87402f6612f2943ff732c4539534a3a701b Mon Sep 17 00:00:00 2001 From: Declan Gazil <92892710+DeclanGazil02@users.noreply.github.com> Date: Tue, 27 Sep 2022 12:21:33 -0400 Subject: [PATCH 5/5] Create sonar-project.properties --- sonar-project.properties | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..e634e6665 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=DeclanGazil02_calculator +sonar.organization=declangazil02 + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=calculator +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8