From d662b5885a1158f0571c54839956546ba0c0fb19 Mon Sep 17 00:00:00 2001 From: Stefan Markovic Date: Fri, 11 Oct 2024 11:56:08 +0200 Subject: [PATCH] Cleanup --- .../Telemetry/ManagedTelemetry.csproj | 1 - src/gpo/assets/en-US/PowerToys.adml | 1 - src/modules/CropAndLock/CropAndLock/main.cpp | 12 ++++-------- src/modules/colorPicker/ColorPickerUI/App.xaml.cs | 13 ++++--------- .../ColorPickerUI/ColorEditorWindow.xaml.cs | 2 -- .../colorPicker/ColorPickerUI/MainWindow.xaml.cs | 2 -- .../PowerRenameUILib/PowerRenameXAML/App.xaml.cpp | 6 +++--- 7 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj b/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj index 6fed98f106..abedce4aa1 100644 --- a/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj +++ b/src/common/ManagedTelemetry/Telemetry/ManagedTelemetry.csproj @@ -13,7 +13,6 @@ - diff --git a/src/gpo/assets/en-US/PowerToys.adml b/src/gpo/assets/en-US/PowerToys.adml index a750cb19ba..7a8f037eee 100644 --- a/src/gpo/assets/en-US/PowerToys.adml +++ b/src/gpo/assets/en-US/PowerToys.adml @@ -265,7 +265,6 @@ If you don't configure this policy, the user takes control over the setting and Disable user defined IP Address mapping rules Predefined IP Address mapping rules Hide template filename extension - Advanced Paste: Allow using online AI models Allow sending diagnostic data diff --git a/src/modules/CropAndLock/CropAndLock/main.cpp b/src/modules/CropAndLock/CropAndLock/main.cpp index b07dbf3338..bcabc39098 100644 --- a/src/modules/CropAndLock/CropAndLock/main.cpp +++ b/src/modules/CropAndLock/CropAndLock/main.cpp @@ -17,7 +17,7 @@ #include -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") namespace winrt { @@ -114,8 +114,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I HANDLE m_exit_event_handle; std::thread m_event_triggers_thread; - std::function removeWindowCallback = [&](HWND windowHandle) - { + std::function removeWindowCallback = [&](HWND windowHandle) { if (!m_running) { // If we're not running, the reference to croppedWindows might no longer be valid and cause a crash at exit time, due to being called by destructors after wWinMain returns. @@ -129,8 +128,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I } }; - std::function ProcessCommand = [&](CropAndLockType mode) - { + std::function ProcessCommand = [&](CropAndLockType mode) { std::function windowCroppedCallback = [&, mode](HWND targetWindow, RECT cropRect) { auto targetInfo = util::WindowInfo(targetWindow); // TODO: Fix WindowInfo.h to not contain the null char at the end. @@ -160,7 +158,6 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I croppedWindow = std::make_shared(title, 800, 600); Logger::trace(L"Creating a thumbnail window"); Trace::CropAndLock::CreateThumbnailWindow(); - Trace::CropAndLock::ActivateThumbnail(); break; default: return; @@ -203,9 +200,8 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I } m_event_triggers_thread = std::thread([&]() { - MSG msg; - HANDLE event_handles[3] = {m_reparent_event_handle, m_thumbnail_event_handle, m_exit_event_handle}; + HANDLE event_handles[3] = { m_reparent_event_handle, m_thumbnail_event_handle, m_exit_event_handle }; while (m_running) { DWORD dwEvt = MsgWaitForMultipleObjects(3, event_handles, false, INFINITE, QS_ALLINPUT); diff --git a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs index 0873844166..bf1aa2751b 100644 --- a/src/modules/colorPicker/ColorPickerUI/App.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/App.xaml.cs @@ -19,13 +19,8 @@ namespace ColorPickerUI /// public partial class App : Application, IDisposable { -#pragma warning disable CA1051 // Do not declare visible instance fields -#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter -#pragma warning disable SA1401 // Accessible fields should begin with upper-case letter - public ETWTrace etwTrace = new ETWTrace(); -#pragma warning restore SA1401 // Accessible fields should begin with upper-case letter -#pragma warning restore SA1307 // Accessible fields should begin with upper-case letter -#pragma warning restore CA1051 // Do not declare visible instance fields + public ETWTrace EtwTrace { get; private set; } = new ETWTrace(); + private Mutex _instanceMutex; private static string[] _args; private int _powerToysRunnerPid; @@ -51,7 +46,7 @@ namespace ColorPickerUI Logger.LogError("CultureNotFoundException: " + ex.Message); } - etwTrace.Start(); + EtwTrace.Start(); NativeThreadCTS = new CancellationTokenSource(); ExitToken = NativeThreadCTS.Token; @@ -105,7 +100,7 @@ namespace ColorPickerUI if (disposing) { _instanceMutex?.Dispose(); - etwTrace?.Dispose(); + EtwTrace?.Dispose(); } disposedValue = true; diff --git a/src/modules/colorPicker/ColorPickerUI/ColorEditorWindow.xaml.cs b/src/modules/colorPicker/ColorPickerUI/ColorEditorWindow.xaml.cs index fc55e9b8a1..eb94d86d1e 100644 --- a/src/modules/colorPicker/ColorPickerUI/ColorEditorWindow.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/ColorEditorWindow.xaml.cs @@ -3,10 +3,8 @@ // See the LICENSE file in the project root for more information. using System; -using System.Windows; using ColorPicker.Helpers; -using ColorPickerUI; using Common.UI; using Wpf.Ui.Controls; diff --git a/src/modules/colorPicker/ColorPickerUI/MainWindow.xaml.cs b/src/modules/colorPicker/ColorPickerUI/MainWindow.xaml.cs index 6bc87b6947..ed9feae896 100644 --- a/src/modules/colorPicker/ColorPickerUI/MainWindow.xaml.cs +++ b/src/modules/colorPicker/ColorPickerUI/MainWindow.xaml.cs @@ -7,8 +7,6 @@ using System.Windows; using System.Windows.Interop; using ColorPicker.ViewModelContracts; -using ColorPickerUI; -using Microsoft.PowerToys.Telemetry; using Wpf.Ui.Controls; namespace ColorPicker diff --git a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/App.xaml.cpp b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/App.xaml.cpp index e4282b369c..71c510e357 100644 --- a/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/App.xaml.cpp +++ b/src/modules/powerrename/PowerRenameUILib/PowerRenameXAML/App.xaml.cpp @@ -22,7 +22,7 @@ using namespace PowerRenameUI::implementation; namespace fs = std::filesystem; -#define DEBUG_BENCHMARK_100K_ENTRIES +//#define DEBUG_BENCHMARK_100K_ENTRIES std::vector g_files; @@ -121,7 +121,7 @@ void App::OnLaunched(LaunchActivatedEventArgs const&) } #ifdef DEBUG_BENCHMARK_100K_ENTRIES - const std::wstring_view ROOT_PATH = L"C:\\PowerRenameBenchmark"; + const std::wstring_view ROOT_PATH = L"R:\\PowerRenameBenchmark"; std::wstring subdirectory_name = L"0"; std::error_code _; @@ -136,7 +136,7 @@ void App::OnLaunched(LaunchActivatedEventArgs const&) g_files.push_back(fs::path{ ROOT_PATH }); constexpr int pow2_threshold = 10; - constexpr int num_files = 10; + constexpr int num_files = 100'000; for (int i = 0; i < num_files; ++i) { fs::path file_path{ ROOT_PATH };