Skip to content
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

Closed
christiannagel opened this issue Mar 31, 2021 · 10 comments · Fixed by #3173
Closed

Change C# templates to have #nullable enabled by default #2979

christiannagel opened this issue Mar 31, 2021 · 10 comments · Fixed by #3173
Labels
area: template-content The issue is related to content of template packages managed in this repo (/template_feed) need-pm-discussion Need agreement from PM that the issue aligns to targeted stories for any of the next 2 releases triaged The issue was evaluated by the triage team, placed on correct area, next action defined.

Comments

@christiannagel
Copy link

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.

@christiannagel
Copy link
Author

Enabling by default is even better: dotnet/roslyn#52302.
Depending on the status in the Roslyn repo, it probably can be closed here.

@DavidKarlas DavidKarlas added need-pm-discussion Need agreement from PM that the issue aligns to targeted stories for any of the next 2 releases triaged The issue was evaluated by the triage team, placed on correct area, next action defined. labels Apr 2, 2021
@DavidKarlas
Copy link
Contributor

Thank you for great idea, will see where Roslyn discussion leads and act accordingly.

@KathleenDollard
Copy link

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.

@vlada-shubina vlada-shubina removed the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Apr 13, 2021
@christiannagel
Copy link
Author

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?

@jamesmontemagno
Copy link
Member

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.

@christiannagel
Copy link
Author

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.

@DavidKarlas DavidKarlas changed the title nullable reference types in templates Change C# templates to have #nullable enabled by default Apr 17, 2021
@DavidKarlas
Copy link
Contributor

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...

@vlada-shubina vlada-shubina added the area: template-content The issue is related to content of template packages managed in this repo (/template_feed) label Apr 21, 2021
@bekir-ozturk bekir-ozturk added the triaged The issue was evaluated by the triage team, placed on correct area, next action defined. label Apr 26, 2021
@vlada-shubina
Copy link
Member

We have enabled nullable for classlib.
For console template - we decided to freeze it at this point and not do anymore changes to it as it might be breaking change for many users that use it in their educational manuals. We are going to create new version of console template - "Console App" template - which will have nullable enabled.

@christiannagel
Copy link
Author

Thanks for the status @vlada-shubina, what about the other templates (ASP.NET Core, WPF, .NET MAUI,...)?

@vlada-shubina
Copy link
Member

@christiannagel other templates are being updated in scope of dotnet/templates#485. This repo only have classlib, console and common item templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: template-content The issue is related to content of template packages managed in this repo (/template_feed) need-pm-discussion Need agreement from PM that the issue aligns to targeted stories for any of the next 2 releases triaged The issue was evaluated by the triage team, placed on correct area, next action defined.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants