Skip to content

enable nullable for new projects #32756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' == 'True'">1</WebProject_DirectoryAccessLevelKey>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">BlazorServerWeb_CSharp</RootNamespace>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<!--#if (IndividualLocalAuth && !UseLocalDB) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<!--#if Hosted -->
<AssemblyName Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">`$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<!--#endif -->
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">ComponentsWebAssembly-CSharp.Server</RootNamespace>
<AssemblyName Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">`$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
<AddRazorSupportForMvc Condition="'$(SupportPagesAndViews)' == 'True'">true</AddRazorSupportForMvc>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.RazorClassLibrary1</RootNamespace>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup Condition="'$(SupportPagesAndViews)' == 'True'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<CopyRefAssembliesToPublishDirectory Condition="'$(RazorRuntimeCompilation)'=='true'">false</CopyRefAssembliesToPublishDirectory>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>
<!--#if (IndividualLocalAuth && !UseLocalDB) -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<CopyRefAssembliesToPublishDirectory Condition="'$(RazorRuntimeCompilation)'=='true'">false</CopyRefAssembliesToPublishDirectory>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>
<!--#if (IndividualLocalAuth && !UseLocalDB) -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>
<!--#if (OrganizationalAuth || IndividualB2CAuth || EnableOpenAPI) -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<UserSecretsId>dotnet-Company.Application1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.Application1</RootNamespace>
<Nullable Condition="'$(Nullable)' == 'true'">enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"CallsMicrosoftGraph": {
"longName": "calls-graph",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,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 @@ -7,7 +7,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public class WeatherForecast

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

#if (!Nullable)
public string Summary { get; set; }
#else
public string? Summary { get; set; }
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
@if (Model?.ShowRequestId ?? false)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ namespace BlazorServerWeb_CSharp.Pages
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
#if (!Nullable)
public string RequestId { get; set; }
#else
public string? RequestId { get; set; }
#endif

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
"CallsMicrosoftGraph": {
"longName": "calls-graph",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@
"GenerateApiOrGraph": {
"type": "computed",
"value": "(GenerateApi || GenerateGraph)"
},
"Nullable": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"description": "Whether to enable nullable reference types for this project."
}
},
"tags": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ else

public int TemperatureC { get; set; }

@*#if (!Nullable)
public string Summary { get; set; }
#else
public string? Summary { get; set; }
#endif*@

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
@if (Model?.ShowRequestId ?? false)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ namespace ComponentsWebAssembly_CSharp.Server.Pages
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
#if (!Nullable)
public string RequestId { get; set; }
#else
public string? RequestId { get; set; }
#endif

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ public class WeatherForecast

public int TemperatureC { get; set; }

#if (!Nullable)
public string Summary { get; set; }
#else
public string? Summary { get; set; }
#endif

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"NoHttps": {
"longName": "no-https",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth."
},
"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 @@ -8,6 +8,10 @@
"ExcludeLaunchSettings": {
"longName": "exclude-launch-settings",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,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 @@ -12,6 +12,10 @@
"SupportPagesAndViews": {
"longName": "support-pages-and-views",
"shortName": "s"
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to support adding traditional Razor pages and Views in addition to components to this library."
},
"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 @@ -83,6 +83,10 @@
"CallsMicrosoftGraph": {
"longName": "calls-graph",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@
"GenerateApiOrGraph": {
"type": "computed",
"value": "(GenerateApi || GenerateGraph)"
},
"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 @@ -7,7 +7,7 @@
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
@if (Model?.ShowRequestId ?? false)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ namespace Company.WebApplication1.Pages
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
#if (!Nullable)
public string RequestId { get; set; }
#else
public string? RequestId { get; set; }
#endif

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/", new { area = "" })" method="post" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ul class="navbar-nav">
@*#if (IndividualB2CAuth)
@if (User.Identity.IsAuthenticated)
@if (User.Identity?.IsAuthenticated == true)
{
@if (!string.IsNullOrEmpty(options.EditProfilePolicyId))
{
Expand All @@ -38,7 +38,7 @@ else
</li>
}
#else
@if (User.Identity.IsAuthenticated)
@if (User.Identity?.IsAuthenticated == true)
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
"CallsMicrosoftGraph": {
"longName": "calls-graph",
"shortName": ""
},
"Nullable": {
"longName": "nullable",
"shortName": ""
}
},
"usageExamples": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@
"GenerateApiOrGraph": {
"type": "computed",
"value": "(GenerateApi || GenerateGraph)"
},
"Nullable": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"description": "Whether to enable nullable reference types for this project."
}
},
"primaryOutputs": [
Expand Down
Loading