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

[Improvement] More null protection #2775

Closed
asbjornu opened this issue Jul 22, 2021 · 2 comments · Fixed by #3064
Closed

[Improvement] More null protection #2775

asbjornu opened this issue Jul 22, 2021 · 2 comments · Fixed by #3064
Milestone

Comments

@asbjornu
Copy link
Member

asbjornu commented Jul 22, 2021

With #2765 merged we have a good basis to tighten the codebase by adding more null guards and allowing for less nullability throughout.

Detailed Description

One of the worst exceptions to debug is NullReferenceException. With ArgumentNullException you at least know which argument was null, which is a huge improvement. Better yet is to alleviate null altogether, or at least move all code dealing with null to the perimeter of the codebase. GitVersion.Core should preferably be completely free of nullable types.

Context

We are plagued with NullReferenceException surfacing its ugly head every so often. See #2763, #2605, #2695, #2734, #2825 and #2631 (comment) for examples. We allow null by having default, argument-free constructors in classes with fields that then become uninitialized, for instance. We also are missing null guards in a lot of constructors that take arguments that should not be allowed to be null.

Possible Implementation

Remove default constructors in classes with fields that need initialization. Add null guards throughout the codebase.

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 2, 2022
@asbjornu asbjornu removed the stale label Mar 2, 2022
@asbjornu asbjornu mentioned this issue Apr 1, 2022
5 tasks
@asbjornu asbjornu added this to the 5.x milestone Apr 2, 2022
@arturcic arturcic modified the milestones: 5.x, 5.10.0 Apr 14, 2022
@github-actions
Copy link

🎉 This issue has been resolved in version 5.10.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants