From c3fc0b95b3f46444a61ec48818391bfd3f2de5fe Mon Sep 17 00:00:00 2001 From: Jonathon Marolf Date: Thu, 3 Jun 2021 08:20:51 -0700 Subject: [PATCH] enable nullable on new project templates (#3173) * enable nullable by default in the classlib template * revert having nullable in dotnetcli.host.json file Co-authored-by: Vlada Shubina --- .../.template.config/dotnetcli.host.json | 4 ++++ .../ClassLibrary-CSharp/.template.config/template.json | 6 ++++++ .../ClassLibrary-CSharp/Company.ClassLibrary1.csproj | 1 + test/dotnet-new3.UnitTests/DotnetNewHelp.cs | 6 +++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/dotnetcli.host.json b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/dotnetcli.host.json index 2c43fcf7d50..af7e5e7480a 100644 --- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/dotnetcli.host.json +++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/dotnetcli.host.json @@ -16,6 +16,10 @@ "langVersion": { "longName": "langVersion", "shortName": "" + }, + "Nullable": { + "longName": "nullable", + "shortName": "" } }, "usageExamples": [ diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json index 8d3dd077af2..040d365208a 100644 --- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json +++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json @@ -74,6 +74,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/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj index 2f950e3ec70..8df822dd268 100644 --- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj +++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj @@ -5,6 +5,7 @@ TargetFrameworkOverride Company.ClassLibrary1 $(ProjectLanguageVersion) + enable diff --git a/test/dotnet-new3.UnitTests/DotnetNewHelp.cs b/test/dotnet-new3.UnitTests/DotnetNewHelp.cs index 0dcc71ee233..982f708c889 100644 --- a/test/dotnet-new3.UnitTests/DotnetNewHelp.cs +++ b/test/dotnet-new3.UnitTests/DotnetNewHelp.cs @@ -96,7 +96,11 @@ public class DotnetNewHelp --no-restore If specified, skips the automatic restore of the project on create. bool - Optional - Default: false "; + Default: false + + --nullable Whether to enable nullable reference types for this project. + bool - Optional + Default: true "; #endregion private readonly ITestOutputHelper _log;