Nullable type assigned to default of underlying type


RH1000 Warning

Cause

A nullable type is assigned to default value of the underlying type.

Note: does not target DateTime? or DateTimeOffset?, since a separate rule covering them exists.

Reason for rule

Helps locating sites where default might erronously be used against a nullable value type. Any such sites require review in context of the domain.

How to fix violations

If applicable, assign type to default(T?) or null.

Examples

Violates

bool? value = default(bool);

Does not violate

bool? value = default(bool?);