File tree Expand file tree Collapse file tree 5 files changed +53
-24
lines changed
Expand file tree Collapse file tree 5 files changed +53
-24
lines changed Original file line number Diff line number Diff line change @@ -69,31 +69,38 @@ WINRT_EXPORT namespace winrt
6969 check_bool (WINRT_IMPL_SetThreadToken (nullptr , get ()));
7070 }
7171
72- auto operator ()() const
73- {
74- struct guard
75- {
76- guard (access_token&& previous) noexcept : m_previous(std::move(previous))
77- {
78- }
79-
80- ~guard ()
81- {
82- m_previous.revert ();
83- }
84-
85- guard (guard const &)
86- {
87- // A Visual C++ compiler bug (550631) requires the copy constructor even though it is never called.
88- WINRT_ASSERT (false );
89- }
72+ auto operator ()() const ;
73+ };
74+ }
9075
91- private:
76+ WINRT_EXPORT namespace winrt
77+ {
78+ struct access_token_guard
79+ {
80+ access_token_guard (handle&& previous) noexcept : m_previous(std::move(previous))
81+ {
82+ }
9283
93- access_token const m_previous;
94- };
84+ ~access_token_guard ()
85+ {
86+ check_bool (WINRT_IMPL_SetThreadToken (nullptr , m_previous.get ()));
87+ }
9588
96- return guard (impersonate ());
89+ access_token_guard (access_token_guard const &)
90+ {
91+ // A Visual C++ compiler bug (550631) requires the copy constructor even though it is never called.
92+ WINRT_ASSERT (false );
9793 }
94+
95+ private:
96+ // Work around modules bug that claims access_token is undefined/incomplete here.
97+ handle m_previous;
9898 };
99+
100+ inline auto access_token::operator ()() const
101+ {
102+ auto previous = thread ();
103+ check_bool (WINRT_IMPL_SetThreadToken (nullptr , get ()));
104+ return access_token_guard (std::move (previous));
105+ }
99106}
Original file line number Diff line number Diff line change 1+ #ifndef WINRT_TEST_MODULES
12#include " pch.h"
3+ #endif
24#include " catch.hpp"
35
6+ #ifdef WINRT_TEST_MODULES
7+ #include < Windows.h>
8+ import std;
9+ import winrt;
10+ #endif
11+
412using namespace winrt ;
513using namespace Windows ::Foundation;
614
Original file line number Diff line number Diff line change 1+ #ifdef WINRT_TEST_MODULES
2+ #include < catch.hpp>
3+ #include < Windows.h>
4+ import std;
5+ import winrt;
6+ #else
17#include " pch.h"
28#include " winrt/Windows.System.h"
9+ #endif
310
411using namespace std ::literals;
512using namespace winrt ;
Original file line number Diff line number Diff line change 11// Intentionally not using pch...
22#include " catch.hpp"
33
4+ #ifdef WINRT_TEST_MODULES
5+ import winrt;
6+ #else
47// Only need winrt/base.h for coroutine thread pool support.
58#include " winrt/base.h"
9+ #endif
610
711using namespace winrt ;
812
Original file line number Diff line number Diff line change 9999 <ItemDefinitionGroup >
100100 <ClCompile >
101101 <AdditionalIncludeDirectories >$(OutputPath);..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories >
102- <PreprocessorDefinitions >NOMINMAX;WINRT_LEAN_AND_MEAN;WINRT_IMPORT_STD;%(PreprocessorDefinitions)</PreprocessorDefinitions >
102+ <PreprocessorDefinitions >NOMINMAX;WINRT_LEAN_AND_MEAN;WINRT_IMPORT_STD;WINRT_TEST_MODULES; %(PreprocessorDefinitions)</PreprocessorDefinitions >
103103 <PrecompiledHeader >NotUsing</PrecompiledHeader >
104104 <BuildStlModules >true</BuildStlModules >
105105 </ClCompile >
127127 </ItemDefinitionGroup >
128128 <ItemGroup >
129129 <ClCompile Include =" $(OutDir)winrt\winrt.ixx" />
130+ <ClCompile Include =" ..\old_tests\UnitTests\Security.cpp" />
131+ <ClCompile Include =" ..\test\await_adapter.cpp" />
132+ <ClCompile Include =" ..\test\coro_threadpool.cpp" />
130133 <ClCompile Include =" async.cpp" />
131134 <ClCompile Include =" interop.cpp" />
132135 <ClCompile Include =" main.cpp" />
133136 </ItemGroup >
134137 <Import Project =" $(VCTargetsPath)\Microsoft.Cpp.targets" />
135138 <ImportGroup Label =" ExtensionTargets" >
136139 </ImportGroup >
137- </Project >
140+ </Project >
You can’t perform that action at this time.
0 commit comments