-
Notifications
You must be signed in to change notification settings - Fork 369
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
Change C# templates to have #nullable enabled
by default
#2979
Comments
Enabling by default is even better: dotnet/roslyn#52302. |
Thank you for great idea, will see where Roslyn discussion leads and act accordingly. |
Let's see where the Roslyn discussion goes. I am a tad concerned about turning it on in simple templates by default because of new to programming new users. Maybe @jongalloway or @jamesmontemagno could weigh in on that. |
I think it should be turned on for the "new to programming" users - it helps them a lot to get rid of the null errors in their programs they do otherwise. @jongalloway @jamesmontemagno what's your opinion? |
Honestly I am torn here, because yes I think it would get rid of null errors in code, but could lead to more confusion when things don't compile and you have to learn a big concept just getting started. |
Some additional views: I'm working a lot with students. The main issues I'm seeing in their code is issues with null. If creating new projects don't have this setting, they don't turn it on. When they then first learn about this feature, they have a lot to change in their projects, and than this feature stays turned off. Learning materials for beginners should show this feature early. This will not happen if nullable is not turned on by default. I'm just in the finishing steps where all the projects have nullable turned on. Many complains from a reviewer because the code I'm showing does not compile with default project settings - although of course it was explained in the beginning. I added a note in every chapter that nullable is turned on. Having a directory default setting does not help in this case. Copying a project to a different directory, it's not compiling anymore. The more I'm thinking about it and helping new programmers - and also supporting long-time developers giving information on this feature - I think the default should be to have nullable turned on with new projects, and should be explicitly turned on with existing projects. I hope this helps for the discussion. |
#nullable enabled
by default
I changed title, I hope you don't mind, I'm also a bit confused what is Roslyn planning to change on their side to change this... |
We have enabled nullable for |
Thanks for the status @vlada-shubina, what about the other templates (ASP.NET Core, WPF, .NET MAUI,...)? |
@christiannagel other templates are being updated in scope of dotnet/templates#485. This repo only have classlib, console and common item templates. |
It would be great to have nullable reference types enabled by default in new projects.
Because of the breaking changes it's understandable that this is not the default with existing projects, but creating new projects this should be the default, or easily turned on to be the default.
Just turning nullable reference types on with directory properties does not help. Using this, if a project with nullable reference types is copied results in compiler warnings.
At least there should be an option that can be easily configured that new projects should be created with nullable reference types turned on.
The text was updated successfully, but these errors were encountered: