Skip to content

[release/1.4-stable] Various fixes for C++ project and item templates (#3745) #3754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem OpenInEditor="true" ReplaceParameters="true" ItemType="Page" CustomTool="MSBuild:Compile" TargetFileName="$fileinputname$.xaml">BlankWindow.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;

namespace winrt::$rootnamespace$::implementation
{
$safeitemname$::$safeitemname$()
{
InitializeComponent();
}

int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "$safeitemname$.g.h"
Expand All @@ -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);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace $rootnamespace$
{
[default_interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Designer" TargetFileName="$fileinputname$.xaml" ReplaceParameters="true">BlankWindow.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem OpenInEditor="true" ReplaceParameters="true" ItemType="Page" CustomTool="MSBuild:Compile" TargetFileName="$fileinputname$.xaml">BlankPage.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem OpenInEditor="true" ReplaceParameters="true" ItemType="Page" CustomTool="MSBuild:Compile" TargetFileName="$fileinputname$.xaml">ResourceDictionary.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem ItemType="PRIResource">Resources.resw</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.cs">CustomControl.cs</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>csharp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem OpenInEditor="true" ReplaceParameters="true" ItemType="Page" CustomTool="MSBuild:Compile" TargetFileName="$fileinputname$.xaml">UserControl.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;

namespace winrt::$rootnamespace$::implementation
{
$safeitemname$::$safeitemname$()
{
InitializeComponent();
}

int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
Expand Down
11 changes: 6 additions & 5 deletions dev/VSIX/ItemTemplates/Neutral/CppWinRT/BlankPage/BlankPage.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "$safeitemname$.g.h"
Expand All @@ -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);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace $rootnamespace$
{
[default_interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Designer" TargetFileName="$fileinputname$.xaml" ReplaceParameters="true">BlankPage.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem OpenInEditor="true" ReplaceParameters="true" ItemType="Page" TargetFileName="$fileinputname$.xaml">ResourceDictionary.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem ItemType="PRIResource">Resources.resw</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace $rootnamespace$
{
[default_interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cpp" ReplaceParameters="true">TemplatedControl.cpp</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -15,11 +12,6 @@ using namespace Microsoft::UI::Xaml;

namespace winrt::$rootnamespace$::implementation
{
$safeitemname$::$safeitemname$()
{
InitializeComponent();
}

int32_t $safeitemname$::MyProperty()
{
throw hresult_not_implemented();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

namespace $rootnamespace$
{
[default_interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<TargetPlatformName>Windows</TargetPlatformName>
<LanguageTag>cpp</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>uwp</ProjectTypeTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<ProjectItem SubType="Designer" TargetFileName="$fileinputname$.xaml" ReplaceParameters="true">UserControl.xaml</ProjectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LanguageTag>XAML</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>WinUI</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent PreferedSolutionConfiguration="Debug|AnyCPU">
<CustomParameters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<LanguageTag>XAML</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>WinUI</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent PreferedSolutionConfiguration="Debug|x86">
<Project File="ProjectTemplate.csproj" ReplaceParameters="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LanguageTag>XAML</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>WinUI</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent>
<CustomParameters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LanguageTag>XAML</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>WinUI</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent PreferedSolutionConfiguration="Debug|x86">
<CustomParameters>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<LanguageTag>XAML</LanguageTag>
<PlatformTag>windows</PlatformTag>
<ProjectTypeTag>desktop</ProjectTypeTag>
<ProjectTypeTag>WinUI</ProjectTypeTag>
<ProjectTypeTag>winui</ProjectTypeTag>
</TemplateData>
<TemplateContent PreferedSolutionConfiguration="Debug|x86">
<CustomParameters>
Expand Down
Loading