Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/spell-check/allow/code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,11 @@ pwa

AOT
Aot
cswinrt
ify
rsp
TFM
RTIID

# YML
onefuzz
Expand Down
2 changes: 1 addition & 1 deletion deps/spdlog
Submodule spdlog updated 176 files
94 changes: 0 additions & 94 deletions deps/spdlog-msvc-fix/include/spdlog-msvc-fix.h

This file was deleted.

3 changes: 1 addition & 2 deletions deps/spdlog.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)spdlog\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SPDLOG_WCHAR_TO_UTF8_SUPPORT;SPDLOG_COMPILED_LIB;SPDLOG_WCHAR_FILENAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>$(MSBuildThisFileDirectory)spdlog-msvc-fix\include\spdlog-msvc-fix.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<PreprocessorDefinitions>SPDLOG_WCHAR_TO_UTF8_SUPPORT;SPDLOG_COMPILED_LIB;SPDLOG_WCHAR_FILENAMES;FMT_UNICODE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
60 changes: 59 additions & 1 deletion src/Common.Dotnet.CsWinRT.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup>

<!--
Opt out of CsWinRT 2.2 IIDOptimizer. On .NET 10 / CsWinRT 2.2 the tool exits with code -1
after producing "0 IID calculations/fetches patched", which generates a noisy MSB3073
warning for every CsWinRT-consuming project. The IIDOptimizer is a runtime-perf optimization
that interns GUID lookups; disabling it just means a small first-call cost. This switch
causes Microsoft.Windows.CsWinRT.IIDOptimizer.targets to not be imported at all.
-->
<PropertyGroup>
<CsWinRTIIDOptimizerOptOut>true</CsWinRTIIDOptimizerOptOut>
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
</PropertyGroup>

<!-- Common from the debug / release items -->
<PropertyGroup>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -41,7 +52,54 @@
<!-- this may need to be removed on future CsWinRT upgrades-->
<Target Name="RemoveCsWinRTPackageAnalyzer" BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(Analyzer.NuGetPackageId) == 'Microsoft.Windows.CsWinRT'" />   
<Analyzer Remove="@(Analyzer)" Condition="%(Analyzer.NuGetPackageId) == 'Microsoft.Windows.CsWinRT'" />
</ItemGroup>
</Target>

<!--
Ensure any referenced C++/WinRT (.vcxproj) projects are fully built BEFORE the CsWinRT
source generator runs in this csproj. On a clean machine the SDK-style ProjectReference
graph does not guarantee that the producing vcxproj has emitted its .winmd before the
consuming C# Compile / source-generator stage starts in a parallel solution build,
which manifests as CS0246 on the projected namespace (e.g. 'PowerToys.Interop').
Forcing a serialized Build of the .vcxproj references here closes that race.

We hook BEFORE ResolveProjectReferences so the produced .winmd is visible to
CsWinRTRemoveWinMDReferences (which moves it into @(CsWinRTInputs)) and we also
delete a possibly stale cswinrt.rsp so CsWinRTGenerateProjection re-invokes
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
cswinrt.exe instead of incrementally skipping.
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
-->
<Target Name="EnsureNativeWinMDProjectionInputsBuilt"
BeforeTargets="ResolveProjectReferences;ResolveAssemblyReferences;CsWinRTPrepareProjection;CsWinRTGenerateProjection"
Condition="'@(ProjectReference)' != '' and '$(DesignTimeBuild)' != 'true' and '$(BuildingProject)' != 'false'">
<ItemGroup>
<_NativeWinMDProjectionRef Include="@(ProjectReference)" Condition="'%(Extension)' == '.vcxproj'" />
</ItemGroup>
<MSBuild Projects="@(_NativeWinMDProjectionRef)"
Properties="Configuration=$(Configuration);Platform=$(Platform)"
Targets="Build"
BuildInParallel="false"
Condition="'@(_NativeWinMDProjectionRef)' != ''" />
<!-- Force CsWinRTGenerateProjection to re-run so stale-rsp incremental skip cannot
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
leave us without generated .cs files when the .winmd has just been (re)produced. -->
<Delete Files="$(CsWinRTGeneratedFilesDir)cswinrt.rsp;$(CsWinRTGeneratedFilesDir)cswinrt_internal.rsp"
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Condition="'@(_NativeWinMDProjectionRef)' != '' and '$(CsWinRTGeneratedFilesDir)' != ''" />
<!-- Mark that we need to delete the rsp again once CsWinRTGeneratedFilesDir is fully resolved
(some projects set it to $(OutDir) which is not evaluated this early). -->
<PropertyGroup>
<_DeleteStaleCsWinRTRspPending>true</_DeleteStaleCsWinRTRspPending>
</PropertyGroup>
</Target>

<!--
Second pass: after CsWinRTPrepareProjection has resolved $(CsWinRTGeneratedFilesDir) to its
final value (which may depend on $(OutDir)), delete any stale cswinrt.rsp so the
CsWinRTGenerateProjection target's incremental-skip cannot leave us without generated .cs files.
-->
<Target Name="DeleteStaleCsWinRTRspAfterPrepare"
AfterTargets="CsWinRTPrepareProjection"
BeforeTargets="CsWinRTGenerateProjection"
Condition="'$(_DeleteStaleCsWinRTRspPending)' == 'true' and '$(CsWinRTGeneratedFilesDir)' != ''">
<Delete Files="$(CsWinRTGeneratedFilesDir)cswinrt.rsp;$(CsWinRTGeneratedFilesDir)cswinrt_internal.rsp" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<ClCompile>
<!-- We use MultiThreadedDebug, rather than MultiThreadedDebugDLL, to avoid DLL dependencies on VCRUNTIME140d.dll and MSVCP140d.dll. -->
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<!-- Link statically against the runtime and STL, but link dynamically against the CRT by ignoring the static CRT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ClCompile>
<AdditionalIncludeDirectories>..\;..\utils;..\Telemetry;..\..\;..\..\..\deps\;..\..\..\deps\spdlog\include;..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.260126.7\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp23</LanguageStandard>
<PreprocessorDefinitions>SPDLOG_WCHAR_TO_UTF8_SUPPORT;SPDLOG_HEADER_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SPDLOG_WCHAR_TO_UTF8_SUPPORT;SPDLOG_HEADER_ONLY;FMT_UNICODE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down
44 changes: 32 additions & 12 deletions src/common/logger/logger.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
#pragma once
#include <spdlog/spdlog.h>
#include <type_traits>
#include "logger_settings.h"

// fmt 9+ no longer auto-formats enums. Provide a generic formatter that
// converts any scoped or unscoped enum to its underlying integer type so
// existing Logger::xxx(L"... {} ...", someEnum) call sites keep working
// after the spdlog 1.17 / fmt 12 upgrade.
namespace fmt
{
template <typename E, typename Char>
struct formatter<E, Char, std::enable_if_t<std::is_enum_v<E>>>
: formatter<std::underlying_type_t<E>, Char>
{
template <typename FormatContext>
auto format(E value, FormatContext& ctx) const
{
return formatter<std::underlying_type_t<E>, Char>::format(
static_cast<std::underlying_type_t<E>>(value), ctx);
}
};
}

class Logger
{
private:
Expand All @@ -17,44 +37,44 @@ class Logger

// log message should not be localized
template<typename FormatString, typename... Args>
static void trace(const FormatString& fmt, const Args&... args)
static void trace(const FormatString& formatString, const Args&... args)
{
logger->trace(fmt, args...);
logger->trace(fmt::runtime(formatString), args...);
}

// log message should not be localized
template<typename FormatString, typename... Args>
static void debug(const FormatString& fmt, const Args&... args)
static void debug(const FormatString& formatString, const Args&... args)
{
logger->debug(fmt, args...);
logger->debug(fmt::runtime(formatString), args...);
}

// log message should not be localized
template<typename FormatString, typename... Args>
static void info(const FormatString& fmt, const Args&... args)
static void info(const FormatString& formatString, const Args&... args)
{
logger->info(fmt, args...);
logger->info(fmt::runtime(formatString), args...);
}

// log message should not be localized
template<typename FormatString, typename... Args>
static void warn(const FormatString& fmt, const Args&... args)
static void warn(const FormatString& formatString, const Args&... args)
{
logger->warn(fmt, args...);
logger->warn(fmt::runtime(formatString), args...);
}

// log message should not be localized
template<typename FormatString, typename... Args>
static void error(const FormatString& fmt, const Args&... args)
static void error(const FormatString& formatString, const Args&... args)
{
logger->error(fmt, args...);
logger->error(fmt::runtime(formatString), args...);
}

// log message should not be localized
template<typename FormatString, typename... Args>
static void critical(const FormatString& fmt, const Args&... args)
static void critical(const FormatString& formatString, const Args&... args)
{
logger->critical(fmt, args...);
logger->critical(fmt::runtime(formatString), args...);
}

static void flush()
Expand Down
4 changes: 2 additions & 2 deletions src/logging/logging.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;SPDLOG_COMPILED_LIB;SPDLOG_WCHAR_FILENAMES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;SPDLOG_COMPILED_LIB;SPDLOG_WCHAR_FILENAMES;SPDLOG_WCHAR_TO_UTF8_SUPPORT;FMT_UNICODE=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName>
<FunctionLevelLinking>true</FunctionLevelLinking>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
Expand All @@ -71,7 +71,7 @@
<ClCompile Include="$(RepoRoot)deps\spdlog\src\file_sinks.cpp" />
<ClCompile Include="$(RepoRoot)deps\spdlog\src\async.cpp" />
<ClCompile Include="$(RepoRoot)deps\spdlog\src\cfg.cpp" />
<ClCompile Include="$(RepoRoot)deps\spdlog\src\fmt.cpp" />
<ClCompile Include="$(RepoRoot)deps\spdlog\src\bundled_fmtlib_format.cpp" />
<ClInclude Include="$(RepoRoot)deps\spdlog\include\spdlog\async.h" />
<ClInclude Include="$(RepoRoot)deps\spdlog\include\spdlog\async_logger-inl.h" />
<ClInclude Include="$(RepoRoot)deps\spdlog\include\spdlog\async_logger.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ void LightSwitchInterface::init_settings()
}
catch (const winrt::hresult_error& e)
{
Logger::error(L"[Light Switch] init_settings: hresult_error 0x{:08X} - {}", e.code(), e.message().c_str());
Logger::error(L"[Light Switch] init_settings: hresult_error 0x{:08X} - {}", static_cast<int32_t>(e.code()), e.message().c_str());
}
catch (const std::exception& e)
{
Expand Down
12 changes: 6 additions & 6 deletions src/modules/Workspaces/WorkspacesLauncher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
switch (res.error())
{
case JsonUtils::WorkspacesFileError::FileReadingError:
formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_FILE_READING_ERROR), file);
formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_FILE_READING_ERROR)), file);
break;
case JsonUtils::WorkspacesFileError::IncorrectFileError:
formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR), file);
formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR)), file);
break;
}

Expand All @@ -137,10 +137,10 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
switch (res.error())
{
case JsonUtils::WorkspacesFileError::FileReadingError:
formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_FILE_READING_ERROR), file);
formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_FILE_READING_ERROR)), file);
break;
case JsonUtils::WorkspacesFileError::IncorrectFileError:
formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR), file);
formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_INCORRECT_FILE_ERROR)), file);
break;
}

Expand All @@ -151,7 +151,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
if (workspaces.empty())
{
Logger::warn("Workspaces file is empty");
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_EMPTY_FILE), file);
std::wstring formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_EMPTY_FILE)), file);
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_WORKSPACES).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
Expand All @@ -169,7 +169,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdline, int cm
if (projectToLaunch.id.empty())
{
Logger::critical(L"Workspace {} not found", cmdArgs.workspaceId);
std::wstring formattedMessage = fmt::format(GET_RESOURCE_STRING(IDS_PROJECT_NOT_FOUND), cmdArgs.workspaceId);
std::wstring formattedMessage = fmt::format(fmt::runtime(GET_RESOURCE_STRING(IDS_PROJECT_NOT_FOUND)), cmdArgs.workspaceId);
MessageBox(NULL, formattedMessage.c_str(), GET_RESOURCE_STRING(IDS_WORKSPACES).c_str(), MB_ICONERROR | MB_OK);
return 1;
}
Expand Down
4 changes: 3 additions & 1 deletion src/modules/cmdpal/CmdPalKeyboardService/KeyboardListener.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once
#pragma once

#include "KeyboardListener.g.h"
#include <windows.h>
#include <mutex>
#include <functional>
#include <spdlog/stopwatch.h>
#include <set>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#pragma once

#include "KeyboardListener.g.h"
#include <mutex>
#include <functional>
#include <spdlog/stopwatch.h>

namespace winrt::PowerToys::PowerAccentKeyboardService::implementation
Expand Down
Loading
Loading