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

Enables Nullability for PythonVersionInfo #213

Merged
merged 1 commit into from
Jan 13, 2021
Merged

Conversation

dan-hein
Copy link
Contributor

Summary

This change annotates the PythonVersionInfo class to enable nullable references. This clears the warning and indicates intent to work with nullable references.

Details

C# 8.0 added the nullable annotation to allow for fine-grain control on the nullability of references. This annotation also allows for the change to the SafeToLower and SafeExtract methods, that can potentially return null, to return Nullable strings which further enables null-safe checking.

More information is available Microsoft's Nullable documentation.

Solution

Enabling this annotation and adding the nullable ? to the string return types of SafeToLower and SafeExtract eliminated that warnings in the build and should help future development use these methods with care.
If there is anything else that I did not take into account, please let me know! I'd be more than happy to make those changes.

Resolves #199

Annotates the PythonVersionInfo class to enable nullable references. This clears the warning and indicates intent to work with nullable references. C# 8.0 added this annotation to allow for fine-grain control on the nullability of references. This annotation also allows for the change to the SafeToLower and SafeExtract methods, that can potentially return null, to return Nullable strings which further enables null-safe checking.

See Microsoft's documentation https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references#nullable-annotation-context

Resolves #199
@github-actions
Copy link
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@dan-hein dan-hein requested a review from nickiemc January 12, 2021 20:31
@codeclimate
Copy link

codeclimate bot commented Jan 12, 2021

Code Climate has analyzed commit 70bb764 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Contributor

@nickiemc nickiemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed background! This looks good! 💯

@nickiemc nickiemc merged commit 0576700 into main Jan 13, 2021
@nickiemc nickiemc deleted the fix-nullable-warnings branch January 13, 2021 15:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix nullable reference types warning
2 participants