Skip to content

Commit c47af80

Browse files
authored
Update templates to use ApplicationConfiguration.Initialize() (#5529)
Relates to #5035 Relates to #5071
1 parent 08b29bc commit c47af80

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"type": "computed",
5454
"value": "(Framework == \"netcoreapp3.1\")"
5555
},
56+
"UseApplicationBoilerplate": {
57+
"type": "computed",
58+
"value": "(Framework == \"net5.0\")"
59+
},
5660
"langVersion": {
5761
"type": "parameter",
5862
"datatype": "text",
@@ -94,16 +98,29 @@
9498
{
9599
"condition": "(UseWindowsDesktopSdk)",
96100
"exclude": [
97-
"Company.WinFormsApplication1.csproj"
101+
"Company.WinFormsApplication1.csproj",
102+
"Program.cs"
103+
],
104+
"rename": {
105+
"Company.WinFormsApplication3x1.csproj": "Company.WinFormsApplication1.csproj",
106+
"Program.boilerplate.cs": "Program.cs"
107+
}
108+
},
109+
{
110+
"condition": "(!UseWindowsDesktopSdk && UseApplicationBoilerplate)",
111+
"exclude": [
112+
"Company.WinFormsApplication3x1.csproj",
113+
"Program.cs"
98114
],
99115
"rename": {
100-
"Company.WinFormsApplication3x1.csproj": "Company.WinFormsApplication1.csproj"
116+
"Program.boilerplate.cs": "Program.cs"
101117
}
102118
},
103119
{
104-
"condition": "(!UseWindowsDesktopSdk)",
120+
"condition": "(!UseWindowsDesktopSdk && !UseApplicationBoilerplate)",
105121
"exclude": [
106-
"Company.WinFormsApplication3x1.csproj"
122+
"Company.WinFormsApplication3x1.csproj",
123+
"Program.boilerplate.cs"
107124
]
108125
}
109126
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using System.Windows.Forms;
6+
7+
namespace Company.WinFormsApplication1
8+
{
9+
static class Program
10+
{
11+
/// <summary>
12+
/// The main entry point for the application.
13+
/// </summary>
14+
[STAThread]
15+
static void Main()
16+
{
17+
Application.SetHighDpiMode(HighDpiMode.SystemAware);
18+
Application.EnableVisualStyles();
19+
Application.SetCompatibleTextRenderingDefault(false);
20+
Application.Run(new Form1());
21+
}
22+
}
23+
}

pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ static class Program
1414
[STAThread]
1515
static void Main()
1616
{
17-
Application.SetHighDpiMode(HighDpiMode.SystemAware);
18-
Application.EnableVisualStyles();
19-
Application.SetCompatibleTextRenderingDefault(false);
17+
ApplicationConfiguration.Initialize();
2018
Application.Run(new Form1());
2119
}
2220
}

0 commit comments

Comments
 (0)