Skip to content

Why can Collections be nullable, but exceptions is thrown on null? #1388

Closed Answered by sveinhelge
sveinhelge asked this question in Q&A
Discussion options

You must be logged in to vote

If I added ThrowOnMappingNullMismatch = false to the attribute it works as expected

See docs

[Mapper(PropertyNameMappingStrategy = PropertyNameMappingStrategy.CaseInsensitive, ThrowOnMappingNullMismatch  = false)]

Then we will get this is the generated code

if (model == null)
   return new global::System.Collections.Generic.List<global::...Target>();

instead of

if (model == null)
   throw new System.ArgumentNullException(nameof(model));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sveinhelge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant