Skip to content

Validate default Razor and Blazor project templates with nullability enforcement enabled doesn't result in unexpected warnings. #13072

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
NTaylorMullen opened this issue Aug 12, 2019 · 3 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Validation This issue is used to track validation efforts

Comments

@NTaylorMullen
Copy link

  • Open up all of the .cshtml files in a Razor pages site with nullability enforcement enabled and ensure that there are no warnings for nullability.
  • Open up all of the .razor files in a Razor pages site with nullability enforcement enabled and ensure that there are no warnings for nullability.
@NTaylorMullen NTaylorMullen added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-blazor Includes: Blazor, Razor Components Validation This issue is used to track validation efforts labels Aug 12, 2019
@NTaylorMullen NTaylorMullen added this to the 3.0.0-preview9 milestone Aug 12, 2019
@NTaylorMullen NTaylorMullen self-assigned this Aug 12, 2019
@NTaylorMullen
Copy link
Author

  • Open up all of the .razor files in a Razor pages site with nullability enforcement enabled and ensure that there are no warnings for nullability.

@danroth27 there are several locations in our Blazor project templates that aren't nullable enforcement friendly. Is this something we want to address or leave as is? I'm uncertain of C#'s plans to turn the feature on by default or not so this decision might be largely based on that decision as well.

For context in Blazor server side app there's:

Shared\NavMenu.razor(31,31): warning CS8603: Possible null reference return. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
Pages\FetchData.razor(40,23): warning CS8618: Non-nullable field 'forecasts' is uninitialized. Consider declaring the field as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
Data\WeatherForecast.cs(13,23): warning CS8618: Non-nullable property 'Summary' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
Data\WeatherForecast.cs(13,23): warning CS8618: Non-nullable property 'Summary' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
Shared\NavMenu.razor(31,31): warning CS8603: Possible null reference return. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
Pages\FetchData.razor(40,23): warning CS8618: Non-nullable field 'forecasts' is uninitialized. Consider declaring the field as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorServerSide\Preview9BlazorServerSide\Preview9BlazorServerSide.csproj]
    6 Warning(s)

Blazor WASM:

Shared\SurveyPrompt.razor(14,31): warning CS8618: Non-nullable property 'Title' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Shared\NavMenu.razor(31,31): warning CS8603: Possible null reference return. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Pages\FetchData.razor(38,23): warning CS8618: Non-nullable field 'forecasts' is uninitialized. Consider declaring the field as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Pages\FetchData.razor(51,23): warning CS8618: Non-nullable property 'Summary' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Shared\SurveyPrompt.razor(14,31): warning CS8618: Non-nullable property 'Title' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Pages\FetchData.razor(38,23): warning CS8618: Non-nullable field 'forecasts' is uninitialized. Consider declaring the field as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Pages\FetchData.razor(51,23): warning CS8618: Non-nullable property 'Summary' is uninitialized. Consider declaring the property as nullable. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
Shared\NavMenu.razor(31,31): warning CS8603: Possible null reference return. [C:\Users\nimullen.REDMOND\source\repos\Preview9BlazorWASM\Preview9BlazorWASM\Preview9BlazorWASM.csproj]
    8 Warning(s)

@danroth27
Copy link
Member

@NTaylorMullen We should address these, so go ahead and file an issue if you haven't already.

@NTaylorMullen
Copy link
Author

Looks like I already filed an issue for this a while back that's in 3.1.0. Feel free to move the milestone if you want: #10921

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Validation This issue is used to track validation efforts
Projects
None yet
Development

No branches or pull requests

2 participants