Skip to content

Feature Request: Add Null Helper Attributes to IsNullOrEmpty or similar methods. #25

@GeekInTheNorth

Description

@GeekInTheNorth

Feature Request:
Add Null Helper Attributes to IsNullOrEmpty or similar methods.

With CMS 12 and .NET 6 we are able to build projects that are defined as using nullable reference types. This is also the default for any new .NET 6.0 project. With this in mind, we can decorate input and output parameters on methods that allow the code analysis engine to understand if something is potentially null and encouraging null checking/handling within custom code.

e.g.

public static bool IsNullOrEmpty(this ContentReference contentReference)
{
    return ContentReference.IsNullOrEmpty(contentReference);
}

Could be declared as

public static bool IsNullOrEmpty([NotNullWhen(false)] this ContentReference? contentReference)
{
	return ContentReference.IsNullOrEmpty(contentReference);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions