From f3cf86aef0d561c26089a8179089f25c2d947e11 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 18 Mar 2021 19:46:27 -0700 Subject: [PATCH 1/8] Protoype of refactoring work with Test code too. Pushing these commits for a draft PR. --- src/AppInstallerCLI/main.cpp | 8 +- .../AppInstallerCLICore.vcxproj | 1 + .../AppInstallerCLICore.vcxproj.filters | 3 + src/AppInstallerCLICore/COMContext.cpp | 3 + src/AppInstallerCLICore/COMContext.h | 73 +++++++++++++++++++ src/AppInstallerCLICore/Core.cpp | 58 +++++++++++++++ src/AppInstallerCLICore/ExecutionContext.h | 11 +++ src/AppInstallerCLICore/ExecutionReporter.cpp | 16 +++- src/AppInstallerCLICore/ExecutionReporter.h | 25 +++++-- .../Public/AppInstallerCLICore.h | 1 + .../Workflows/WorkflowBase.cpp | 1 + src/AppInstallerCLITests/TestCommon.cpp | 8 ++ src/AppInstallerCLITests/TestCommon.h | 5 ++ .../Public/AppInstallerProgress.h | 22 ++++++ 14 files changed, 224 insertions(+), 11 deletions(-) create mode 100644 src/AppInstallerCLICore/COMContext.cpp create mode 100644 src/AppInstallerCLICore/COMContext.h diff --git a/src/AppInstallerCLI/main.cpp b/src/AppInstallerCLI/main.cpp index 8b06f12292..e6e054b174 100644 --- a/src/AppInstallerCLI/main.cpp +++ b/src/AppInstallerCLI/main.cpp @@ -2,7 +2,11 @@ // Licensed under the MIT License. #include -int wmain(int argc, wchar_t const** argv) +//int wmain(int argc, wchar_t const** argv) +int wmain() { - return AppInstaller::CLI::CoreMain(argc, argv); + AppInstaller::CLI::TestCOMScenario(); + return 0; + //return AppInstaller::CLI::CoreMain(argc, argv); } + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index d99b7b790f..50c77827ef 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -177,6 +177,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 784c9210aa..15941fd28e 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -152,6 +152,9 @@ Header Files + + Public + diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp new file mode 100644 index 0000000000..2991e3657e --- /dev/null +++ b/src/AppInstallerCLICore/COMContext.cpp @@ -0,0 +1,3 @@ +#include "COMContext.h" + +using namespace AppInstaller; diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h new file mode 100644 index 0000000000..a2c90ba783 --- /dev/null +++ b/src/AppInstallerCLICore/COMContext.h @@ -0,0 +1,73 @@ +#pragma once +#include "pch.h" +#include "..\AppInstallerCommonCore\Public\AppInstallerProgress.h" +#include "ExecutionContext.h" + +namespace AppInstaller +{ + using namespace AppInstaller::CLI; + + enum ReportType + { + BeginProgress, + Progressing, + EndProgress, + ExecutionPhaseUpdate, + }; + + struct COMContext : IProgressSink, Execution::Context + { + COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) + { + Reporter.SetProgressSink(this); + } + + ~COMContext() {} + + // IProgressSink + void BeginProgress() override + { + m_comProgressCallback((uint32_t)ReportType::BeginProgress, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); + }; + + // IProgressSink + void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override + { + SetProgress(current, maximum, type); + m_comProgressCallback((uint32_t)ReportType::Progressing, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); + } + + // IProgressSink + void EndProgress() override + { + m_comProgressCallback((uint32_t)ReportType::EndProgress, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); + }; + + // Execution::Context + void SetExecutionStage(uint32_t executionPhase) override + { + SetProgress(0,0,ProgressType::None); + m_executionPhase = executionPhase; + m_comProgressCallback((uint32_t)ReportType::ExecutionPhaseUpdate, m_current, m_maximum, (uint32_t)m_type, executionPhase); + } + + void SetProgressCallbackFunction(std::function&& f) + { + m_comProgressCallback = std::move(f); + } + + private: + void SetProgress(uint64_t current, uint64_t maximum, ProgressType type) + { + m_current = current; + m_maximum = maximum; + m_type = type; + } + + std::function m_comProgressCallback; + uint64_t m_current = 0; + uint64_t m_maximum = 0; + ProgressType m_type = ProgressType::None; + uint32_t m_executionPhase = 0; // Instead add Worfklow::ExecutionStage::None and set that as default here + }; +} \ No newline at end of file diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 1dfd95f947..797c93cc30 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -6,6 +6,7 @@ #include "ExecutionContext.h" #include "Workflows/WorkflowBase.h" #include +#include "COMContext.h" using namespace winrt; using namespace winrt::Windows::Foundation; @@ -41,6 +42,63 @@ namespace AppInstaller::CLI }; } + void OnProgress(uint32_t reportType, uint64_t current, uint64_t maximum, uint32_t progressType, uint32_t executionPhase) + { + // Rest of this method is just Local Testing and Demo + std::cout << "Execution Stage:"; + std::cout << executionPhase; + std::cout << " reportType: "; + std::cout << reportType; + std::cout << " current: "; + std::cout << current; + std::cout << " maximum: "; + std::cout << maximum; + std::cout << " ProgressType : "; + std::cout << (uint32_t)progressType; + std::cout << "\n"; + + if (current == maximum) + { + // Current Execution Phase is Complete + std::cout << "Current Execution Phase is now complete\n"; + } + } + + void TestCOMScenario() + { + init_apartment(); + + // proposal: BEGIN what COM Interface should do + // Eventually, COM Interface has to be aware whether the caller wants CLI ouptut or not. And appropriate set null streams or std::cout/cin streams + class NullStreamBuf : public std::streambuf {}; + NullStreamBuf nullStreamBuf; + std::ostream nullOstream(&nullStreamBuf); + std::istream nullIstream(&nullStreamBuf); + + AppInstaller::COMContext context(nullOstream, nullIstream); + context.SetProgressCallbackFunction(OnProgress); + + std::vector utf8Args; + utf8Args.emplace_back(Utility::ConvertToUTF8(L"install")); + utf8Args.emplace_back(Utility::ConvertToUTF8(L"mozilla.firefox")); + // proposal: END what COM Interface should do + + // proposal: BEGIN what COMContext could do in it's own new method to not bother COMInterface with below + Invocation invocation{ std::move(utf8Args) }; + + std::unique_ptr command = std::make_unique(); + std::unique_ptr subCommand = command->FindSubCommand(invocation); + while (subCommand) + { + command = std::move(subCommand); + subCommand = command->FindSubCommand(invocation); + } + + command->ParseArguments(invocation, context.Args); + command->Execute(context); + // proposal: END what COMContext could do in it's own new method to not bother COMInterface with all these details + } + int CoreMain(int argc, wchar_t const** argv) try { init_apartment(); diff --git a/src/AppInstallerCLICore/ExecutionContext.h b/src/AppInstallerCLICore/ExecutionContext.h index f442a8189f..9c1bb3cc6e 100644 --- a/src/AppInstallerCLICore/ExecutionContext.h +++ b/src/AppInstallerCLICore/ExecutionContext.h @@ -101,6 +101,16 @@ namespace AppInstaller::CLI::Execution WI_ClearAllFlags(m_flags, flags); } + virtual void SetExecutionStage(uint32_t stage) + { + m_executionStage = stage; + } + + uint32_t GetExecutionStage() + { + return m_executionStage; + } + #ifndef AICLI_DISABLE_TEST_HOOKS // Enable tests to override behavior virtual bool ShouldExecuteWorkflowTask(const Workflow::WorkflowTask&) { return true; } @@ -112,5 +122,6 @@ namespace AppInstaller::CLI::Execution HRESULT m_terminationHR = S_OK; size_t m_CtrlSignalCount = 0; ContextFlag m_flags = ContextFlag::None; + uint32_t m_executionStage; }; } diff --git a/src/AppInstallerCLICore/ExecutionReporter.cpp b/src/AppInstallerCLICore/ExecutionReporter.cpp index 4e4bc298aa..951dd26e2c 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.cpp +++ b/src/AppInstallerCLICore/ExecutionReporter.cpp @@ -20,7 +20,9 @@ namespace AppInstaller::CLI::Execution m_in(inStream), m_progressBar(std::in_place, outStream, IsVTEnabled()), m_spinner(std::in_place, outStream, IsVTEnabled()) - {} + { + SetProgressSink(this); + } Reporter::~Reporter() { @@ -120,6 +122,18 @@ namespace AppInstaller::CLI::Execution m_progressBar->ShowProgress(current, maximum, type); } } + + void Reporter::BeginProgress() + { + GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::DisableShow; + ShowIndefiniteProgress(true); + }; + + void Reporter::EndProgress() + { + ShowIndefiniteProgress(false); + GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::EnableShow; + }; void Reporter::SetProgressCallback(ProgressCallback* callback) { diff --git a/src/AppInstallerCLICore/ExecutionReporter.h b/src/AppInstallerCLICore/ExecutionReporter.h index 16ae7ba327..5867484ca8 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.h +++ b/src/AppInstallerCLICore/ExecutionReporter.h @@ -87,29 +87,32 @@ namespace AppInstaller::CLI::Execution // running: shows indefinite progress if set to true, stops indefinite progress if set to false void ShowIndefiniteProgress(bool running); + // IProgressSink + void BeginProgress() override; + // IProgressSink void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override; + // IProgressSink + void EndProgress() override; + // Runs the given callable of type: auto(IProgressCallback&) template auto ExecuteWithProgress(F&& f, bool hideProgressWhenDone = false) { - GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::DisableShow; - - ProgressCallback callback(this); + IProgressSink* sink = m_progressSink.load(); + sink->BeginProgress(); + ProgressCallback callback(sink); SetProgressCallback(&callback); - ShowIndefiniteProgress(true); - auto hideProgress = wil::scope_exit([this, hideProgressWhenDone]() + auto hideProgress = wil::scope_exit([this, hideProgressWhenDone, sink]() { SetProgressCallback(nullptr); - ShowIndefiniteProgress(false); if (m_progressBar) { m_progressBar->EndProgress(hideProgressWhenDone); } - - GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::EnableShow; + sink->EndProgress(); }); return f(callback); } @@ -120,6 +123,11 @@ namespace AppInstaller::CLI::Execution // Cancels the in progress task. void CancelInProgressTask(bool force); + void SetProgressSink(IProgressSink* sink) + { + m_progressSink = sink; + } + private: // Gets whether VT is enabled for this reporter. bool IsVTEnabled() const; @@ -136,6 +144,7 @@ namespace AppInstaller::CLI::Execution std::optional m_progressBar; wil::srwlock m_progressCallbackLock; std::atomic m_progressCallback; + std::atomic m_progressSink; }; // Indirection to enable change without tracking down every place diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h index 01db30f800..680c3ba177 100644 --- a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h +++ b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h @@ -5,4 +5,5 @@ namespace AppInstaller::CLI { int CoreMain(int argc, wchar_t const** argv); + void TestCOMScenario(); } diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index 4cc06f84a2..c076dfd3fc 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -710,6 +710,7 @@ namespace AppInstaller::CLI::Workflow } Logging::SetExecutionStage(static_cast(context.Get())); + context.SetExecutionStage(static_cast(context.Get())); } } diff --git a/src/AppInstallerCLITests/TestCommon.cpp b/src/AppInstallerCLITests/TestCommon.cpp index e6ba3b3b00..c5b6a1af9d 100644 --- a/src/AppInstallerCLITests/TestCommon.cpp +++ b/src/AppInstallerCLITests/TestCommon.cpp @@ -139,6 +139,14 @@ namespace TestCommon } } + void TestProgress::BeginProgress() + { + } + + void TestProgress::EndProgress() + { + } + bool TestProgress::IsCancelled() { return false; diff --git a/src/AppInstallerCLITests/TestCommon.h b/src/AppInstallerCLITests/TestCommon.h index aab515acf3..a265bf16e0 100644 --- a/src/AppInstallerCLITests/TestCommon.h +++ b/src/AppInstallerCLITests/TestCommon.h @@ -92,7 +92,12 @@ namespace TestCommon struct TestProgress : public AppInstaller::IProgressCallback { // Inherited via IProgressCallback + void BeginProgress() override; + void OnProgress(uint64_t current, uint64_t maximum, AppInstaller::ProgressType type) override; + + void EndProgress() override; + bool IsCancelled() override; CancelFunctionRemoval SetCancellationFunction(std::function&& f) override; diff --git a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h index 0f346c1f3f..b9c109c372 100644 --- a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h +++ b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h @@ -34,6 +34,10 @@ namespace AppInstaller // Called as progress is made. // If maximum is 0, the maximum is unknown. virtual void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) = 0; + + virtual void BeginProgress() = 0; + + virtual void EndProgress() = 0; }; // Callback interface given to the worker to report to. @@ -55,6 +59,15 @@ namespace AppInstaller ProgressCallback() = default; ProgressCallback(IProgressSink* sink) : m_sink(sink) {} + void BeginProgress() override + { + IProgressSink* sink = GetSink(); + if (sink) + { + sink->BeginProgress(); + } + }; + void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override { IProgressSink* sink = GetSink(); @@ -64,6 +77,15 @@ namespace AppInstaller } } + void EndProgress() override + { + IProgressSink* sink = GetSink(); + if (sink) + { + sink->EndProgress(); + } + }; + bool IsCancelled() override { return m_cancelled.load(); From 3e4881bd03b836391acfa1c4d1c8865dee559373 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Mon, 22 Mar 2021 10:26:07 -0700 Subject: [PATCH 2/8] Incorporated review comments to the Prototype. --- .../AppInstallerCLICore.vcxproj | 1 + .../AppInstallerCLICore.vcxproj.filters | 3 + src/AppInstallerCLICore/COMContext.cpp | 37 ++++++++++- src/AppInstallerCLICore/COMContext.h | 61 ++++++++----------- src/AppInstallerCLICore/ChannelStreams.cpp | 12 ++++ src/AppInstallerCLICore/ChannelStreams.h | 14 +++++ src/AppInstallerCLICore/Core.cpp | 42 +++++-------- src/AppInstallerCLICore/ExecutionContext.cpp | 31 ++++++++++ src/AppInstallerCLICore/ExecutionContext.h | 13 +--- src/AppInstallerCLICore/ExecutionReporter.cpp | 6 +- src/AppInstallerCLICore/ExecutionReporter.h | 16 ++--- .../Workflows/WorkflowBase.cpp | 20 +----- .../Workflows/WorkflowBase.h | 1 + src/AppInstallerCLITests/TestCommon.cpp | 3 +- src/AppInstallerCLITests/TestCommon.h | 2 +- .../Public/AppInstallerProgress.h | 13 ++-- 16 files changed, 163 insertions(+), 112 deletions(-) diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 50c77827ef..96a1f29c0d 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -222,6 +222,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 15941fd28e..a475b192b1 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -274,6 +274,9 @@ Commands + + Source Files + diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp index 2991e3657e..6d2b4fc97f 100644 --- a/src/AppInstallerCLICore/COMContext.cpp +++ b/src/AppInstallerCLICore/COMContext.cpp @@ -1,3 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" #include "COMContext.h" -using namespace AppInstaller; +namespace AppInstaller +{ + void COMContext::BeginProgress() + { + m_comProgressCallback(ReportType::BeginProgress, m_current, m_maximum, m_type, m_executionPhase); + }; + + void COMContext::OnProgress(uint64_t current, uint64_t maximum, ProgressType type) + { + SetProgress(current, maximum, type); + m_comProgressCallback(ReportType::Progressing, m_current, m_maximum, m_type, m_executionPhase); + } + + void COMContext::EndProgress(bool hideProgressWhenDone) + { + UNREFERENCED_PARAMETER(hideProgressWhenDone); + m_comProgressCallback(ReportType::EndProgress, m_current, m_maximum, m_type, m_executionPhase); + }; + + void COMContext::SetExecutionStage(ExecutionStage executionPhase) + { + SetProgress(0, 0, ProgressType::None); + m_executionPhase = executionPhase; + m_comProgressCallback(ReportType::ExecutionPhaseUpdate, m_current, m_maximum, m_type, executionPhase); + } + + void COMContext::SetProgress(uint64_t current, uint64_t maximum, ProgressType type) + { + m_current = current; + m_maximum = maximum; + m_type = type; + } +} \ No newline at end of file diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h index a2c90ba783..a62e34809b 100644 --- a/src/AppInstallerCLICore/COMContext.h +++ b/src/AppInstallerCLICore/COMContext.h @@ -1,73 +1,62 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. #pragma once #include "pch.h" #include "..\AppInstallerCommonCore\Public\AppInstallerProgress.h" #include "ExecutionContext.h" +#include "Workflows/WorkflowBase.h" namespace AppInstaller { using namespace AppInstaller::CLI; + using namespace AppInstaller::CLI; + using namespace AppInstaller::Workflow; - enum ReportType + enum class ReportType: uint32_t { + ExecutionPhaseUpdate, BeginProgress, Progressing, EndProgress, - ExecutionPhaseUpdate, }; - struct COMContext : IProgressSink, Execution::Context + // NullStream constructs the Stream parameters for Context constructor + // Hence, NullStream should always precede Context in base class order of COMContext's inheritance + struct COMContext : IProgressSink, Execution::NullStream, Execution::Context { - COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) + // When no Console streams need involvement, construct NullStreams instead to pass to Context + COMContext() : Execution::NullStream(), Execution::Context(*nOut, *nIn) { Reporter.SetProgressSink(this); } - ~COMContext() {} - - // IProgressSink - void BeginProgress() override - { - m_comProgressCallback((uint32_t)ReportType::BeginProgress, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); - }; - - // IProgressSink - void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override + COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) { - SetProgress(current, maximum, type); - m_comProgressCallback((uint32_t)ReportType::Progressing, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); + Reporter.SetProgressSink(this); } + ~COMContext() = default; + // IProgressSink - void EndProgress() override - { - m_comProgressCallback((uint32_t)ReportType::EndProgress, m_current, m_maximum, (uint32_t)m_type, m_executionPhase); - }; + void BeginProgress() override; + void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override; + void EndProgress(bool hideProgressWhenDone) override; - // Execution::Context - void SetExecutionStage(uint32_t executionPhase) override - { - SetProgress(0,0,ProgressType::None); - m_executionPhase = executionPhase; - m_comProgressCallback((uint32_t)ReportType::ExecutionPhaseUpdate, m_current, m_maximum, (uint32_t)m_type, executionPhase); - } + //Execution::Context + void SetExecutionStage(ExecutionStage executionPhase); - void SetProgressCallbackFunction(std::function&& f) + void SetProgressCallbackFunction(std::function&& f) { m_comProgressCallback = std::move(f); } private: - void SetProgress(uint64_t current, uint64_t maximum, ProgressType type) - { - m_current = current; - m_maximum = maximum; - m_type = type; - } + void SetProgress(uint64_t current, uint64_t maximum, ProgressType type); - std::function m_comProgressCallback; uint64_t m_current = 0; uint64_t m_maximum = 0; ProgressType m_type = ProgressType::None; - uint32_t m_executionPhase = 0; // Instead add Worfklow::ExecutionStage::None and set that as default here + ExecutionStage m_executionPhase = ExecutionStage::None; + std::function m_comProgressCallback; }; } \ No newline at end of file diff --git a/src/AppInstallerCLICore/ChannelStreams.cpp b/src/AppInstallerCLICore/ChannelStreams.cpp index 9dc2013a80..27be39099d 100644 --- a/src/AppInstallerCLICore/ChannelStreams.cpp +++ b/src/AppInstallerCLICore/ChannelStreams.cpp @@ -100,4 +100,16 @@ namespace AppInstaller::CLI::Execution m_out << f; return *this; } + + NullStream::NullStream() + { + nOut = new std::ostream(&nullStreamBuf); + nIn = new std::istream(&nullStreamBuf); + } + + NullStream::~NullStream() + { + delete nOut; + delete nIn; + } } diff --git a/src/AppInstallerCLICore/ChannelStreams.h b/src/AppInstallerCLICore/ChannelStreams.h index d3b7df2315..457aa9ab6c 100644 --- a/src/AppInstallerCLICore/ChannelStreams.h +++ b/src/AppInstallerCLICore/ChannelStreams.h @@ -130,4 +130,18 @@ namespace AppInstaller::CLI::Execution private: BaseStream m_out; }; + + class NullStreamBuf : public std::streambuf {}; + + struct NullStream + { + NullStream(); + + ~NullStream(); + + protected: + std::ostream* nOut; + std::istream* nIn; + NullStreamBuf nullStreamBuf; + }; } diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 797c93cc30..4a178d348e 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -7,6 +7,7 @@ #include "Workflows/WorkflowBase.h" #include #include "COMContext.h" +#include "Commands/InstallCommand.h" using namespace winrt; using namespace winrt::Windows::Foundation; @@ -42,7 +43,7 @@ namespace AppInstaller::CLI }; } - void OnProgress(uint32_t reportType, uint64_t current, uint64_t maximum, uint32_t progressType, uint32_t executionPhase) + void OnProgress(ReportType reportType, uint64_t current, uint64_t maximum, ProgressType progressType, ExecutionStage executionPhase) { // Rest of this method is just Local Testing and Demo std::cout << "Execution Stage:"; @@ -68,35 +69,24 @@ namespace AppInstaller::CLI { init_apartment(); - // proposal: BEGIN what COM Interface should do - // Eventually, COM Interface has to be aware whether the caller wants CLI ouptut or not. And appropriate set null streams or std::cout/cin streams - class NullStreamBuf : public std::streambuf {}; - NullStreamBuf nullStreamBuf; - std::ostream nullOstream(&nullStreamBuf); - std::istream nullIstream(&nullStreamBuf); - - AppInstaller::COMContext context(nullOstream, nullIstream); + AppInstaller::COMContext context; context.SetProgressCallbackFunction(OnProgress); - std::vector utf8Args; - utf8Args.emplace_back(Utility::ConvertToUTF8(L"install")); - utf8Args.emplace_back(Utility::ConvertToUTF8(L"mozilla.firefox")); - // proposal: END what COM Interface should do - - // proposal: BEGIN what COMContext could do in it's own new method to not bother COMInterface with below - Invocation invocation{ std::move(utf8Args) }; - - std::unique_ptr command = std::make_unique(); - std::unique_ptr subCommand = command->FindSubCommand(invocation); - while (subCommand) + std::string str = "mozilla.firefox"; + context.Args.AddArg(Execution::Args::Type::Query, str); + RootCommand rootCommand; + InstallCommand command(rootCommand.Name()); + command.Execute(context); + + int Hr = context.GetTerminationHR(); + if (SUCCEEDED(Hr)) { - command = std::move(subCommand); - subCommand = command->FindSubCommand(invocation); + // SUCCEEDED + } + else + { + std::cout << "Failure Hresult = " << Hr; } - - command->ParseArguments(invocation, context.Args); - command->Execute(context); - // proposal: END what COMContext could do in it's own new method to not bother COMInterface with all these details } int CoreMain(int argc, wchar_t const** argv) try diff --git a/src/AppInstallerCLICore/ExecutionContext.cpp b/src/AppInstallerCLICore/ExecutionContext.cpp index cba9155b47..97811eccb1 100644 --- a/src/AppInstallerCLICore/ExecutionContext.cpp +++ b/src/AppInstallerCLICore/ExecutionContext.cpp @@ -126,4 +126,35 @@ namespace AppInstaller::CLI::Execution m_isTerminated = true; m_terminationHR = hr; } + + void Context::SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward) + { + m_executionStage = stage; + + if (!Contains(Data::ExecutionStage)) + { + Add(stage); + } + else if (Get() == stage) + { + return; + } + else if (Get() < stage || allowBackward) + { + Get() = stage; + } + else + { + THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), "Reporting ExecutionStage to an earlier Stage without allowBackward as true"); + } + + // When Telemetry and Diagnostics will be moved to Execution::Context, the below immediate line will not be needed + Logging::SetExecutionStage(static_cast(Get())); + SetExecutionStage(Get()); + } + + void Context::SetExecutionStage(Workflow::ExecutionStage stage) + { + UNREFERENCED_PARAMETER(stage); + } } diff --git a/src/AppInstallerCLICore/ExecutionContext.h b/src/AppInstallerCLICore/ExecutionContext.h index 9c1bb3cc6e..0aae31d396 100644 --- a/src/AppInstallerCLICore/ExecutionContext.h +++ b/src/AppInstallerCLICore/ExecutionContext.h @@ -101,15 +101,8 @@ namespace AppInstaller::CLI::Execution WI_ClearAllFlags(m_flags, flags); } - virtual void SetExecutionStage(uint32_t stage) - { - m_executionStage = stage; - } - - uint32_t GetExecutionStage() - { - return m_executionStage; - } + void SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward); + virtual void SetExecutionStage(Workflow::ExecutionStage stage); #ifndef AICLI_DISABLE_TEST_HOOKS // Enable tests to override behavior @@ -122,6 +115,6 @@ namespace AppInstaller::CLI::Execution HRESULT m_terminationHR = S_OK; size_t m_CtrlSignalCount = 0; ContextFlag m_flags = ContextFlag::None; - uint32_t m_executionStage; + Workflow::ExecutionStage m_executionStage = Workflow::ExecutionStage::None; }; } diff --git a/src/AppInstallerCLICore/ExecutionReporter.cpp b/src/AppInstallerCLICore/ExecutionReporter.cpp index 951dd26e2c..91dd502c26 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.cpp +++ b/src/AppInstallerCLICore/ExecutionReporter.cpp @@ -129,10 +129,14 @@ namespace AppInstaller::CLI::Execution ShowIndefiniteProgress(true); }; - void Reporter::EndProgress() + void Reporter::EndProgress(bool hideProgressWhenDone) { ShowIndefiniteProgress(false); GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::EnableShow; + if (m_progressBar) + { + m_progressBar->EndProgress(hideProgressWhenDone); + } }; void Reporter::SetProgressCallback(ProgressCallback* callback) diff --git a/src/AppInstallerCLICore/ExecutionReporter.h b/src/AppInstallerCLICore/ExecutionReporter.h index 5867484ca8..a6446b31a6 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.h +++ b/src/AppInstallerCLICore/ExecutionReporter.h @@ -89,30 +89,22 @@ namespace AppInstaller::CLI::Execution // IProgressSink void BeginProgress() override; - - // IProgressSink void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override; - - // IProgressSink - void EndProgress() override; + void EndProgress(bool hideProgressWhenDone) override; // Runs the given callable of type: auto(IProgressCallback&) template auto ExecuteWithProgress(F&& f, bool hideProgressWhenDone = false) { IProgressSink* sink = m_progressSink.load(); - sink->BeginProgress(); ProgressCallback callback(sink); SetProgressCallback(&callback); + sink->BeginProgress(); - auto hideProgress = wil::scope_exit([this, hideProgressWhenDone, sink]() + auto hideProgress = wil::scope_exit([this, hideProgressWhenDone]() { SetProgressCallback(nullptr); - if (m_progressBar) - { - m_progressBar->EndProgress(hideProgressWhenDone); - } - sink->EndProgress(); + m_progressSink.load()->EndProgress(hideProgressWhenDone); }); return f(callback); } diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index c076dfd3fc..118afc08d4 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -692,25 +692,7 @@ namespace AppInstaller::CLI::Workflow void ReportExecutionStage::operator()(Execution::Context& context) const { - if (!context.Contains(Execution::Data::ExecutionStage)) - { - context.Add(m_stage); - } - else if (context.Get() == m_stage) - { - return; - } - else if (context.Get() < m_stage || m_allowBackward) - { - context.Get() = m_stage; - } - else - { - THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), "Reporting ExecutionStage to an earlier Stage without allowBackward as true"); - } - - Logging::SetExecutionStage(static_cast(context.Get())); - context.SetExecutionStage(static_cast(context.Get())); + context.SetExecutionStage(m_stage, m_allowBackward); } } diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.h b/src/AppInstallerCLICore/Workflows/WorkflowBase.h index 51fdb10c7b..bf77615af8 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.h +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.h @@ -19,6 +19,7 @@ namespace AppInstaller::CLI::Workflow // Values are ordered in a typical workflow stages enum class ExecutionStage : uint32_t { + None = 0, ParseArgs = 1000, Discovery = 2000, Download = 3000, diff --git a/src/AppInstallerCLITests/TestCommon.cpp b/src/AppInstallerCLITests/TestCommon.cpp index c5b6a1af9d..04b032348a 100644 --- a/src/AppInstallerCLITests/TestCommon.cpp +++ b/src/AppInstallerCLITests/TestCommon.cpp @@ -143,8 +143,9 @@ namespace TestCommon { } - void TestProgress::EndProgress() + void TestProgress::EndProgress(bool hideProgressWhenDone) { + _Unreferenced_parameter_(hideProgressWhenDone); } bool TestProgress::IsCancelled() diff --git a/src/AppInstallerCLITests/TestCommon.h b/src/AppInstallerCLITests/TestCommon.h index a265bf16e0..77852f38e0 100644 --- a/src/AppInstallerCLITests/TestCommon.h +++ b/src/AppInstallerCLITests/TestCommon.h @@ -96,7 +96,7 @@ namespace TestCommon void OnProgress(uint64_t current, uint64_t maximum, AppInstaller::ProgressType type) override; - void EndProgress() override; + void EndProgress(bool hideProgressWhenDone) override; bool IsCancelled() override; CancelFunctionRemoval SetCancellationFunction(std::function&& f) override; diff --git a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h index b9c109c372..59e1980433 100644 --- a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h +++ b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h @@ -18,7 +18,7 @@ namespace AppInstaller } // The semantic meaning of the progress values. - enum class ProgressType + enum class ProgressType: uint32_t { // Progress will not be sent. None, @@ -31,13 +31,16 @@ namespace AppInstaller // of cancel state. struct IProgressSink { - // Called as progress is made. + // Called as progress is made within the current execution stage. // If maximum is 0, the maximum is unknown. virtual void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) = 0; + // Called as progress begins for the current execution stage. virtual void BeginProgress() = 0; - virtual void EndProgress() = 0; + // Called whenever progress ends for the current execution stage, + // even if it ends before the completion of current execution stage due to any reason. + virtual void EndProgress(bool hideProgressWhenDone) = 0; }; // Callback interface given to the worker to report to. @@ -77,12 +80,12 @@ namespace AppInstaller } } - void EndProgress() override + void EndProgress(bool hideProgressWhenDone) override { IProgressSink* sink = GetSink(); if (sink) { - sink->EndProgress(); + sink->EndProgress(hideProgressWhenDone); } }; From d705fda46960ef2231949f4e5e39ab2393caf29d Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 25 Mar 2021 02:41:47 -0700 Subject: [PATCH 3/8] Incorporate Feedback comments --- src/AppInstallerCLI/AppInstallerCLI.vcxproj | 2 +- .../AppInstallerCLICore.vcxproj | 1 + .../AppInstallerCLICore.vcxproj.filters | 3 ++ src/AppInstallerCLICore/COMContext.cpp | 7 +++++ src/AppInstallerCLICore/COMContext.h | 29 ++++++++++++++----- src/AppInstallerCLICore/ChannelStreams.cpp | 12 -------- src/AppInstallerCLICore/ChannelStreams.h | 14 --------- src/AppInstallerCLICore/Core.cpp | 25 +++++++++------- src/AppInstallerCLICore/ExecutionContext.cpp | 29 +++++++------------ src/AppInstallerCLICore/ExecutionContext.h | 3 +- .../ExecutionContextData.h | 7 ----- src/AppInstallerCLICore/ExecutionReporter.cpp | 2 +- .../Public/AppInstallerCLICoreExecute.h | 8 +++++ .../Workflows/WorkflowBase.cpp | 2 +- .../Workflows/WorkflowBase.h | 2 +- .../Public/AppInstallerProgress.h | 7 ++--- 16 files changed, 75 insertions(+), 78 deletions(-) create mode 100644 src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index 541c8cd1eb..9bc78fea0a 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -128,7 +128,7 @@ _DEBUG;%(PreprocessorDefinitions) $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) - $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\AppInstallerCLICore;$(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) true true true diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 96a1f29c0d..5f07326896 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -201,6 +201,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index a475b192b1..9caf3e0c5d 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -155,6 +155,9 @@ Public + + Public + diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp index 6d2b4fc97f..2ae925619d 100644 --- a/src/AppInstallerCLICore/COMContext.cpp +++ b/src/AppInstallerCLICore/COMContext.cpp @@ -5,6 +5,13 @@ namespace AppInstaller { + + NullStream::NullStream() + { + null_Out.reset(new std::ostream(&nullStreamBuf)); + null_In.reset(new std::istream(&nullStreamBuf)); + } + void COMContext::BeginProgress() { m_comProgressCallback(ReportType::BeginProgress, m_current, m_maximum, m_type, m_executionPhase); diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h index a62e34809b..8e2199c7c7 100644 --- a/src/AppInstallerCLICore/COMContext.h +++ b/src/AppInstallerCLICore/COMContext.h @@ -8,7 +8,6 @@ namespace AppInstaller { - using namespace AppInstaller::CLI; using namespace AppInstaller::CLI; using namespace AppInstaller::Workflow; @@ -20,17 +19,31 @@ namespace AppInstaller EndProgress, }; + class NullStreamBuf : public std::streambuf {}; + + struct NullStream + { + NullStream(); + + ~NullStream() = default; + + protected: + NullStreamBuf nullStreamBuf; + std::unique_ptr null_Out; + std::unique_ptr null_In; + }; + // NullStream constructs the Stream parameters for Context constructor // Hence, NullStream should always precede Context in base class order of COMContext's inheritance - struct COMContext : IProgressSink, Execution::NullStream, Execution::Context - { + struct COMContext : IProgressSink, NullStream, Execution::Context + { // When no Console streams need involvement, construct NullStreams instead to pass to Context - COMContext() : Execution::NullStream(), Execution::Context(*nOut, *nIn) + COMContext() : NullStream(), Execution::Context(*null_Out, *null_In) { Reporter.SetProgressSink(this); } - COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) + COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) { Reporter.SetProgressSink(this); } @@ -50,13 +63,13 @@ namespace AppInstaller m_comProgressCallback = std::move(f); } - private: + private: void SetProgress(uint64_t current, uint64_t maximum, ProgressType type); uint64_t m_current = 0; uint64_t m_maximum = 0; ProgressType m_type = ProgressType::None; - ExecutionStage m_executionPhase = ExecutionStage::None; + ExecutionStage m_executionPhase = ExecutionStage::Initial; std::function m_comProgressCallback; - }; + }; } \ No newline at end of file diff --git a/src/AppInstallerCLICore/ChannelStreams.cpp b/src/AppInstallerCLICore/ChannelStreams.cpp index 27be39099d..9dc2013a80 100644 --- a/src/AppInstallerCLICore/ChannelStreams.cpp +++ b/src/AppInstallerCLICore/ChannelStreams.cpp @@ -100,16 +100,4 @@ namespace AppInstaller::CLI::Execution m_out << f; return *this; } - - NullStream::NullStream() - { - nOut = new std::ostream(&nullStreamBuf); - nIn = new std::istream(&nullStreamBuf); - } - - NullStream::~NullStream() - { - delete nOut; - delete nIn; - } } diff --git a/src/AppInstallerCLICore/ChannelStreams.h b/src/AppInstallerCLICore/ChannelStreams.h index 457aa9ab6c..d3b7df2315 100644 --- a/src/AppInstallerCLICore/ChannelStreams.h +++ b/src/AppInstallerCLICore/ChannelStreams.h @@ -130,18 +130,4 @@ namespace AppInstaller::CLI::Execution private: BaseStream m_out; }; - - class NullStreamBuf : public std::streambuf {}; - - struct NullStream - { - NullStream(); - - ~NullStream(); - - protected: - std::ostream* nOut; - std::istream* nIn; - NullStreamBuf nullStreamBuf; - }; } diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 4a178d348e..36420011aa 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -2,6 +2,7 @@ // Licensed under the MIT License. #include "pch.h" #include "Public/AppInstallerCLICore.h" +#include "Public/AppInstallerCLICoreExecute.h" #include "Commands/RootCommand.h" #include "ExecutionContext.h" #include "Workflows/WorkflowBase.h" @@ -75,10 +76,9 @@ namespace AppInstaller::CLI std::string str = "mozilla.firefox"; context.Args.AddArg(Execution::Args::Type::Query, str); RootCommand rootCommand; - InstallCommand command(rootCommand.Name()); - command.Execute(context); - - int Hr = context.GetTerminationHR(); + std::unique_ptr command = std::make_unique(rootCommand.Name()); + + int Hr = Execute(context, command); if (SUCCEEDED(Hr)) { // SUCCEEDED @@ -163,6 +163,17 @@ namespace AppInstaller::CLI return APPINSTALLER_CLI_ERROR_INVALID_CL_ARGUMENTS; } + return Execute(context, command); + } + // End of the line exceptions that are not ever expected. + // Telemetry cannot be reliable beyond this point, so don't let these happen. + catch (...) + { + return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR; + } + + int Execute(Execution::Context& context, std::unique_ptr& command) + { try { if (!Settings::User().GetWarnings().empty()) @@ -215,11 +226,5 @@ namespace AppInstaller::CLI return context.GetTerminationHR(); } - // End of the line exceptions that are not ever expected. - // Telemetry cannot be reliable beyond this point, so don't let these happen. - catch (...) - { - return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR; - } } diff --git a/src/AppInstallerCLICore/ExecutionContext.cpp b/src/AppInstallerCLICore/ExecutionContext.cpp index 97811eccb1..5627dc60b6 100644 --- a/src/AppInstallerCLICore/ExecutionContext.cpp +++ b/src/AppInstallerCLICore/ExecutionContext.cpp @@ -126,35 +126,28 @@ namespace AppInstaller::CLI::Execution m_isTerminated = true; m_terminationHR = hr; } - + void Context::SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward) - { - m_executionStage = stage; - - if (!Contains(Data::ExecutionStage)) - { - Add(stage); - } - else if (Get() == stage) + { + if (GetExecutionStage() == stage) { return; } - else if (Get() < stage || allowBackward) - { - Get() = stage; - } - else + else if (GetExecutionStage() > stage && !allowBackward) { THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), "Reporting ExecutionStage to an earlier Stage without allowBackward as true"); } - // When Telemetry and Diagnostics will be moved to Execution::Context, the below immediate line will not be needed - Logging::SetExecutionStage(static_cast(Get())); - SetExecutionStage(Get()); + return SetExecutionStage(stage); } void Context::SetExecutionStage(Workflow::ExecutionStage stage) { - UNREFERENCED_PARAMETER(stage); + m_executionStage = stage; + } + + Workflow::ExecutionStage Context::GetExecutionStage() + { + return m_executionStage; } } diff --git a/src/AppInstallerCLICore/ExecutionContext.h b/src/AppInstallerCLICore/ExecutionContext.h index 0aae31d396..ce3674c128 100644 --- a/src/AppInstallerCLICore/ExecutionContext.h +++ b/src/AppInstallerCLICore/ExecutionContext.h @@ -103,6 +103,7 @@ namespace AppInstaller::CLI::Execution void SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward); virtual void SetExecutionStage(Workflow::ExecutionStage stage); + Workflow::ExecutionStage GetExecutionStage(); #ifndef AICLI_DISABLE_TEST_HOOKS // Enable tests to override behavior @@ -115,6 +116,6 @@ namespace AppInstaller::CLI::Execution HRESULT m_terminationHR = S_OK; size_t m_CtrlSignalCount = 0; ContextFlag m_flags = ContextFlag::None; - Workflow::ExecutionStage m_executionStage = Workflow::ExecutionStage::None; + Workflow::ExecutionStage m_executionStage = Workflow::ExecutionStage::Initial; }; } diff --git a/src/AppInstallerCLICore/ExecutionContextData.h b/src/AppInstallerCLICore/ExecutionContextData.h index 7349c6fe16..2bfd806cb6 100644 --- a/src/AppInstallerCLICore/ExecutionContextData.h +++ b/src/AppInstallerCLICore/ExecutionContextData.h @@ -36,7 +36,6 @@ namespace AppInstaller::CLI::Execution InstallerArgs, CompletionData, InstalledPackageVersion, - ExecutionStage, UninstallString, PackageFamilyNames, ProductCodes, @@ -137,12 +136,6 @@ namespace AppInstaller::CLI::Execution using value_t = std::shared_ptr; }; - template <> - struct DataMapping - { - using value_t = Workflow::ExecutionStage; - }; - template <> struct DataMapping { diff --git a/src/AppInstallerCLICore/ExecutionReporter.cpp b/src/AppInstallerCLICore/ExecutionReporter.cpp index 91dd502c26..ebffe59efa 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.cpp +++ b/src/AppInstallerCLICore/ExecutionReporter.cpp @@ -132,11 +132,11 @@ namespace AppInstaller::CLI::Execution void Reporter::EndProgress(bool hideProgressWhenDone) { ShowIndefiniteProgress(false); - GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::EnableShow; if (m_progressBar) { m_progressBar->EndProgress(hideProgressWhenDone); } + GetBasicOutputStream() << VirtualTerminal::Cursor::Visibility::EnableShow; }; void Reporter::SetProgressCallback(ProgressCallback* callback) diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h b/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h new file mode 100644 index 0000000000..67e6987bca --- /dev/null +++ b/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h @@ -0,0 +1,8 @@ +#pragma once +#include "ExecutionContext.h" +#include "Command.h" + +namespace AppInstaller::CLI +{ + int Execute(Execution::Context& context, std::unique_ptr& command); +} \ No newline at end of file diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index 118afc08d4..4a1b4f145d 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -692,7 +692,7 @@ namespace AppInstaller::CLI::Workflow void ReportExecutionStage::operator()(Execution::Context& context) const { - context.SetExecutionStage(m_stage, m_allowBackward); + context.SetExecutionStage(m_stage); } } diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.h b/src/AppInstallerCLICore/Workflows/WorkflowBase.h index bf77615af8..49ee23efff 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.h +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.h @@ -19,7 +19,7 @@ namespace AppInstaller::CLI::Workflow // Values are ordered in a typical workflow stages enum class ExecutionStage : uint32_t { - None = 0, + Initial = 0, ParseArgs = 1000, Discovery = 2000, Download = 3000, diff --git a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h index 59e1980433..b58b5f4b65 100644 --- a/src/AppInstallerCommonCore/Public/AppInstallerProgress.h +++ b/src/AppInstallerCommonCore/Public/AppInstallerProgress.h @@ -31,15 +31,14 @@ namespace AppInstaller // of cancel state. struct IProgressSink { - // Called as progress is made within the current execution stage. + // Called as progress is made. // If maximum is 0, the maximum is unknown. virtual void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) = 0; - // Called as progress begins for the current execution stage. + // Called as progress begins. virtual void BeginProgress() = 0; - // Called whenever progress ends for the current execution stage, - // even if it ends before the completion of current execution stage due to any reason. + // Called as progress ends. virtual void EndProgress(bool hideProgressWhenDone) = 0; }; From f6713270107da588d690815839fbad8f42d6c4f4 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 25 Mar 2021 14:59:16 -0700 Subject: [PATCH 4/8] Removing Dev Test Code for formal PR --- src/AppInstallerCLI/AppInstallerCLI.vcxproj | 2 +- src/AppInstallerCLI/main.cpp | 8 +--- src/AppInstallerCLICore/Core.cpp | 46 ------------------- .../Public/AppInstallerCLICore.h | 1 - 4 files changed, 3 insertions(+), 54 deletions(-) diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index 9bc78fea0a..541c8cd1eb 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -128,7 +128,7 @@ _DEBUG;%(PreprocessorDefinitions) $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) - $(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\AppInstallerCLICore;$(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) + $(ProjectDir);..\AppInstallerCLICore\Public\;%(AdditionalIncludeDirectories) true true true diff --git a/src/AppInstallerCLI/main.cpp b/src/AppInstallerCLI/main.cpp index e6e054b174..8b06f12292 100644 --- a/src/AppInstallerCLI/main.cpp +++ b/src/AppInstallerCLI/main.cpp @@ -2,11 +2,7 @@ // Licensed under the MIT License. #include -//int wmain(int argc, wchar_t const** argv) -int wmain() +int wmain(int argc, wchar_t const** argv) { - AppInstaller::CLI::TestCOMScenario(); - return 0; - //return AppInstaller::CLI::CoreMain(argc, argv); + return AppInstaller::CLI::CoreMain(argc, argv); } - diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 36420011aa..7ddf646494 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -7,7 +7,6 @@ #include "ExecutionContext.h" #include "Workflows/WorkflowBase.h" #include -#include "COMContext.h" #include "Commands/InstallCommand.h" using namespace winrt; @@ -44,51 +43,6 @@ namespace AppInstaller::CLI }; } - void OnProgress(ReportType reportType, uint64_t current, uint64_t maximum, ProgressType progressType, ExecutionStage executionPhase) - { - // Rest of this method is just Local Testing and Demo - std::cout << "Execution Stage:"; - std::cout << executionPhase; - std::cout << " reportType: "; - std::cout << reportType; - std::cout << " current: "; - std::cout << current; - std::cout << " maximum: "; - std::cout << maximum; - std::cout << " ProgressType : "; - std::cout << (uint32_t)progressType; - std::cout << "\n"; - - if (current == maximum) - { - // Current Execution Phase is Complete - std::cout << "Current Execution Phase is now complete\n"; - } - } - - void TestCOMScenario() - { - init_apartment(); - - AppInstaller::COMContext context; - context.SetProgressCallbackFunction(OnProgress); - - std::string str = "mozilla.firefox"; - context.Args.AddArg(Execution::Args::Type::Query, str); - RootCommand rootCommand; - std::unique_ptr command = std::make_unique(rootCommand.Name()); - - int Hr = Execute(context, command); - if (SUCCEEDED(Hr)) - { - // SUCCEEDED - } - else - { - std::cout << "Failure Hresult = " << Hr; - } - } - int CoreMain(int argc, wchar_t const** argv) try { init_apartment(); diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h index 680c3ba177..01db30f800 100644 --- a/src/AppInstallerCLICore/Public/AppInstallerCLICore.h +++ b/src/AppInstallerCLICore/Public/AppInstallerCLICore.h @@ -5,5 +5,4 @@ namespace AppInstaller::CLI { int CoreMain(int argc, wchar_t const** argv); - void TestCOMScenario(); } From a7f704bace5ebc91169b97861fd6d5fbca09f527 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 25 Mar 2021 15:11:28 -0700 Subject: [PATCH 5/8] Fixing one self comment --- src/AppInstallerCLICore/Workflows/WorkflowBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp index 4a1b4f145d..118afc08d4 100644 --- a/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp +++ b/src/AppInstallerCLICore/Workflows/WorkflowBase.cpp @@ -692,7 +692,7 @@ namespace AppInstaller::CLI::Workflow void ReportExecutionStage::operator()(Execution::Context& context) const { - context.SetExecutionStage(m_stage); + context.SetExecutionStage(m_stage, m_allowBackward); } } From 3a3355883ba86a282f58f9d7639d9c6d9cd19a25 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 25 Mar 2021 15:37:50 -0700 Subject: [PATCH 6/8] Addressing SpellCheck pipeline failure --- .github/actions/spelling/expect.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 60f9fd1b83..e23a548581 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -210,6 +210,7 @@ SRL srs Standalone startswith +StreamBuf strtoull subdir subkey From 10b3e55ffcfd16c1d62e46f3579c6c6ff60469e3 Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Thu, 25 Mar 2021 15:41:23 -0700 Subject: [PATCH 7/8] Fixing Spellcheck case --- .github/actions/spelling/expect.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index e23a548581..4aa912f131 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -210,7 +210,7 @@ SRL srs Standalone startswith -StreamBuf +streambuf strtoull subdir subkey From b90b2ca837225e7c5caf1654c433b6d3eeb642fb Mon Sep 17 00:00:00 2001 From: Santosh Chintalapati Date: Fri, 26 Mar 2021 17:03:58 -0700 Subject: [PATCH 8/8] Incorporated review comments --- .../AppInstallerCLICore.vcxproj | 1 - .../AppInstallerCLICore.vcxproj.filters | 3 - src/AppInstallerCLICore/COMContext.cpp | 30 ++++------ src/AppInstallerCLICore/COMContext.h | 32 +++++------ src/AppInstallerCLICore/Command.cpp | 55 ++++++++++++++++++ src/AppInstallerCLICore/Command.h | 2 + src/AppInstallerCLICore/Core.cpp | 57 ------------------- src/AppInstallerCLICore/ExecutionContext.cpp | 14 +---- src/AppInstallerCLICore/ExecutionContext.h | 4 +- .../Public/AppInstallerCLICoreExecute.h | 8 --- src/AppInstallerCLITests/TestCommon.cpp | 3 +- src/AppInstallerCLITests/TestCommon.h | 2 +- 12 files changed, 85 insertions(+), 126 deletions(-) delete mode 100644 src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 5f07326896..96a1f29c0d 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -201,7 +201,6 @@ - diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 9caf3e0c5d..a475b192b1 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -155,9 +155,6 @@ Public - - Public - diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp index 2ae925619d..ee2cb11fea 100644 --- a/src/AppInstallerCLICore/COMContext.cpp +++ b/src/AppInstallerCLICore/COMContext.cpp @@ -8,38 +8,28 @@ namespace AppInstaller NullStream::NullStream() { - null_Out.reset(new std::ostream(&nullStreamBuf)); - null_In.reset(new std::istream(&nullStreamBuf)); + m_nullOut.reset(new std::ostream(&m_nullStreamBuf)); + m_nullIn.reset(new std::istream(&m_nullStreamBuf)); } void COMContext::BeginProgress() { - m_comProgressCallback(ReportType::BeginProgress, m_current, m_maximum, m_type, m_executionPhase); + m_comProgressCallback(ReportType::BeginProgress, 0, 0, ProgressType::None, m_executionStage); }; - void COMContext::OnProgress(uint64_t current, uint64_t maximum, ProgressType type) + void COMContext::OnProgress(uint64_t current, uint64_t maximum, ProgressType progressType) { - SetProgress(current, maximum, type); - m_comProgressCallback(ReportType::Progressing, m_current, m_maximum, m_type, m_executionPhase); + m_comProgressCallback(ReportType::Progressing, current, maximum, progressType, m_executionStage); } - void COMContext::EndProgress(bool hideProgressWhenDone) + void COMContext::EndProgress(bool) { - UNREFERENCED_PARAMETER(hideProgressWhenDone); - m_comProgressCallback(ReportType::EndProgress, m_current, m_maximum, m_type, m_executionPhase); + m_comProgressCallback(ReportType::EndProgress, 0, 0, ProgressType::None, m_executionStage); }; - void COMContext::SetExecutionStage(ExecutionStage executionPhase) + void COMContext::SetExecutionStage(CLI::Workflow::ExecutionStage executionStage, bool) { - SetProgress(0, 0, ProgressType::None); - m_executionPhase = executionPhase; - m_comProgressCallback(ReportType::ExecutionPhaseUpdate, m_current, m_maximum, m_type, executionPhase); - } - - void COMContext::SetProgress(uint64_t current, uint64_t maximum, ProgressType type) - { - m_current = current; - m_maximum = maximum; - m_type = type; + m_executionStage = executionStage; + m_comProgressCallback(ReportType::ExecutionPhaseUpdate, 0, 0, ProgressType::None, m_executionStage); } } \ No newline at end of file diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h index 8e2199c7c7..bcc4d1a7bb 100644 --- a/src/AppInstallerCLICore/COMContext.h +++ b/src/AppInstallerCLICore/COMContext.h @@ -8,9 +8,6 @@ namespace AppInstaller { - using namespace AppInstaller::CLI; - using namespace AppInstaller::Workflow; - enum class ReportType: uint32_t { ExecutionPhaseUpdate, @@ -28,22 +25,24 @@ namespace AppInstaller ~NullStream() = default; protected: - NullStreamBuf nullStreamBuf; - std::unique_ptr null_Out; - std::unique_ptr null_In; + NullStreamBuf m_nullStreamBuf; + std::unique_ptr m_nullOut; + std::unique_ptr m_nullIn; }; + typedef std::function ProgressCallBackFunction; + // NullStream constructs the Stream parameters for Context constructor // Hence, NullStream should always precede Context in base class order of COMContext's inheritance - struct COMContext : IProgressSink, NullStream, Execution::Context + struct COMContext : IProgressSink, NullStream, CLI::Execution::Context { // When no Console streams need involvement, construct NullStreams instead to pass to Context - COMContext() : NullStream(), Execution::Context(*null_Out, *null_In) + COMContext() : NullStream(), CLI::Execution::Context(*m_nullOut, *m_nullIn) { Reporter.SetProgressSink(this); } - COMContext(std::ostream& out, std::istream& in) : Execution::Context(out, in) + COMContext(std::ostream& out, std::istream& in) : CLI::Execution::Context(out, in) { Reporter.SetProgressSink(this); } @@ -53,23 +52,18 @@ namespace AppInstaller // IProgressSink void BeginProgress() override; void OnProgress(uint64_t current, uint64_t maximum, ProgressType type) override; - void EndProgress(bool hideProgressWhenDone) override; + void EndProgress(bool) override; //Execution::Context - void SetExecutionStage(ExecutionStage executionPhase); + void SetExecutionStage(CLI::Workflow::ExecutionStage executionPhase, bool); - void SetProgressCallbackFunction(std::function&& f) + void SetProgressCallbackFunction(ProgressCallBackFunction&& f) { m_comProgressCallback = std::move(f); } private: - void SetProgress(uint64_t current, uint64_t maximum, ProgressType type); - - uint64_t m_current = 0; - uint64_t m_maximum = 0; - ProgressType m_type = ProgressType::None; - ExecutionStage m_executionPhase = ExecutionStage::Initial; - std::function m_comProgressCallback; + CLI::Workflow::ExecutionStage m_executionStage = CLI::Workflow::ExecutionStage::Initial; + ProgressCallBackFunction m_comProgressCallback; }; } \ No newline at end of file diff --git a/src/AppInstallerCLICore/Command.cpp b/src/AppInstallerCLICore/Command.cpp index abefea0bdb..efaaacd2bc 100644 --- a/src/AppInstallerCLICore/Command.cpp +++ b/src/AppInstallerCLICore/Command.cpp @@ -770,4 +770,59 @@ namespace AppInstaller::CLI return arguments; } + + int Execute(Execution::Context& context, std::unique_ptr& command) + { + try + { + if (!Settings::User().GetWarnings().empty()) + { + context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl; + } + + command->Execute(context); + } + // Exceptions that may occur in the process of executing an arbitrary command + catch (const wil::ResultException& re) + { + // Even though they are logged at their source, log again here for completeness. + Logging::Telemetry().LogException(command->FullName(), "wil::ResultException", re.what()); + context.Reporter.Error() << + Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << + GetUserPresentableMessage(re) << std::endl; + return re.GetErrorCode(); + } + catch (const winrt::hresult_error& hre) + { + std::string message = GetUserPresentableMessage(hre); + Logging::Telemetry().LogException(command->FullName(), "winrt::hresult_error", message); + context.Reporter.Error() << + Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << + message << std::endl; + return hre.code(); + } + catch (const std::exception& e) + { + Logging::Telemetry().LogException(command->FullName(), "std::exception", e.what()); + context.Reporter.Error() << + Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << + GetUserPresentableMessage(e) << std::endl; + return APPINSTALLER_CLI_ERROR_COMMAND_FAILED; + } + catch (...) + { + LOG_CAUGHT_EXCEPTION(); + Logging::Telemetry().LogException(command->FullName(), "unknown", {}); + context.Reporter.Error() << + Resource::String::UnexpectedErrorExecutingCommand << " ???"_liv << std::endl; + return APPINSTALLER_CLI_ERROR_COMMAND_FAILED; + } + + if (SUCCEEDED(context.GetTerminationHR())) + { + Logging::Telemetry().LogCommandSuccess(command->FullName()); + } + + return context.GetTerminationHR(); + } } diff --git a/src/AppInstallerCLICore/Command.h b/src/AppInstallerCLICore/Command.h index 478d5f539a..db1d6616b9 100644 --- a/src/AppInstallerCLICore/Command.h +++ b/src/AppInstallerCLICore/Command.h @@ -112,4 +112,6 @@ namespace AppInstaller::CLI return result; } + + int Execute(Execution::Context& context, std::unique_ptr& command); } diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 7ddf646494..01d68c77ae 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -2,7 +2,6 @@ // Licensed under the MIT License. #include "pch.h" #include "Public/AppInstallerCLICore.h" -#include "Public/AppInstallerCLICoreExecute.h" #include "Commands/RootCommand.h" #include "ExecutionContext.h" #include "Workflows/WorkflowBase.h" @@ -125,60 +124,4 @@ namespace AppInstaller::CLI { return APPINSTALLER_CLI_ERROR_INTERNAL_ERROR; } - - int Execute(Execution::Context& context, std::unique_ptr& command) - { - try - { - if (!Settings::User().GetWarnings().empty()) - { - context.Reporter.Warn() << Resource::String::SettingsWarnings << std::endl; - } - - command->Execute(context); - } - // Exceptions that may occur in the process of executing an arbitrary command - catch (const wil::ResultException& re) - { - // Even though they are logged at their source, log again here for completeness. - Logging::Telemetry().LogException(command->FullName(), "wil::ResultException", re.what()); - context.Reporter.Error() << - Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << - GetUserPresentableMessage(re) << std::endl; - return re.GetErrorCode(); - } - catch (const winrt::hresult_error& hre) - { - std::string message = GetUserPresentableMessage(hre); - Logging::Telemetry().LogException(command->FullName(), "winrt::hresult_error", message); - context.Reporter.Error() << - Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << - message << std::endl; - return hre.code(); - } - catch (const std::exception& e) - { - Logging::Telemetry().LogException(command->FullName(), "std::exception", e.what()); - context.Reporter.Error() << - Resource::String::UnexpectedErrorExecutingCommand << ' ' << std::endl << - GetUserPresentableMessage(e) << std::endl; - return APPINSTALLER_CLI_ERROR_COMMAND_FAILED; - } - catch (...) - { - LOG_CAUGHT_EXCEPTION(); - Logging::Telemetry().LogException(command->FullName(), "unknown", {}); - context.Reporter.Error() << - Resource::String::UnexpectedErrorExecutingCommand << " ???"_liv << std::endl; - return APPINSTALLER_CLI_ERROR_COMMAND_FAILED; - } - - if (SUCCEEDED(context.GetTerminationHR())) - { - Logging::Telemetry().LogCommandSuccess(command->FullName()); - } - - return context.GetTerminationHR(); - } - } diff --git a/src/AppInstallerCLICore/ExecutionContext.cpp b/src/AppInstallerCLICore/ExecutionContext.cpp index 5627dc60b6..47385895ce 100644 --- a/src/AppInstallerCLICore/ExecutionContext.cpp +++ b/src/AppInstallerCLICore/ExecutionContext.cpp @@ -129,25 +129,15 @@ namespace AppInstaller::CLI::Execution void Context::SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward) { - if (GetExecutionStage() == stage) + if (m_executionStage == stage) { return; } - else if (GetExecutionStage() > stage && !allowBackward) + else if (m_executionStage > stage && !allowBackward) { THROW_HR_MSG(HRESULT_FROM_WIN32(ERROR_INVALID_STATE), "Reporting ExecutionStage to an earlier Stage without allowBackward as true"); } - return SetExecutionStage(stage); - } - - void Context::SetExecutionStage(Workflow::ExecutionStage stage) - { m_executionStage = stage; } - - Workflow::ExecutionStage Context::GetExecutionStage() - { - return m_executionStage; - } } diff --git a/src/AppInstallerCLICore/ExecutionContext.h b/src/AppInstallerCLICore/ExecutionContext.h index ce3674c128..67777efe9a 100644 --- a/src/AppInstallerCLICore/ExecutionContext.h +++ b/src/AppInstallerCLICore/ExecutionContext.h @@ -101,9 +101,7 @@ namespace AppInstaller::CLI::Execution WI_ClearAllFlags(m_flags, flags); } - void SetExecutionStage(Workflow::ExecutionStage stage, bool allowBackward); - virtual void SetExecutionStage(Workflow::ExecutionStage stage); - Workflow::ExecutionStage GetExecutionStage(); + virtual void SetExecutionStage(Workflow::ExecutionStage stage, bool); #ifndef AICLI_DISABLE_TEST_HOOKS // Enable tests to override behavior diff --git a/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h b/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h deleted file mode 100644 index 67e6987bca..0000000000 --- a/src/AppInstallerCLICore/Public/AppInstallerCLICoreExecute.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "ExecutionContext.h" -#include "Command.h" - -namespace AppInstaller::CLI -{ - int Execute(Execution::Context& context, std::unique_ptr& command); -} \ No newline at end of file diff --git a/src/AppInstallerCLITests/TestCommon.cpp b/src/AppInstallerCLITests/TestCommon.cpp index 04b032348a..f101d196aa 100644 --- a/src/AppInstallerCLITests/TestCommon.cpp +++ b/src/AppInstallerCLITests/TestCommon.cpp @@ -143,9 +143,8 @@ namespace TestCommon { } - void TestProgress::EndProgress(bool hideProgressWhenDone) + void TestProgress::EndProgress(bool) { - _Unreferenced_parameter_(hideProgressWhenDone); } bool TestProgress::IsCancelled() diff --git a/src/AppInstallerCLITests/TestCommon.h b/src/AppInstallerCLITests/TestCommon.h index 77852f38e0..0ef24f2ffa 100644 --- a/src/AppInstallerCLITests/TestCommon.h +++ b/src/AppInstallerCLITests/TestCommon.h @@ -96,7 +96,7 @@ namespace TestCommon void OnProgress(uint64_t current, uint64_t maximum, AppInstaller::ProgressType type) override; - void EndProgress(bool hideProgressWhenDone) override; + void EndProgress(bool) override; bool IsCancelled() override; CancelFunctionRemoval SetCancellationFunction(std::function&& f) override;