From 93a3533fccc0f1128e762728d747da0a7b9192d7 Mon Sep 17 00:00:00 2001 From: Vlada Shubina Date: Thu, 26 Aug 2021 12:55:07 +0300 Subject: [PATCH 1/4] changed WinFormsApplication-CSharp to use tfm based sources; enabled file scoped namespaces and global usings --- .../.template.config/template.json | 73 ++++++++----------- .../Company.WinFormsApplication1.csproj.user | 8 -- .../Company.WinFormsApplication1.csproj | 0 .../{ => net5.0}/Form1.Designer.cs | 0 .../{ => net5.0}/Form1.cs | 13 ++++ .../Program.cs} | 19 +++++ .../Company.WinFormsApplication1.csproj | 14 ++++ .../net6.0/Form1.Designer.cs | 40 ++++++++++ .../net6.0/Form1.cs | 34 +++++++++ .../{ => net6.0}/Program.cs | 19 +++++ .../Company.WinFormsApplication1.csproj} | 0 .../netcoreapp3.1/Form1.Designer.cs | 40 ++++++++++ .../netcoreapp3.1/Form1.cs | 34 +++++++++ .../netcoreapp3.1/Program.cs | 43 +++++++++++ 14 files changed, 288 insertions(+), 49 deletions(-) delete mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj.user rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{ => net5.0}/Company.WinFormsApplication1.csproj (100%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{ => net5.0}/Form1.Designer.cs (100%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{ => net5.0}/Form1.cs (66%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{Program.boilerplate.cs => net5.0/Program.cs} (56%) create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Company.WinFormsApplication1.csproj create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.cs rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{ => net6.0}/Program.cs (54%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/{Company.WinFormsApplication3x1.csproj => netcoreapp3.1/Company.WinFormsApplication1.csproj} (100%) create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json index 68ca5548aa2..83c1f0aa828 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/.template.config/template.json @@ -1,7 +1,7 @@ { "$schema": "http://json.schemastore.org/template", "author": "Microsoft", - "classifications": ["Common", "WinForms"], + "classifications": [ "Common", "WinForms" ], "name": "Windows Forms App", "generatorVersions": "[1.0.0.0-*)", "description": "A project template for creating a .NET Windows Forms (WinForms) App.", @@ -49,14 +49,6 @@ "defaultValue": "net6.0", "displayName": "Framework" }, - "UseWindowsDesktopSdk": { - "type": "computed", - "value": "(Framework == \"netcoreapp3.1\")" - }, - "UseApplicationBoilerplate": { - "type": "computed", - "value": "(Framework == \"net5.0\")" - }, "langVersion": { "type": "parameter", "datatype": "text", @@ -82,6 +74,23 @@ "defaultValue": "true", "description": "Whether to enable nullable reference types for this project.", "displayName": "Enable nullable" + }, + "csharp10orLater": { + "type": "generated", + "generator": "regexMatch", + "datatype": "bool", + "parameters": { + "pattern": "^(|10\\.0|10|preview|latest|default|latestMajor)$", + "source": "langVersion" + } + }, + "csharpFeature_ImplicitUsings": { + "type": "computed", + "value": "Framework == \"net6.0\" && csharp10orLater == \"true\"" + }, + "csharpFeature_FileScopedNamespaces": { + "type": "computed", + "value": "(Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -93,37 +102,19 @@ ], "sources": [ { - "exclude": [ "**/[Bb]in/**", "**/[Oo]bj/**", ".template.config/**/*", "**/*.filelist", "**/*.lock.json" ], - "modifiers": [ - { - "condition": "(UseWindowsDesktopSdk)", - "exclude": [ - "Company.WinFormsApplication1.csproj", - "Program.cs" - ], - "rename": { - "Company.WinFormsApplication3x1.csproj": "Company.WinFormsApplication1.csproj", - "Program.boilerplate.cs": "Program.cs" - } - }, - { - "condition": "(!UseWindowsDesktopSdk && UseApplicationBoilerplate)", - "exclude": [ - "Company.WinFormsApplication3x1.csproj", - "Program.cs" - ], - "rename": { - "Program.boilerplate.cs": "Program.cs" - } - }, - { - "condition": "(!UseWindowsDesktopSdk && !UseApplicationBoilerplate)", - "exclude": [ - "Company.WinFormsApplication3x1.csproj", - "Program.boilerplate.cs" - ] - } - ] + "condition": "Framework == \"netcoreapp3.1\"", + "source": "./netcoreapp3.1", + "target": "./" + }, + { + "condition": "Framework == \"net5.0\"", + "source": "./net5.0", + "target": "./" + }, + { + "condition": "Framework == \"net6.0\"", + "source": "./net6.0", + "target": "./" } ], "defaultName": "WinFormsApp1", @@ -142,7 +133,7 @@ "id": "open-file", "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", "description": "Opens Form1.cs in the editor", - "manualInstructions": [ ], + "manualInstructions": [], "actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6", "args": { "files": "1" diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj.user b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj.user deleted file mode 100644 index 7814ea24efb..00000000000 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj.user +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Form - - - diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Company.WinFormsApplication1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Company.WinFormsApplication1.csproj diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.Designer.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs similarity index 66% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs index 0ac1f900f5d..28194683d6d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Form1.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs @@ -8,6 +8,18 @@ using System.Threading.Tasks; using System.Windows.Forms; +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +public partial class Form1 : Form +{ + public Form1() + { + InitializeComponent(); + } + +} +#else namespace Company.WinFormsApplication1 { public partial class Form1 : Form @@ -19,3 +31,4 @@ public Form1() } } +#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.boilerplate.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs similarity index 56% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.boilerplate.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs index f456f2c592b..16e480ac075 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.boilerplate.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs @@ -4,6 +4,24 @@ using System.Threading.Tasks; using System.Windows.Forms; +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } +} +#else namespace Company.WinFormsApplication1 { static class Program @@ -21,3 +39,4 @@ static void Main() } } } +#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Company.WinFormsApplication1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Company.WinFormsApplication1.csproj new file mode 100644 index 00000000000..3bdcf361e98 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Company.WinFormsApplication1.csproj @@ -0,0 +1,14 @@ + + + + WinExe + FrameworkParameter-windows + TargetFrameworkOverride-windows + Company.WinFormsApplication1 + $(ProjectLanguageVersion) + enable + true + enable + + + \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs new file mode 100644 index 00000000000..7bba2aa658a --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace Company.WinFormsApplication1 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.cs new file mode 100644 index 00000000000..d1ac7561fe4 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.cs @@ -0,0 +1,34 @@ +#if (!csharpFeature_ImplicitUsings) +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +#endif +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +public partial class Form1 : Form +{ + public Form1() + { + InitializeComponent(); + } +} +#else +namespace Company.WinFormsApplication1 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} +#endif diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Program.cs similarity index 54% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Program.cs index 026f8234c1d..9c35cf13f9b 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Program.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Program.cs @@ -1,9 +1,27 @@ +#if (!csharpFeature_ImplicitUsings) using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; +#endif +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + ApplicationConfiguration.Initialize(); + Application.Run(new Form1()); + } +} +#else namespace Company.WinFormsApplication1 { static class Program @@ -19,3 +37,4 @@ static void Main() } } } +#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication3x1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Company.WinFormsApplication1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/Company.WinFormsApplication3x1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Company.WinFormsApplication1.csproj diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs new file mode 100644 index 00000000000..7bba2aa658a --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace Company.WinFormsApplication1 +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs new file mode 100644 index 00000000000..28194683d6d --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +public partial class Form1 : Form +{ + public Form1() + { + InitializeComponent(); + } + +} +#else +namespace Company.WinFormsApplication1 +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + } +} +#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs new file mode 100644 index 00000000000..86d4fa8767c --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +static class Program +{ + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } +} + +#else +namespace Company.WinFormsApplication1 +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} +#endif \ No newline at end of file From a3ab22e5af2f6edce299f8f5fcd5d8bf36645858 Mon Sep 17 00:00:00 2001 From: Igor Velikorossov Date: Mon, 30 Aug 2021 15:58:42 +1000 Subject: [PATCH 2/4] Leave .NET Core 3.1 and .NET 5.0 templates as-is --- .../net5.0/Form1.Designer.cs | 1 - .../net5.0/Form1.cs | 13 ------ .../net5.0/Program.cs | 19 -------- .../net6.0/Form1.Designer.cs | 44 ++++++++++++++++++- .../netcoreapp3.1/Form1.Designer.cs | 1 - .../netcoreapp3.1/Form1.cs | 13 ------ .../netcoreapp3.1/Program.cs | 20 --------- 7 files changed, 42 insertions(+), 69 deletions(-) diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs index 7bba2aa658a..5367110f5c4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.Designer.cs @@ -37,4 +37,3 @@ private void InitializeComponent() #endregion } } - diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs index 28194683d6d..0ac1f900f5d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Form1.cs @@ -8,18 +8,6 @@ using System.Threading.Tasks; using System.Windows.Forms; -#if (csharpFeature_FileScopedNamespaces) -namespace Company.WinFormsApplication1; - -public partial class Form1 : Form -{ - public Form1() - { - InitializeComponent(); - } - -} -#else namespace Company.WinFormsApplication1 { public partial class Form1 : Form @@ -31,4 +19,3 @@ public Form1() } } -#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs index 16e480ac075..f456f2c592b 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net5.0/Program.cs @@ -4,24 +4,6 @@ using System.Threading.Tasks; using System.Windows.Forms; -#if (csharpFeature_FileScopedNamespaces) -namespace Company.WinFormsApplication1; - -static class Program -{ - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } -} -#else namespace Company.WinFormsApplication1 { static class Program @@ -39,4 +21,3 @@ static void Main() } } } -#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs index 7bba2aa658a..eb8b662216d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/net6.0/Form1.Designer.cs @@ -1,4 +1,44 @@ -namespace Company.WinFormsApplication1 +#if (csharpFeature_FileScopedNamespaces) +namespace Company.WinFormsApplication1; + +partial class Form1 +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion +} +#else +namespace Company.WinFormsApplication1 { partial class Form1 { @@ -37,4 +77,4 @@ private void InitializeComponent() #endregion } } - +#endif diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs index 7bba2aa658a..5367110f5c4 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.Designer.cs @@ -37,4 +37,3 @@ private void InitializeComponent() #endregion } } - diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs index 28194683d6d..0ac1f900f5d 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Form1.cs @@ -8,18 +8,6 @@ using System.Threading.Tasks; using System.Windows.Forms; -#if (csharpFeature_FileScopedNamespaces) -namespace Company.WinFormsApplication1; - -public partial class Form1 : Form -{ - public Form1() - { - InitializeComponent(); - } - -} -#else namespace Company.WinFormsApplication1 { public partial class Form1 : Form @@ -31,4 +19,3 @@ public Form1() } } -#endif \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs index 86d4fa8767c..f456f2c592b 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsApplication-CSharp/netcoreapp3.1/Program.cs @@ -4,25 +4,6 @@ using System.Threading.Tasks; using System.Windows.Forms; -#if (csharpFeature_FileScopedNamespaces) -namespace Company.WinFormsApplication1; - -static class Program -{ - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } -} - -#else namespace Company.WinFormsApplication1 { static class Program @@ -40,4 +21,3 @@ static void Main() } } } -#endif \ No newline at end of file From 40a9443b5109557f5e560c6334c9f1173e4dd424 Mon Sep 17 00:00:00 2001 From: Igor Velikorossov Date: Mon, 30 Aug 2021 17:06:14 +1000 Subject: [PATCH 3/4] Update WinFormsControlLibrary-CSharp --- .../.template.config/template.json | 52 +++++++------ .../Company.ControlLibrary1.csproj.user | 8 -- .../Company.ControlLibrary1.csproj | 0 .../{ => net5.0}/UserControl1.Designer.cs | 0 .../{ => net5.0}/UserControl1.cs | 0 .../net6.0/Company.ControlLibrary1.csproj | 13 ++++ .../net6.0/UserControl1.Designer.cs | 78 +++++++++++++++++++ .../net6.0/UserControl1.cs | 27 +++++++ .../Company.ControlLibrary1.csproj} | 0 .../netcoreapp3.1/UserControl1.Designer.cs | 38 +++++++++ .../netcoreapp3.1/UserControl1.cs | 13 ++++ 11 files changed, 199 insertions(+), 30 deletions(-) delete mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj.user rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/{ => net5.0}/Company.ControlLibrary1.csproj (100%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/{ => net5.0}/UserControl1.Designer.cs (100%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/{ => net5.0}/UserControl1.cs (100%) create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/Company.ControlLibrary1.csproj create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.Designer.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.cs rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/{Company.ControlLibrary3x1.csproj => netcoreapp3.1/Company.ControlLibrary1.csproj} (100%) create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.Designer.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json index 61297b33801..01c160d369b 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/.template.config/template.json @@ -49,10 +49,6 @@ "defaultValue": "net6.0", "displayName": "Framework" }, - "UseWindowsDesktopSdk": { - "type": "computed", - "value": "(Framework == \"netcoreapp3.1\")" - }, "langVersion": { "type": "parameter", "datatype": "text", @@ -78,6 +74,23 @@ "defaultValue": "true", "description": "Whether to enable nullable reference types for this project.", "displayName": "Enable nullable" + }, + "csharp10orLater": { + "type": "generated", + "generator": "regexMatch", + "datatype": "bool", + "parameters": { + "pattern": "^(|10\\.0|10|preview|latest|default|latestMajor)$", + "source": "langVersion" + } + }, + "csharpFeature_ImplicitUsings": { + "type": "computed", + "value": "Framework == \"net6.0\" && csharp10orLater == \"true\"" + }, + "csharpFeature_FileScopedNamespaces": { + "type": "computed", + "value": "(Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -89,24 +102,19 @@ ], "sources": [ { - "exclude": [ "**/[Bb]in/**", "**/[Oo]bj/**", ".template.config/**/*", "**/*.filelist", "**/*.lock.json" ], - "modifiers": [ - { - "condition": "(UseWindowsDesktopSdk)", - "exclude": [ - "Company.ControlLibrary1.csproj" - ], - "rename": { - "Company.ControlLibrary3x1.csproj": "Company.ControlLibrary1.csproj" - } - }, - { - "condition": "(!UseWindowsDesktopSdk)", - "exclude": [ - "Company.ControlLibrary3x1.csproj" - ] - } - ] + "condition": "Framework == \"netcoreapp3.1\"", + "source": "./netcoreapp3.1", + "target": "./" + }, + { + "condition": "Framework == \"net5.0\"", + "source": "./net5.0", + "target": "./" + }, + { + "condition": "Framework == \"net6.0\"", + "source": "./net6.0", + "target": "./" } ], "defaultName": "WinFormsControlLibrary1", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj.user b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj.user deleted file mode 100644 index 81dca9d6b83..00000000000 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj.user +++ /dev/null @@ -1,8 +0,0 @@ - - - - - UserControl - - - \ No newline at end of file diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/Company.ControlLibrary1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/Company.ControlLibrary1.csproj diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/UserControl1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/UserControl1.Designer.cs similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/UserControl1.Designer.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/UserControl1.Designer.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/UserControl1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/UserControl1.cs similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/UserControl1.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net5.0/UserControl1.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/Company.ControlLibrary1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/Company.ControlLibrary1.csproj new file mode 100644 index 00000000000..a689b368cb8 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/Company.ControlLibrary1.csproj @@ -0,0 +1,13 @@ + + + + FrameworkParameter-windows + TargetFrameworkOverride-windows + Company.ControlLibrary1 + $(ProjectLanguageVersion) + enable + true + enable + + + diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.Designer.cs new file mode 100644 index 00000000000..fdafbb7f89e --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.Designer.cs @@ -0,0 +1,78 @@ +#if (csharpFeature_FileScopedNamespaces) +namespace Company.ControlLibrary1; + +partial class UserControl1 +{ + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + } + + #endregion +} +#else +namespace Company.ControlLibrary1 +{ + partial class UserControl1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + } + + #endregion + } +} +#endif diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.cs new file mode 100644 index 00000000000..bcea26122e3 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/net6.0/UserControl1.cs @@ -0,0 +1,27 @@ +#if (!csharpFeature_ImplicitUsings) +using System; +using System.Windows.Forms; + +#endif +#if (csharpFeature_FileScopedNamespaces) +namespace Company.ControlLibrary1; + +public partial class UserControl1: UserControl +{ + public UserControl1() + { + InitializeComponent(); + } +} +#else +namespace Company.ControlLibrary1 +{ + public partial class UserControl1: UserControl + { + public UserControl1() + { + InitializeComponent(); + } + } +} +#endif diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary3x1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/Company.ControlLibrary1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/Company.ControlLibrary3x1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/Company.ControlLibrary1.csproj diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.Designer.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.Designer.cs new file mode 100644 index 00000000000..204ef56e8ff --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.Designer.cs @@ -0,0 +1,38 @@ +namespace Company.ControlLibrary1 +{ + partial class UserControl1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + } + + #endregion + } +} diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.cs new file mode 100644 index 00000000000..4bb7a869b7c --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsControlLibrary-CSharp/netcoreapp3.1/UserControl1.cs @@ -0,0 +1,13 @@ +using System; +using System.Windows.Forms; + +namespace Company.ControlLibrary1 +{ + public partial class UserControl1: UserControl + { + public UserControl1() + { + InitializeComponent(); + } + } +} From a9eff0c7126aff82a11e7691fd08e2f8981f04f4 Mon Sep 17 00:00:00 2001 From: Igor Velikorossov Date: Mon, 30 Aug 2021 17:27:10 +1000 Subject: [PATCH 4/4] Update WinFormsLibrary-CSharp --- .../.template.config/template.json | 51 +++++++++++-------- .../{ => net5.0}/Class1.cs | 0 .../{ => net5.0}/Company.ClassLibrary1.csproj | 0 .../WinFormsLibrary-CSharp/net6.0/Class1.cs | 18 +++++++ .../net6.0/Company.ClassLibrary1.csproj | 13 +++++ .../netcoreapp3.1/Class1.cs | 8 +++ .../Company.ClassLibrary1.csproj} | 0 7 files changed, 69 insertions(+), 21 deletions(-) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/{ => net5.0}/Class1.cs (100%) rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/{ => net5.0}/Company.ClassLibrary1.csproj (100%) create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Class1.cs create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Company.ClassLibrary1.csproj create mode 100644 pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Class1.cs rename pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/{Company.ClassLibrary3x1.csproj => netcoreapp3.1/Company.ClassLibrary1.csproj} (100%) diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json index 642cc550a0d..3ed92a48c70 100644 --- a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/.template.config/template.json @@ -49,10 +49,6 @@ "defaultValue": "net6.0", "displayName": "Framework" }, - "UseWindowsDesktopSdk": { - "type": "computed", - "value": "(Framework == \"netcoreapp3.1\")" - }, "langVersion": { "type": "parameter", "datatype": "text", @@ -78,6 +74,23 @@ "defaultValue": "true", "description": "Whether to enable nullable reference types for this project.", "displayName": "Enable nullable" + }, + "csharp10orLater": { + "type": "generated", + "generator": "regexMatch", + "datatype": "bool", + "parameters": { + "pattern": "^(|10\\.0|10|preview|latest|default|latestMajor)$", + "source": "langVersion" + } + }, + "csharpFeature_ImplicitUsings": { + "type": "computed", + "value": "Framework == \"net6.0\" && csharp10orLater == \"true\"" + }, + "csharpFeature_FileScopedNamespaces": { + "type": "computed", + "value": "(Framework == \"net6.0\" || langVersion != \"\") && csharp10orLater == \"true\"" } }, "primaryOutputs": [ @@ -89,23 +102,19 @@ ], "sources": [ { - "modifiers": [ - { - "condition": "(UseWindowsDesktopSdk)", - "exclude": [ - "Company.ClassLibrary1.csproj" - ], - "rename": { - "Company.ClassLibrary3x1.csproj": "Company.ClassLibrary1.csproj" - } - }, - { - "condition": "(!UseWindowsDesktopSdk)", - "exclude": [ - "Company.ClassLibrary3x1.csproj" - ] - } - ] + "condition": "Framework == \"netcoreapp3.1\"", + "source": "./netcoreapp3.1", + "target": "./" + }, + { + "condition": "Framework == \"net5.0\"", + "source": "./net5.0", + "target": "./" + }, + { + "condition": "Framework == \"net6.0\"", + "source": "./net6.0", + "target": "./" } ], "defaultName": "WinFormsLibrary1", diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Class1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net5.0/Class1.cs similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Class1.cs rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net5.0/Class1.cs diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Company.ClassLibrary1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net5.0/Company.ClassLibrary1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Company.ClassLibrary1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net5.0/Company.ClassLibrary1.csproj diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Class1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Class1.cs new file mode 100644 index 00000000000..ceddf45fb29 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Class1.cs @@ -0,0 +1,18 @@ +#if (!csharpFeature_ImplicitUsings) +using System; + +#endif +#if (csharpFeature_FileScopedNamespaces) +namespace Company.ClassLibrary1; + +public class Class1 +{ +} +#else +namespace Company.ClassLibrary1 +{ + public class Class1 + { + } +} +#endif diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Company.ClassLibrary1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Company.ClassLibrary1.csproj new file mode 100644 index 00000000000..62f2f26fda0 --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/net6.0/Company.ClassLibrary1.csproj @@ -0,0 +1,13 @@ + + + + FrameworkParameter-windows + TargetFrameworkOverride-windows + Company.ClassLibrary1 + $(ProjectLanguageVersion) + enable + true + enable + + + diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Class1.cs b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Class1.cs new file mode 100644 index 00000000000..72abb3efe5a --- /dev/null +++ b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace Company.ClassLibrary1 +{ + public class Class1 + { + } +} diff --git a/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Company.ClassLibrary3x1.csproj b/pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Company.ClassLibrary1.csproj similarity index 100% rename from pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/Company.ClassLibrary3x1.csproj rename to pkg/Microsoft.Dotnet.WinForms.ProjectTemplates/content/WinFormsLibrary-CSharp/netcoreapp3.1/Company.ClassLibrary1.csproj