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

Enable nullable in project #769

Merged
merged 2 commits into from
Sep 21, 2024
Merged

Enable nullable in project #769

merged 2 commits into from
Sep 21, 2024

Conversation

Arthurvdv
Copy link
Collaborator

Enabling nullable reference types will improve the LinterCop on reducing possible System.NullReferenceException errors.

New rules will automatically have the nullable reference types enabled, where existing rules will be reviewed in the future.

Originally, all reference-type variables were nullable. This meant that you always had to consider the possibility of a null reference and code accordingly. If it was your intention that a variable never be null, there was no way to enforce that. If you treated it like it would never be null, there was always the possibility of a NullReferenceException at run time if someone mistakenly set it to null.

Now, you can specify which variables should be nullable and which shouldn't and the compiler will enforce that. If you try to make a non-nullable variable null, a compiler error will prevent that. If you treat a nullable variable as though it definitely won't be null, a compiler warning will alert you.

https://stackoverflow.com/a/74583086

@Arthurvdv Arthurvdv merged commit 93e94ff into prerelease Sep 21, 2024
44 checks passed
@Arthurvdv Arthurvdv deleted the Nullable branch September 21, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant