From 23a365302c5d64c1a275ca2dc52dde717cdbb5ed Mon Sep 17 00:00:00 2001
From: Evelyn Wu <50890554+evelynwu-msft@users.noreply.github.com>
Date: Thu, 20 Jul 2023 13:38:03 -0700
Subject: [PATCH] Various fixes for C++ project and item templates (#3745)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is a partial adoption of #3619 by @JaiganeshKumaran in order to expedite the merging of the changes from that PR which do not need additional time for discussion. The individual changes that were extracted from the aforementioned PR are as follows:
- Removed usage of InitializeComponent as it's no longer recommended by C++/WinRT (see https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent for more details).
- Removed Microsoft copyright notice.
- Removed #include XAML headers in a template control header. This was in the C++/WinRT templates because a runtime component will not include XAML headers in pch.h, which is no longer the case with a WinUI 3 runtime component.
- Made the WinUI 3 runtime component "desktop-only" as WinUI 3 cannot be used by UWP apps. This is a fix for #1780. (Note that unlike the original PR the source directory structure is not being changed in order to minimize potential merge conflicts.)
- Removed App.idl because it's empty and not needed.
- Indented App.xaml.cpp's content inside the implementation namespace, rather than `using namespace` for consistency with the rest of the code. Also removed `using namespace` for namespaces that aren't actually used (Controls and Navigation namespaces were needed for Frame navigation, which isn't performed in the WinUI 3 template. IInspectable is available as an alias in every WinRT implementation type, thus doesn't require prefixing it with Windows::Foundation).
Additionally, this PR replaces `uwp` with `WinUI` (or just adds the latter if the former was not present at all) in the item templates. I don't believe this tag is surfaced anywhere in the Visual Studio UI but the consistency makes me happier.
---------
Co-authored-by: Jaiganésh Kumaran
(cherry picked from commit 18ada2ffa013e488916125ca96a7007259250e05)
---
.../WinUI.Desktop.Cs.BlankWindow.vstemplate | 1 +
.../CppWinRT/BlankWindow/BlankWindow.cpp | 8 ---
.../CppWinRT/BlankWindow/BlankWindow.h | 11 ++--
.../CppWinRT/BlankWindow/BlankWindow.idl | 3 -
...UI.Desktop.CppWinRT.BlankWindow.vstemplate | 1 +
.../WinUI.Neutral.Cs.BlankPage.vstemplate | 2 +-
...I.Neutral.Cs.ResourceDictionary.vstemplate | 2 +-
.../Resw/WinUI.Neutral.Cs.Resw.vstemplate | 2 +-
...nUI.Neutral.Cs.TemplatedControl.vstemplate | 2 +-
.../WinUI.Neutral.Cs.UserControl.vstemplate | 2 +-
.../Neutral/CppWinRT/BlankPage/BlankPage.cpp | 8 ---
.../Neutral/CppWinRT/BlankPage/BlankPage.h | 11 ++--
.../Neutral/CppWinRT/BlankPage/BlankPage.idl | 3 -
...inUI.Neutral.CppWinRT.BlankPage.vstemplate | 2 +-
...ral.CppWinRT.ResourceDictionary.vstemplate | 2 +-
.../WinUI.Neutral.CppWinRT.Resw.vstemplate | 2 +-
.../TemplatedControl/TemplatedControl.cpp | 3 -
.../TemplatedControl/TemplatedControl.h | 6 --
.../TemplatedControl/TemplatedControl.idl | 3 -
...utral.CppWinRT.TemplatedControl.vstemplate | 2 +-
.../CppWinRT/UserControl/UserControl.cpp | 8 ---
.../CppWinRT/UserControl/UserControl.h | 14 ++---
.../CppWinRT/UserControl/UserControl.idl | 3 -
...UI.Neutral.CppWinRT.UserControl.vstemplate | 2 +-
.../WinUI.Desktop.Cs.ClassLibrary.vstemplate | 2 +-
.../WinUI.Desktop.Cs.BlankApp.vstemplate | 2 +-
.../WinUI.Desktop.Cs.WapProj.vstemplate | 2 +-
.../WinUI.Desktop.Cs.PackagedApp.vstemplate | 2 +-
...top.Cs.SingleProjectPackagedApp.vstemplate | 2 +-
.../CppWinRT/PackagedApp/BlankApp/App.cpp | 57 +++++++++----------
.../CppWinRT/PackagedApp/BlankApp/App.h | 3 -
.../CppWinRT/PackagedApp/BlankApp/App.idl | 6 --
.../PackagedApp/BlankApp/MainWindow.cpp | 8 ---
.../PackagedApp/BlankApp/MainWindow.h | 12 ++--
.../PackagedApp/BlankApp/MainWindow.idl | 3 -
.../BlankApp/ProjectTemplate.vcxproj | 4 --
.../BlankApp/ProjectTemplate.vcxproj.filters | 1 -
...WinUI.Desktop.CppWinRT.BlankApp.vstemplate | 3 +-
.../CppWinRT/PackagedApp/BlankApp/pch.cpp | 3 -
.../CppWinRT/PackagedApp/BlankApp/pch.h | 3 -
.../WinUI.Desktop.CppWinRT.WapProj.vstemplate | 2 +-
...UI.Desktop.CppWinRT.PackagedApp.vstemplate | 2 +-
.../CppWinRT/SingleProjectPackagedApp/App.cpp | 57 +++++++++----------
.../CppWinRT/SingleProjectPackagedApp/App.h | 3 -
.../CppWinRT/SingleProjectPackagedApp/App.idl | 6 --
.../SingleProjectPackagedApp/MainWindow.cpp | 8 ---
.../SingleProjectPackagedApp/MainWindow.h | 11 ++--
.../SingleProjectPackagedApp/MainWindow.idl | 3 -
.../ProjectTemplate.vcxproj | 4 --
.../ProjectTemplate.vcxproj.filters | 1 -
...p.CppWinRT.SingleProjectPackagedApp.csproj | 1 -
...pWinRT.SingleProjectPackagedApp.vstemplate | 3 +-
.../CppWinRT/SingleProjectPackagedApp/pch.cpp | 3 -
.../CppWinRT/SingleProjectPackagedApp/pch.h | 3 -
.../CppWinRT/RuntimeComponent/Class.cpp | 3 -
.../Neutral/CppWinRT/RuntimeComponent/Class.h | 3 -
.../CppWinRT/RuntimeComponent/Class.idl | 3 -
.../RuntimeComponent/ProjectTemplate.vcxproj | 2 +-
...utral.CppWinRT.RuntimeComponent.vstemplate | 3 +-
.../Neutral/CppWinRT/RuntimeComponent/pch.cpp | 3 -
.../Neutral/CppWinRT/RuntimeComponent/pch.h | 16 +++++-
61 files changed, 119 insertions(+), 237 deletions(-)
delete mode 100644 dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.idl
delete mode 100644 dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.idl
diff --git a/dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/WinUI.Desktop.Cs.BlankWindow.vstemplate b/dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/WinUI.Desktop.Cs.BlankWindow.vstemplate
index 2ec9e75a60..d3c02065d9 100644
--- a/dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/WinUI.Desktop.Cs.BlankWindow.vstemplate
+++ b/dev/VSIX/ItemTemplates/Desktop/CSharp/BlankWindow/WinUI.Desktop.Cs.BlankWindow.vstemplate
@@ -15,6 +15,7 @@
csharp
windows
desktop
+ winui
BlankWindow.xaml
diff --git a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.cpp b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.cpp
index b9465ed819..71f96dbd85 100644
--- a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.cpp
+++ b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "$safeitemname$.xaml.h"
#if __has_include("$safeitemname$.g.cpp")
@@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;
namespace winrt::$rootnamespace$::implementation
{
- $safeitemname$::$safeitemname$()
- {
- InitializeComponent();
- }
-
int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
diff --git a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.h b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.h
index 298749282d..8eff169b57 100644
--- a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.h
+++ b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "$safeitemname$.g.h"
@@ -9,12 +6,16 @@ namespace winrt::$rootnamespace$::implementation
{
struct $safeitemname$ : $safeitemname$T<$safeitemname$>
{
- $safeitemname$();
+ $safeitemname$()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+ }
int32_t MyProperty();
void MyProperty(int32_t value);
- void myButton_Click(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
};
}
diff --git a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.idl b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.idl
index f830b44f06..948adbe989 100644
--- a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.idl
+++ b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/BlankWindow.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $rootnamespace$
{
[default_interface]
diff --git a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/WinUI.Desktop.CppWinRT.BlankWindow.vstemplate b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/WinUI.Desktop.CppWinRT.BlankWindow.vstemplate
index c37a5908ad..62d2ec489e 100644
--- a/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/WinUI.Desktop.CppWinRT.BlankWindow.vstemplate
+++ b/dev/VSIX/ItemTemplates/Desktop/CppWinRT/BlankWindow/WinUI.Desktop.CppWinRT.BlankWindow.vstemplate
@@ -15,6 +15,7 @@
cpp
windows
desktop
+ winui
BlankWindow.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/WinUI.Neutral.Cs.BlankPage.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/WinUI.Neutral.Cs.BlankPage.vstemplate
index ef1cde9152..b96bbce5ab 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/WinUI.Neutral.Cs.BlankPage.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CSharp/BlankPage/WinUI.Neutral.Cs.BlankPage.vstemplate
@@ -14,8 +14,8 @@
Windows
csharp
windows
- uwp
desktop
+ winui
BlankPage.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CSharp/ResourceDictionary/WinUI.Neutral.Cs.ResourceDictionary.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CSharp/ResourceDictionary/WinUI.Neutral.Cs.ResourceDictionary.vstemplate
index 7d1aa930c1..47352957f9 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CSharp/ResourceDictionary/WinUI.Neutral.Cs.ResourceDictionary.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CSharp/ResourceDictionary/WinUI.Neutral.Cs.ResourceDictionary.vstemplate
@@ -14,8 +14,8 @@
Windows
csharp
windows
- uwp
desktop
+ winui
ResourceDictionary.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CSharp/Resw/WinUI.Neutral.Cs.Resw.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CSharp/Resw/WinUI.Neutral.Cs.Resw.vstemplate
index d4f1586de1..8d82892557 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CSharp/Resw/WinUI.Neutral.Cs.Resw.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CSharp/Resw/WinUI.Neutral.Cs.Resw.vstemplate
@@ -14,8 +14,8 @@
Windows
csharp
windows
- uwp
desktop
+ winui
Resources.resw
diff --git a/dev/VSIX/ItemTemplates/Neutral/CSharp/TemplatedControl/WinUI.Neutral.Cs.TemplatedControl.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CSharp/TemplatedControl/WinUI.Neutral.Cs.TemplatedControl.vstemplate
index 434911da49..cec6d71915 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CSharp/TemplatedControl/WinUI.Neutral.Cs.TemplatedControl.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CSharp/TemplatedControl/WinUI.Neutral.Cs.TemplatedControl.vstemplate
@@ -14,8 +14,8 @@
Windows
csharp
windows
- uwp
desktop
+ winui
CustomControl.cs
diff --git a/dev/VSIX/ItemTemplates/Neutral/CSharp/UserControl/WinUI.Neutral.Cs.UserControl.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CSharp/UserControl/WinUI.Neutral.Cs.UserControl.vstemplate
index 3232e88cae..9b399e6767 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CSharp/UserControl/WinUI.Neutral.Cs.UserControl.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CSharp/UserControl/WinUI.Neutral.Cs.UserControl.vstemplate
@@ -14,8 +14,8 @@
Windows
csharp
windows
- uwp
desktop
+ winui
UserControl.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.cpp b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.cpp
index b9465ed819..71f96dbd85 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.cpp
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "$safeitemname$.xaml.h"
#if __has_include("$safeitemname$.g.cpp")
@@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;
namespace winrt::$rootnamespace$::implementation
{
- $safeitemname$::$safeitemname$()
- {
- InitializeComponent();
- }
-
int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.h b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.h
index 298749282d..8eff169b57 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.h
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "$safeitemname$.g.h"
@@ -9,12 +6,16 @@ namespace winrt::$rootnamespace$::implementation
{
struct $safeitemname$ : $safeitemname$T<$safeitemname$>
{
- $safeitemname$();
+ $safeitemname$()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+ }
int32_t MyProperty();
void MyProperty(int32_t value);
- void myButton_Click(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
};
}
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.idl b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.idl
index ee72b5f377..c91ead7c5e 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.idl
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $rootnamespace$
{
[default_interface]
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/WinUI.Neutral.CppWinRT.BlankPage.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/WinUI.Neutral.CppWinRT.BlankPage.vstemplate
index d443e8b102..df9b8bfcef 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/WinUI.Neutral.CppWinRT.BlankPage.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/WinUI.Neutral.CppWinRT.BlankPage.vstemplate
@@ -14,8 +14,8 @@
Windows
cpp
windows
- uwp
desktop
+ winui
BlankPage.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/ResourceDictionary/WinUI.Neutral.CppWinRT.ResourceDictionary.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/ResourceDictionary/WinUI.Neutral.CppWinRT.ResourceDictionary.vstemplate
index ae167991ff..bbb7046144 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/ResourceDictionary/WinUI.Neutral.CppWinRT.ResourceDictionary.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/ResourceDictionary/WinUI.Neutral.CppWinRT.ResourceDictionary.vstemplate
@@ -14,8 +14,8 @@
Windows
cpp
windows
- uwp
desktop
+ winui
ResourceDictionary.xaml
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/Resw/WinUI.Neutral.CppWinRT.Resw.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/Resw/WinUI.Neutral.CppWinRT.Resw.vstemplate
index 1c1a590512..3512528fdc 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/Resw/WinUI.Neutral.CppWinRT.Resw.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/Resw/WinUI.Neutral.CppWinRT.Resw.vstemplate
@@ -14,8 +14,8 @@
Windows
cpp
windows
- uwp
desktop
+ winui
Resources.resw
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.cpp b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.cpp
index f885007964..d890d87161 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.cpp
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "$safeitemname$.h"
#if __has_include("$safeitemname$.g.cpp")
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.h b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.h
index 5b2c7438a5..d7d67cec10 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.h
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.h
@@ -1,11 +1,5 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
-#include "winrt/Microsoft.UI.Xaml.h"
-#include "winrt/Microsoft.UI.Xaml.Markup.h"
-#include "winrt/Microsoft.UI.Xaml.Controls.Primitives.h"
#include "$safeitemname$.g.h"
namespace winrt::$rootnamespace$::implementation
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.idl b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.idl
index 32b2c2cc02..3733d0c2b5 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.idl
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/TemplatedControl.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $rootnamespace$
{
[default_interface]
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/WinUI.Neutral.CppWinRT.TemplatedControl.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/WinUI.Neutral.CppWinRT.TemplatedControl.vstemplate
index 73e42d8f90..46b8048bf0 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/WinUI.Neutral.CppWinRT.TemplatedControl.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/TemplatedControl/WinUI.Neutral.CppWinRT.TemplatedControl.vstemplate
@@ -14,8 +14,8 @@
Windows
cpp
windows
- uwp
desktop
+ winui
TemplatedControl.cpp
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.cpp b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.cpp
index b9465ed819..71f96dbd85 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.cpp
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "$safeitemname$.xaml.h"
#if __has_include("$safeitemname$.g.cpp")
@@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;
namespace winrt::$rootnamespace$::implementation
{
- $safeitemname$::$safeitemname$()
- {
- InitializeComponent();
- }
-
int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.h b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.h
index 3ce4f4a724..8eff169b57 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.h
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.h
@@ -1,23 +1,21 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
-#include "winrt/Microsoft.UI.Xaml.h"
-#include "winrt/Microsoft.UI.Xaml.Markup.h"
-#include "winrt/Microsoft.UI.Xaml.Controls.Primitives.h"
#include "$safeitemname$.g.h"
namespace winrt::$rootnamespace$::implementation
{
struct $safeitemname$ : $safeitemname$T<$safeitemname$>
{
- $safeitemname$();
+ $safeitemname$()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+ }
int32_t MyProperty();
void MyProperty(int32_t value);
- void myButton_Click(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
};
}
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.idl b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.idl
index 1ce0f37546..e612c3ca7c 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.idl
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/UserControl.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $rootnamespace$
{
[default_interface]
diff --git a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/WinUI.Neutral.CppWinRT.UserControl.vstemplate b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/WinUI.Neutral.CppWinRT.UserControl.vstemplate
index 4ad7a45b4a..6d1efeac1e 100644
--- a/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/WinUI.Neutral.CppWinRT.UserControl.vstemplate
+++ b/dev/VSIX/ItemTemplates/Neutral/CppWinRT/UserControl/WinUI.Neutral.CppWinRT.UserControl.vstemplate
@@ -14,8 +14,8 @@
Windows
cpp
windows
- uwp
desktop
+ winui
UserControl.xaml
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CSharp/ClassLibrary/WinUI.Desktop.Cs.ClassLibrary.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CSharp/ClassLibrary/WinUI.Desktop.Cs.ClassLibrary.vstemplate
index 738db1ea85..c549f3a530 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CSharp/ClassLibrary/WinUI.Desktop.Cs.ClassLibrary.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CSharp/ClassLibrary/WinUI.Desktop.Cs.ClassLibrary.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/BlankApp/WinUI.Desktop.Cs.BlankApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/BlankApp/WinUI.Desktop.Cs.BlankApp.vstemplate
index b2eeb3afc8..f643e9c321 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/BlankApp/WinUI.Desktop.Cs.BlankApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/BlankApp/WinUI.Desktop.Cs.BlankApp.vstemplate
@@ -22,7 +22,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WapProj/WinUI.Desktop.Cs.WapProj.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WapProj/WinUI.Desktop.Cs.WapProj.vstemplate
index 1f6e396a27..6e61c517f6 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WapProj/WinUI.Desktop.Cs.WapProj.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WapProj/WinUI.Desktop.Cs.WapProj.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WinUI.Desktop.Cs.PackagedApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WinUI.Desktop.Cs.PackagedApp.vstemplate
index 2e4e91fdba..1365432762 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WinUI.Desktop.Cs.PackagedApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CSharp/PackagedApp/WinUI.Desktop.Cs.PackagedApp.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CSharp/SingleProjectPackagedApp/WinUI.Desktop.Cs.SingleProjectPackagedApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CSharp/SingleProjectPackagedApp/WinUI.Desktop.Cs.SingleProjectPackagedApp.vstemplate
index fb34eff491..9675c5b3e7 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CSharp/SingleProjectPackagedApp/WinUI.Desktop.Cs.SingleProjectPackagedApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CSharp/SingleProjectPackagedApp/WinUI.Desktop.Cs.SingleProjectPackagedApp.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp
index cd08294f06..47f77e36cf 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.cpp
@@ -1,48 +1,43 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
-
#include "App.xaml.h"
#include "MainWindow.xaml.h"
using namespace winrt;
-using namespace Windows::Foundation;
using namespace Microsoft::UI::Xaml;
-using namespace Microsoft::UI::Xaml::Controls;
-using namespace Microsoft::UI::Xaml::Navigation;
-using namespace $safeprojectname$;
-using namespace $safeprojectname$::implementation;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
-///
-/// Initializes the singleton application object. This is the first line of authored code
-/// executed, and as such is the logical equivalent of main() or WinMain().
-///
-App::App()
+namespace winrt::$safeprojectname$::implementation
{
- InitializeComponent();
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ App::App()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
- UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e)
- {
- if (IsDebuggerPresent())
+ UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e)
{
- auto errorMessage = e.Message();
- __debugbreak();
- }
- });
+ if (IsDebuggerPresent())
+ {
+ auto errorMessage = e.Message();
+ __debugbreak();
+ }
+ });
#endif
-}
+ }
-///
-/// Invoked when the application is launched.
-///
-/// Details about the launch request and process.
-void App::OnLaunched(LaunchActivatedEventArgs const&)
-{
- window = make();
- window.Activate();
+ ///
+ /// Invoked when the application is launched.
+ ///
+ /// Details about the launch request and process.
+ void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e)
+ {
+ window = make();
+ window.Activate();
+ }
}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.h
index 5b835dda35..20431336d7 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "App.xaml.g.h"
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.idl b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.idl
deleted file mode 100644
index 55ac0e3690..0000000000
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/App.idl
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
-namespace $safeprojectname$
-{
-}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp
index 746fe412aa..d6d47e7619 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "MainWindow.xaml.h"
#if __has_include("MainWindow.g.cpp")
@@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;
namespace winrt::$safeprojectname$::implementation
{
- MainWindow::MainWindow()
- {
- InitializeComponent();
- }
-
int32_t MainWindow::MyProperty()
{
throw hresult_not_implemented();
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.h
index f814ca11e7..1077d33b4f 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.h
@@ -1,19 +1,21 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
+
#include "MainWindow.g.h"
namespace winrt::$safeprojectname$::implementation
{
struct MainWindow : MainWindowT
{
- MainWindow();
+ MainWindow()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+ }
int32_t MyProperty();
void MyProperty(int32_t value);
- void myButton_Click(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
};
}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.idl b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.idl
index 5d81f19d36..0e0ce71ae6 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.idl
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/MainWindow.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $safeprojectname$
{
[default_interface]
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj
index 125764fe81..e73a840592 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj
@@ -123,10 +123,6 @@
-
- Code
- App.xaml
-
Code
MainWindow.xaml
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj.filters b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj.filters
index b34b6d068d..95cd21e016 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj.filters
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/ProjectTemplate.vcxproj.filters
@@ -7,7 +7,6 @@
-
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/WinUI.Desktop.CppWinRT.BlankApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/WinUI.Desktop.CppWinRT.BlankApp.vstemplate
index a73f9039b9..a2ffc45741 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/WinUI.Desktop.CppWinRT.BlankApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/WinUI.Desktop.CppWinRT.BlankApp.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
@@ -30,7 +30,6 @@
pch.h
app.manifest
App.xaml
- App.idl
App.cpp
App.h
MainWindow.xaml
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.cpp
index 0850baca11..1d9f38c57d 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.cpp
@@ -1,4 +1 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.h
index 170dd76c69..6d06556701 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/BlankApp/pch.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include
#include
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WapProj/WinUI.Desktop.CppWinRT.WapProj.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WapProj/WinUI.Desktop.CppWinRT.WapProj.vstemplate
index 442142facb..2810c38a1e 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WapProj/WinUI.Desktop.CppWinRT.WapProj.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WapProj/WinUI.Desktop.CppWinRT.WapProj.vstemplate
@@ -21,7 +21,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WinUI.Desktop.CppWinRT.PackagedApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WinUI.Desktop.CppWinRT.PackagedApp.vstemplate
index 36183ad922..e2a5c97540 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WinUI.Desktop.CppWinRT.PackagedApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/PackagedApp/WinUI.Desktop.CppWinRT.PackagedApp.vstemplate
@@ -20,7 +20,7 @@
XAML
windows
desktop
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp
index cd08294f06..47f77e36cf 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.cpp
@@ -1,48 +1,43 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
-
#include "App.xaml.h"
#include "MainWindow.xaml.h"
using namespace winrt;
-using namespace Windows::Foundation;
using namespace Microsoft::UI::Xaml;
-using namespace Microsoft::UI::Xaml::Controls;
-using namespace Microsoft::UI::Xaml::Navigation;
-using namespace $safeprojectname$;
-using namespace $safeprojectname$::implementation;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
-///
-/// Initializes the singleton application object. This is the first line of authored code
-/// executed, and as such is the logical equivalent of main() or WinMain().
-///
-App::App()
+namespace winrt::$safeprojectname$::implementation
{
- InitializeComponent();
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ App::App()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
- UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e)
- {
- if (IsDebuggerPresent())
+ UnhandledException([](IInspectable const&, UnhandledExceptionEventArgs const& e)
{
- auto errorMessage = e.Message();
- __debugbreak();
- }
- });
+ if (IsDebuggerPresent())
+ {
+ auto errorMessage = e.Message();
+ __debugbreak();
+ }
+ });
#endif
-}
+ }
-///
-/// Invoked when the application is launched.
-///
-/// Details about the launch request and process.
-void App::OnLaunched(LaunchActivatedEventArgs const&)
-{
- window = make();
- window.Activate();
+ ///
+ /// Invoked when the application is launched.
+ ///
+ /// Details about the launch request and process.
+ void App::OnLaunched([[maybe_unused]] LaunchActivatedEventArgs const& e)
+ {
+ window = make();
+ window.Activate();
+ }
}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.h
index 5b835dda35..20431336d7 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "App.xaml.g.h"
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.idl b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.idl
deleted file mode 100644
index 55ac0e3690..0000000000
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/App.idl
+++ /dev/null
@@ -1,6 +0,0 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
-namespace $safeprojectname$
-{
-}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp
index 746fe412aa..d6d47e7619 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "MainWindow.xaml.h"
#if __has_include("MainWindow.g.cpp")
@@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;
namespace winrt::$safeprojectname$::implementation
{
- MainWindow::MainWindow()
- {
- InitializeComponent();
- }
-
int32_t MainWindow::MyProperty()
{
throw hresult_not_implemented();
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.h
index 6bc83fa80a..1077d33b4f 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "MainWindow.g.h"
@@ -9,12 +6,16 @@ namespace winrt::$safeprojectname$::implementation
{
struct MainWindow : MainWindowT
{
- MainWindow();
+ MainWindow()
+ {
+ // Xaml objects should not call InitializeComponent during construction.
+ // See https://github.com/microsoft/cppwinrt/tree/master/nuget#initializecomponent
+ }
int32_t MyProperty();
void MyProperty(int32_t value);
- void myButton_Click(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
+ void myButton_Click(IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& args);
};
}
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.idl b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.idl
index 5d81f19d36..0e0ce71ae6 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.idl
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/MainWindow.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $safeprojectname$
{
[default_interface]
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj
index 8186b4bd45..18f24fc411 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj
@@ -129,10 +129,6 @@
-
- Code
- App.xaml
-
Code
MainWindow.xaml
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj.filters b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj.filters
index 1af01fbcb6..474783025b 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj.filters
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/ProjectTemplate.vcxproj.filters
@@ -7,7 +7,6 @@
-
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.csproj b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.csproj
index 9166a5b2f3..f591427e4d 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.csproj
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.csproj
@@ -56,7 +56,6 @@
-
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.vstemplate b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.vstemplate
index b60e3cf737..530b82923f 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/WinUI.Desktop.CppWinRT.SingleProjectPackagedApp.vstemplate
@@ -20,7 +20,7 @@
XAML
windows
desktop
- WinUI
+ winui
@@ -29,7 +29,6 @@
pch.h
app.manifest
App.xaml
- App.idl
App.cpp
App.h
MainWindow.xaml
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.cpp b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.cpp
index 0850baca11..1d9f38c57d 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.cpp
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.cpp
@@ -1,4 +1 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
diff --git a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.h b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.h
index 170dd76c69..6d06556701 100644
--- a/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.h
+++ b/dev/VSIX/ProjectTemplates/Desktop/CppWinRT/SingleProjectPackagedApp/pch.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include
#include
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.cpp b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.cpp
index 8b0049de60..a24a855b28 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.cpp
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.cpp
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
#include "Class.h"
#if __has_include("Class.g.cpp")
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.h b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.h
index b74291f717..67afcddeaf 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.h
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.h
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
#include "Class.g.h"
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.idl b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.idl
index 2d4c82c3a8..86166e9780 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.idl
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/Class.idl
@@ -1,6 +1,3 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
namespace $safeprojectname$
{
[default_interface]
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/ProjectTemplate.vcxproj b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/ProjectTemplate.vcxproj
index df8226c1fe..1c5ae504ca 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/ProjectTemplate.vcxproj
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/ProjectTemplate.vcxproj
@@ -9,7 +9,7 @@
$safeprojectname$
$currentuiculturename$
16.0
- true
+ false
Windows Store
10.0
$targetplatformversion$
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/WinUI.Neutral.CppWinRT.RuntimeComponent.vstemplate b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/WinUI.Neutral.CppWinRT.RuntimeComponent.vstemplate
index ce21009daa..99f5d734a2 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/WinUI.Neutral.CppWinRT.RuntimeComponent.vstemplate
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/WinUI.Neutral.CppWinRT.RuntimeComponent.vstemplate
@@ -20,8 +20,7 @@
XAML
windows
desktop
- uwp
- WinUI
+ winui
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.cpp b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.cpp
index 0850baca11..1d9f38c57d 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.cpp
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.cpp
@@ -1,4 +1 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#include "pch.h"
diff --git a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.h b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.h
index 510ce87ab0..1533d96bb2 100644
--- a/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.h
+++ b/dev/VSIX/ProjectTemplates/Neutral/CppWinRT/RuntimeComponent/pch.h
@@ -1,16 +1,26 @@
-// Copyright (c) Microsoft Corporation and Contributors.
-// Licensed under the MIT License.
-
#pragma once
+#include
#include
+#include
+#include
+
+// Undefine GetCurrentTime macro to prevent
+// conflict with Storyboard::GetCurrentTime
+#undef GetCurrentTime
+
#include
#include
+#include
+#include
#include
#include
#include
#include
#include
+#include
#include
+#include
#include
+#include
#include
#include