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

Maintenance: Enable nullable references across the solution #284

Open
1 task done
hjgraca opened this issue May 26, 2023 · 0 comments
Open
1 task done

Maintenance: Enable nullable references across the solution #284

hjgraca opened this issue May 26, 2023 · 0 comments
Labels
internal Maintenance changes

Comments

@hjgraca
Copy link
Contributor

hjgraca commented May 26, 2023

Summary

C# 8.0 introduced a significant new feature to the language that extends the type system to make a distinction between references that may be null and ones that must not be.
Enabling non-nullability is a radical change, which is why the feature is switched off until we enabled it explicitly

Why is this needed?

Nullability becomes an opt-in feature: a reference will never contain null unless it is explicitly defined as a nullable reference.
Enabling the type system to distinguish between nullable and non-nullable references is going to be a tricky thing to retrofit. C# cannot always guarantee that a non-nullable reference will never contain a null.
However, it can make the guarantee if certain constraints hold, and more generally it will significantly reduce the chances of encountering a NullReferenceException even in cases where it cannot absolutely rule this out.

Which area does this relate to?

Governance

Solution

On each projects .csproj file add inside PropertyGroup the new tag <Nullable>enable</Nullable>

Example:

<PropertyGroup>
  <Nullable>enable</Nullable>
</PropertyGroup>

Acknowledgment

@hjgraca hjgraca added internal Maintenance changes triage Pending triage from maintainers labels May 26, 2023
@hjgraca hjgraca removed the triage Pending triage from maintainers label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Maintenance changes
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant