From 0ebeda554bdd6135dab8c33c4359077ed0e2a419 Mon Sep 17 00:00:00 2001 From: "Muyuan Li (from Dev Box)" Date: Tue, 5 Nov 2024 16:59:59 +0800 Subject: [PATCH] Update template to follow best practices in namespace use --- .../Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp | 12 +++++++----- .../CppWinRT/PackagedApp/BlankApp/MainWindow.cpp | 6 ++++-- .../CppWinRT/SingleProjectPackagedApp/App.cpp | 12 +++++++----- .../CppWinRT/SingleProjectPackagedApp/MainWindow.cpp | 6 ++++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp index 47f77e36cf..792849c154 100644 --- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp +++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp @@ -2,8 +2,10 @@ #include "App.xaml.h" #include "MainWindow.xaml.h" -using namespace winrt; -using namespace Microsoft::UI::Xaml; +namespace winrt +{ + using namespace Microsoft::UI::Xaml; +} // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -20,7 +22,7 @@ namespace winrt::$safeprojectname$::implementation // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION - UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e) + UnhandledException([](winrt::IInspectable const&, winrt::UnhandledExceptionEventArgs const& e) { if (IsDebuggerPresent()) { @@ -35,9 +37,9 @@ namespace winrt::$safeprojectname$::implementation /// Invoked when the application is launched. /// /// Details about the launch request and process. - void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e) + void App::OnLaunched([[maybe_unused]] winrt::LaunchActivatedEventArgs const& e) { - window = make(); + window = winrt::make(); window.Activate(); } } diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp index d6d47e7619..6aa751203c 100644 --- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp +++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp @@ -4,8 +4,10 @@ #include "MainWindow.g.cpp" #endif -using namespace winrt; -using namespace Microsoft::UI::Xaml; +namespace winrt +{ + using namespace Microsoft::UI::Xaml; +} // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp index 47f77e36cf..792849c154 100644 --- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp +++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp @@ -2,8 +2,10 @@ #include "App.xaml.h" #include "MainWindow.xaml.h" -using namespace winrt; -using namespace Microsoft::UI::Xaml; +namespace winrt +{ + using namespace Microsoft::UI::Xaml; +} // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -20,7 +22,7 @@ namespace winrt::$safeprojectname$::implementation // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent #if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION - UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e) + UnhandledException([](winrt::IInspectable const&, winrt::UnhandledExceptionEventArgs const& e) { if (IsDebuggerPresent()) { @@ -35,9 +37,9 @@ namespace winrt::$safeprojectname$::implementation /// Invoked when the application is launched. /// /// Details about the launch request and process. - void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e) + void App::OnLaunched([[maybe_unused]] winrt::LaunchActivatedEventArgs const& e) { - window = make(); + window = winrt::make(); window.Activate(); } } diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp index d6d47e7619..6aa751203c 100644 --- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp +++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp @@ -4,8 +4,10 @@ #include "MainWindow.g.cpp" #endif -using namespace winrt; -using namespace Microsoft::UI::Xaml; +namespace winrt +{ + using namespace Microsoft::UI::Xaml; +} // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info.