Open robrich opened 3 years ago
I already put #nullable enable
at the top of my generated code. Even with that, it's possible that someone could pass in a null
value, and my take is that you should still check for null
and throw ArgumentNullException
.
One thing I would consider is some kind of configuration setting that says, "If you're given a null
value, return null
instead of throwing ArgumentNullException
". This could be done as a setting in the attribute (that could be done as work with this issue), and/or a configuration setting.
Ah, I see I mis-read the generation code. Then throwing the YouAreADorkException
here is completely the right move.
It still would be nice to allow cloning a nullable object though. Thinking further, would this work?:
Destination? destionation = source?.MapToDestination();
If you put
#nullable enable
at the top of each file then you won't need to do this:but instead can do this: