Skip to content

Commit

Permalink
enable nullable on new project templates (#3173)
Browse files Browse the repository at this point in the history
* enable nullable by default in the classlib template

* revert having nullable in dotnetcli.host.json file

Co-authored-by: Vlada Shubina <vshubina@microsoft.com>
  • Loading branch information
jmarolf and vlada-shubina authored Jun 3, 2021
1 parent f253696 commit c3fc0b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"langVersion": {
"longName": "langVersion",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.ClassLibrary1</RootNamespace>
<LangVersion Condition="'$(langVersion)' != ''">$(ProjectLanguageVersion)</LangVersion>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

</Project>
6 changes: 5 additions & 1 deletion test/dotnet-new3.UnitTests/DotnetNewHelp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c3fc0b9

Please sign in to comment.