From 372a5849eef38b4e3a6f6c576b84624eed704392 Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Sun, 16 May 2021 16:09:06 -0700 Subject: [PATCH 1/2] enable nullable for new projects --- .../.template.config/dotnetcli.host.json | 4 ++++ .../WpfApplication-CSharp/Company.WpfApplication1.csproj | 2 ++ .../.template.config/dotnetcli.host.json | 4 ++++ .../WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj | 2 ++ .../.template.config/dotnetcli.host.json | 4 ++++ .../Company.WpfCustomControlLibrary.csproj | 2 ++ .../.template.config/dotnetcli.host.json | 4 ++++ .../Company.WpfControlLibrary.csproj | 2 ++ 8 files changed, 24 insertions(+) diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json index 22ab4a3929f..d45ec365327 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,10 @@ "langVersion": { "longName": "langVersion", "shortName": "" + }, + "NullableOverride": { + "longName": "nullable", + "shortName": "" } }, "usageExamples": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj index ae7f087a75b..e7d487a1aed 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj @@ -6,6 +6,8 @@ TargetFrameworkOverride-windows Company.WpfApplication1 $(ProjectLanguageVersion) + enable + NullableOverride true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json index 22ab4a3929f..d45ec365327 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,10 @@ "langVersion": { "longName": "langVersion", "shortName": "" + }, + "NullableOverride": { + "longName": "nullable", + "shortName": "" } }, "usageExamples": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj index 789f85656a8..bb8b73ad597 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj @@ -5,6 +5,8 @@ TargetFrameworkOverride-windows Company.ClassLibrary1 $(ProjectLanguageVersion) + enable + NullableOverride true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json index 22ab4a3929f..d45ec365327 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,10 @@ "langVersion": { "longName": "langVersion", "shortName": "" + }, + "NullableOverride": { + "longName": "nullable", + "shortName": "" } }, "usageExamples": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj index 33945934b95..24b462d6e69 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj @@ -5,6 +5,8 @@ TargetFrameworkOverride-windows Company.WpfCustomControlLibrary $(ProjectLanguageVersion) + enable + NullableOverride true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json index 22ab4a3929f..d45ec365327 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,10 @@ "langVersion": { "longName": "langVersion", "shortName": "" + }, + "NullableOverride": { + "longName": "nullable", + "shortName": "" } }, "usageExamples": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj index 7b1312c1b95..9f553f5d61b 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj @@ -5,6 +5,8 @@ TargetFrameworkOverride-windows Company.WpfControlLibrary $(ProjectLanguageVersion) + enable + NullableOverride true From f287523e4af99d39cdc746fba6d8f2ee6fbf3a7d Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Mon, 17 May 2021 11:15:50 -0700 Subject: [PATCH 2/2] update template.json --- .../.template.config/dotnetcli.host.json | 2 +- .../.template.config/template.json | 10 ++++++++-- .../Company.WpfApplication1.csproj | 3 +-- .../.template.config/dotnetcli.host.json | 2 +- .../.template.config/template.json | 6 ++++++ .../Company.ClassLibrary1.csproj | 3 +-- .../.template.config/dotnetcli.host.json | 2 +- .../.template.config/template.json | 6 ++++++ .../Company.WpfCustomControlLibrary.csproj | 3 +-- .../.template.config/dotnetcli.host.json | 2 +- .../.template.config/template.json | 6 ++++++ .../Company.WpfControlLibrary.csproj | 3 +-- 12 files changed, 34 insertions(+), 14 deletions(-) diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json index d45ec365327..3ba9f7c9be9 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/dotnetcli.host.json @@ -17,7 +17,7 @@ "longName": "langVersion", "shortName": "" }, - "NullableOverride": { + "Nullable": { "longName": "nullable", "shortName": "" } diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/template.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/template.json index 224a8b56f1d..2785a48ed9e 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/template.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/.template.config/template.json @@ -43,7 +43,7 @@ { "choice": "net6.0", "description": "Target net6.0" - } + } ], "replaces": "FrameworkParameter", "defaultValue": "net6.0" @@ -68,6 +68,12 @@ "datatype": "bool", "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" + }, + "Nullable": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "true", + "description": "Whether to enable nullable reference types for this project." } }, "primaryOutputs": [ @@ -76,7 +82,7 @@ "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", "path": "MainWindow.xaml.cs" }, - { + { "condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")", "path": "MainWindow.xaml" } diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj index e7d487a1aed..7a268bdea17 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfApplication-CSharp/Company.WpfApplication1.csproj @@ -6,8 +6,7 @@ TargetFrameworkOverride-windows Company.WpfApplication1 $(ProjectLanguageVersion) - enable - NullableOverride + enable true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json index d45ec365327..3ba9f7c9be9 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/dotnetcli.host.json @@ -17,7 +17,7 @@ "longName": "langVersion", "shortName": "" }, - "NullableOverride": { + "Nullable": { "longName": "nullable", "shortName": "" } diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/template.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/template.json index d4e3c8d4b32..64462a92f50 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/template.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/.template.config/template.json @@ -68,6 +68,12 @@ "datatype": "bool", "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" + }, + "Nullable": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "true", + "description": "Whether to enable nullable reference types for this project." } }, "primaryOutputs": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj index bb8b73ad597..39443dc822f 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfClassLibrary-CSharp/Company.ClassLibrary1.csproj @@ -5,8 +5,7 @@ TargetFrameworkOverride-windows Company.ClassLibrary1 $(ProjectLanguageVersion) - enable - NullableOverride + enable true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json index d45ec365327..3ba9f7c9be9 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/dotnetcli.host.json @@ -17,7 +17,7 @@ "longName": "langVersion", "shortName": "" }, - "NullableOverride": { + "Nullable": { "longName": "nullable", "shortName": "" } diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/template.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/template.json index a48cd5a63af..362b281a80d 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/template.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/.template.config/template.json @@ -68,6 +68,12 @@ "datatype": "bool", "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" + }, + "Nullable": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "true", + "description": "Whether to enable nullable reference types for this project." } }, "primaryOutputs": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj index 24b462d6e69..de80086d2a9 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfCustomControlLibrary-CSharp/Company.WpfCustomControlLibrary.csproj @@ -5,8 +5,7 @@ TargetFrameworkOverride-windows Company.WpfCustomControlLibrary $(ProjectLanguageVersion) - enable - NullableOverride + enable true diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json index d45ec365327..3ba9f7c9be9 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/dotnetcli.host.json @@ -17,7 +17,7 @@ "longName": "langVersion", "shortName": "" }, - "NullableOverride": { + "Nullable": { "longName": "nullable", "shortName": "" } diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/template.json b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/template.json index 69e28b1491c..8f8da7c587b 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/template.json +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/.template.config/template.json @@ -68,6 +68,12 @@ "datatype": "bool", "description": "If specified, skips the automatic restore of the project on create.", "defaultValue": "false" + }, + "Nullable": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "true", + "description": "Whether to enable nullable reference types for this project." } }, "primaryOutputs": [ diff --git a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj index 9f553f5d61b..9a6de4c00ad 100644 --- a/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj +++ b/packaging/Microsoft.Dotnet.Wpf.ProjectTemplates/content/WpfUserControlLibrary-CSharp/Company.WpfControlLibrary.csproj @@ -5,8 +5,7 @@ TargetFrameworkOverride-windows Company.WpfControlLibrary $(ProjectLanguageVersion) - enable - NullableOverride + enable true