Nullable DateTime or DateTimeOffset assigned to default of underlying type


RH1001 Warning

Cause

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

Reason for rule

Helps locating sites where default might erronously be used against a nullable DateTime or DateTimeOffset.

This rule is separate from RH1000 since domains where the default, 1.1.0001 0.00.00, is a meaningful value in terms of the domain context are few.

How to fix violations

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

Examples

Violates

DateTime? value = default(DateTime);

Does not violate

DateTime? value = default(DateTime?);