dotvariant icon indicating copy to clipboard operation
dotvariant copied to clipboard

Skip emptiness handling if type cannot be empty

Open mknejp opened this issue 3 years ago • 0 comments

If a variant class has no default constructor and all other constructors initialize the _variant field to a non-default value then the variant cannot be empty. Under these circumstances the "empty" case is impossible to achieve and can be removed from the interface as these code paths will never execute.

Possible conflict: if constructors are later changed and the empty state becomes possible the previously safe methods could now throw InvalidOperationException. Maybe keeping the empty state is the safer option as it reminds the user of this eventuality. This needs investigating.

mknejp avatar Nov 13 '21 01:11 mknejp