Framework icon indicating copy to clipboard operation
Framework copied to clipboard

Boxed.Mapping: Allow source to be null (and set destination to null if so)

Open Kazpers opened this issue 1 year ago • 0 comments

Describe the feature

Currently the Boxed.Mapping.MapperExtensions.Map method specifically checks whether source == null and throws an ArgumentNullException if so. It would be nice if it instead followed .NET nullable rules, and allowed a null source if the mapper defined a nullable type as source. In that case the destination would obviously also simply be null.

Instead, you currently have to do a workaround like: "var result = source == null ? null : _mapper.Map(source)" on every line calling a mapper where the source is a nullable type.

Kazpers avatar May 15 '24 11:05 Kazpers