-
Notifications
You must be signed in to change notification settings - Fork 230
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
Update scaffolders to support nullable reference types #1594
Comments
For Scaffolding the same templates are re-used for multiple TFM’s. So, the generated code is not nullable friendly for controllers, pages & identity. This is the current proposed plan of action: Phase 1. The generated code from Scaffolding will add |
Hi an update. |
@wadepickett Confirmed! The error is no more showing as before. |
For .NET 7, I just needed to make the following change in 3 files - public Movie Movie { get; set; }
+ public Movie Movie { get; set; } = default!; Can I get a guarantee this is fixed right for .NET 8? cc @vijayrkn @deepchoudhery |
Hey @Rick-Anderson, all templates should be nullable friendly in .NET 7. |
Nullable reference types was a feature introduced in C# 8. In .NET 6 we intend to enable it for new projects by default (see dotnet/templating#3359).
Any code emitted into a project by scaffolders should ensure that it doesn't introduce nullability warnings given the configuration of nullable reference types in the target project. This might mean updating the code to be "safe" for inclusion when nullable is on or off, or making the scaffolder emit different code depending on whether the project's nullable context configuration (i.e. the value of the
<Nullable>
property in the .csproj file).@vijayrkn
The text was updated successfully, but these errors were encountered: