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
Add Nullable annotation support in MudBlazor. #6535
Labels
Comments
👋 Thanks for wanting to do a PR @ScarletKuro ! |
This was referenced Mar 27, 2023
This was referenced Apr 8, 2023
This was referenced Apr 17, 2023
Open
2 tasks
This was referenced Apr 21, 2023
This was referenced Jun 7, 2023
5 tasks
This was referenced Jul 1, 2023
This was referenced Jul 9, 2023
This was referenced Aug 10, 2023
This was referenced Aug 26, 2023
2 tasks
6 tasks
6 tasks
6 tasks
This was referenced Apr 1, 2024
This was referenced Apr 10, 2024
This was referenced May 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem?
Update the codebase with nullable reference types to improve null diagnostic warnings, more info here.
Not only end user will benefit from this, but also the codebase quality will increase.
NullReferenceException
would be much rare. For example, currently the DataGrid suffers from this issue.Nowadays, the
<Nullable>enable</Nullable>
is the default when you create a new projects.List of projects that has the nullable enabled on the project level
List of components that should be annotated
Base:
Misc:
Components:
I will volunteer and do 1 component at time when I get the time.
Describe the solution you'd like
Plan:
#nullable enable
to component files.Repeat until no components left to annotate and enable enable on project leave and remove the preprocessor directive.
Rule: Don't make multiple components at once since it will be hard to review.
Technical aspects
This doesn't force the user to use nullable, nothing will change for people who doesn't use Nullable in their application, it will work as it is now..
Technically, this is not API change. In fact, the compiler adds additional metedata:
NullableAttribute
andNullableContextAttribute
.Example:
Transform to
This says that the property
Name
can benull
. It's just added some metadata around.But people who have the nullable enabled will notice the difference.
Let's say I'm MudBlazor user and call
Name.ToString()
the Roslyn will warn me saying that you should check for null since the Name can be null and I get theNullReferenceException
.Now the opposite, if there is no
?
on Name means that it's guaranteed by the library to always have a value and I can safely callName.ToString()
without checking for null.If I as a MudBlazor user try to assign
null
toName
Roslyn will also warn me that this is not desired.Have you seen this feature anywhere else?
BlazorStrap, fluentui-blazor(MS) - surprisingly, many UI Blazor frameworks don't support it.
But if we look more widely, then most popular Nuget packages do support it, including the .NET BCL.
Pull Request
Code of Conduct
The text was updated successfully, but these errors were encountered: