Closed KinNeko-De closed 4 years ago
Hi,
Current behavior was introduced intentionally. NullReferenceException
should bring your attention to the discrepancy between the models . If you need a different behavior you should manually adjust generated code - that's the beauty of MappingGenerator.
Ok. I will get the atttention if i have a good unit test that does boundary tests :)
But i agree that a MappingGenerator is the best concept because you can easily change the code if the result is not what you expected.
@KinNeko-De If you are using R#, you can configure static analysis to report all these situations as an error so you don't need to write tests for these kind scenarios. Not sure if there is an existing Roslyn analyzer that can act as counterpart for this R# rule.
Hello. i tried your extension (Version 1.12.306) at some code. Its great but i think i have found a small issue.
I have a domain object with a nullable bool property and it should be mapped to not nullable bool dto. This is bad design.. i know that :)
The MappingGenerator generates:
This code will fail when the nullableproperty is null. I suggest to use
nullableproperty.GetValueOrDefault()
instead