Fix runner warnings (#8211)

This commit is contained in:
Mykhailo Pylyp
2020-11-30 16:16:49 +02:00
committed by GitHub
parent 7c9888300b
commit f0553c370a
17 changed files with 101 additions and 139 deletions

View File

@@ -294,7 +294,7 @@ namespace UnitTest_ColorPickerUI.Helpers
{
var color = Color.FromArgb(red, green, blue);
Exception exception = null;
Exception? exception = null;
try
{

View File

@@ -13,7 +13,7 @@
#include <lib/FancyZonesData.h>
#include <lib/FancyZonesWinHookEventIDs.h>
#include <lib/FancyZonesData.cpp>
#include <lib/FancyZonesLogger.h>
#include <common/logger/logger.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
@@ -75,7 +75,7 @@ public:
// Enable the powertoy
virtual void enable()
{
FancyZonesLogger::GetLogger()->info("FancyZones enabling");
Logger::info("FancyZones enabling");
if (!m_app)
{
@@ -133,7 +133,7 @@ public:
// Disable the powertoy
virtual void disable()
{
FancyZonesLogger::GetLogger()->info("FancyZones disabling");
Logger::info("FancyZones disabling");
Disable(true);
}
@@ -155,7 +155,9 @@ public:
{
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
app_key = NonLocalizable::FancyZonesStr;
FancyZonesLogger::Init(PTSettingsHelper::get_module_save_folder_location(app_key));
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
logFilePath.append(LogSettings::fancyZonesLogPath);
Logger::init(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
FancyZonesDataInstance().LoadFancyZonesData();
s_instance = this;

View File

@@ -102,7 +102,6 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="FancyZonesLogger.h" />
<ClInclude Include="FancyZones.h" />
<ClInclude Include="FancyZonesDataTypes.h" />
<ClInclude Include="FancyZonesWinHookEventIDs.h" />
@@ -128,7 +127,6 @@
<ItemGroup>
<ClCompile Include="FancyZones.cpp" />
<ClCompile Include="FancyZonesDataTypes.cpp" />
<ClCompile Include="FancyZonesLogger.cpp" />
<ClCompile Include="FancyZonesWinHookEventIDs.cpp" />
<ClCompile Include="FancyZonesData.cpp" />
<ClCompile Include="JsonHelpers.cpp" />

View File

@@ -1,24 +0,0 @@
#include "pch.h"
#include <common\settings_helpers.h>
#include <filesystem>
#include "FancyZonesLogger.h"
std::shared_ptr<Logger> FancyZonesLogger::logger;
void FancyZonesLogger::Init(std::wstring moduleSaveLocation)
{
std::filesystem::path logFilePath(moduleSaveLocation);
logFilePath.append(LogSettings::fancyZonesLogPath);
logger = std::make_shared<Logger>(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
logger->info("FancyZones logger initialized");
}
std::shared_ptr<Logger> FancyZonesLogger::GetLogger()
{
if (!logger)
{
throw "FancyZones logger is not initialized";
}
return logger;
}

View File

@@ -1,10 +0,0 @@
#pragma once
#include <common/logger/logger.h>
class FancyZonesLogger
{
static std::shared_ptr<Logger> logger;
public:
static void Init(std::wstring moduleSaveLocation);
static std::shared_ptr<Logger> GetLogger();
};

View File

@@ -78,8 +78,6 @@ private:
// Handle to event used to invoke the Runner
HANDLE m_hEvent;
std::shared_ptr<Logger> logger;
public:
// Constructor
Microsoft_Launcher()
@@ -88,8 +86,8 @@ public:
app_key = LauncherConstants::ModuleKey;
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(this->app_key));
logFilePath.append(LogSettings::launcherLogPath);
logger = std::make_shared<Logger>(LogSettings::launcherLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
logger->info("Launcher object is constructing");
Logger::init(LogSettings::launcherLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
Logger::info("Launcher object is constructing");
init_settings();
SECURITY_ATTRIBUTES sa;
@@ -101,8 +99,7 @@ public:
~Microsoft_Launcher()
{
logger->info("Launcher object is destroying");
logger.reset();
Logger::info("Launcher object is destroying");
if (m_enabled)
{
terminateProcess();
@@ -183,7 +180,7 @@ public:
// Enable the powertoy
virtual void enable()
{
this->logger->info("Launcher is enabling");
Logger::info("Launcher is enabling");
ResetEvent(m_hEvent);
// Start PowerLauncher.exe only if the OS is 19H1 or higher
if (UseNewSettings())
@@ -255,7 +252,7 @@ public:
// Disable the powertoy
virtual void disable()
{
this->logger->info("Launcher is disabling");
Logger::info("Launcher is disabling");
if (m_enabled)
{
ResetEvent(m_hEvent);
@@ -327,7 +324,7 @@ public:
if (TerminateProcess(m_hProcess, 1) == 0)
{
auto err = get_last_error_message(GetLastError());
this->logger->error(L"Launcher process was not terminated. {}", err.has_value() ? err.value() : L"");
Logger::error(L"Launcher process was not terminated. {}", err.has_value() ? err.value() : L"");
}
// Temporarily disable sending a message to close

View File

@@ -1,24 +0,0 @@
#include "pch.h"
#include "ShortcutGuideLogger.h"
#include <common\settings_helpers.h>
#include <filesystem>
std::shared_ptr<Logger> ShortcutGuideLogger::logger;
void ShortcutGuideLogger::Init(std::wstring moduleSaveLocation)
{
std::filesystem::path logFilePath(moduleSaveLocation);
logFilePath.append(LogSettings::shortcutGuideLogPath);
logger = std::make_shared<Logger>(LogSettings::shortcutGuideLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
logger->info("Shortcut Guide logger initialized");
}
std::shared_ptr<Logger> ShortcutGuideLogger::GetLogger()
{
if (!logger)
{
throw "Shortcut Guide logger is not initialized";
}
return logger;
}

View File

@@ -1,11 +0,0 @@
#pragma once
#include <common/logger/logger.h>
class ShortcutGuideLogger
{
static std::shared_ptr<Logger> logger;
public:
static void Init(std::wstring moduleSaveLocation);
static std::shared_ptr<Logger> GetLogger();
};

View File

@@ -7,9 +7,11 @@
#include <common/settings_objects.h>
#include <common/debug_control.h>
#include <sstream>
#include <modules\shortcut_guide\ShortcutGuideConstants.h>
#include <modules\shortcut_guide\ShortcutGuideLogger.h>
#include <common\settings_helpers.cpp>
#include <modules/shortcut_guide/ShortcutGuideConstants.h>
#include <common/settings_helpers.cpp>
#include <common/logger/logger.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
@@ -98,8 +100,10 @@ OverlayWindow::OverlayWindow()
{
app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE);
app_key = ShortcutGuideConstants::ModuleKey;
ShortcutGuideLogger::Init(PTSettingsHelper::get_module_save_folder_location(app_key));
ShortcutGuideLogger::GetLogger()->info("Overlay Window is creating");
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
logFilePath.append(LogSettings::shortcutGuideLogPath);
Logger::init(LogSettings::shortcutGuideLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
Logger::info("Overlay Window is creating");
init_settings();
}
@@ -200,7 +204,7 @@ constexpr UINT alternative_switch_vk_code = VK_OEM_2;
void OverlayWindow::enable()
{
ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is enabling");
Logger::info("Shortcut Guide is enabling");
auto switcher = [&](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
if (msg == WM_KEYDOWN && wparam == VK_ESCAPE && instance->target_state->active())
@@ -253,7 +257,7 @@ void OverlayWindow::enable()
void OverlayWindow::disable(bool trace_event)
{
ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is disabling");
Logger::info("Shortcut Guide is disabling");
if (_enabled)
{

View File

@@ -112,7 +112,6 @@
<ClInclude Include="Generated Files/resource.h" />
<None Include="resource.base.h" />
<ClInclude Include="ShortcutGuideConstants.h" />
<ClInclude Include="ShortcutGuideLogger.h" />
<ClInclude Include="shortcut_guide.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="target_state.h" />
@@ -125,7 +124,6 @@
<ClCompile Include="overlay_window.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="keyboard_state.cpp" />
<ClCompile Include="ShortcutGuideLogger.cpp" />
<ClCompile Include="shortcut_guide.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>