Skip to content

[Improvement] More null protection #2775

@asbjornu

Description

@asbjornu

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions