MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.32k stars 329 forks source link

Provide more details on null reference questions #609

Open mhkolk opened 1 year ago

mhkolk commented 1 year ago

When mapping nested objects Mapster sometimes fails with

System.NullReferenceException: 'Object reference not set to an instance of an object.'

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

It does not provide details what property it actually failed on. Most of times it's impossible to evaluate manually where the point of failure is.

Could Mapster provide that information by catching the exception or some other means?

uzielmercado11 commented 9 months ago

I have this same situation, how did you manage to solve your problem?

martinib77 commented 2 months ago

I have also this situation and don't understand why is failing, it should only set null value for the destination property.