DeagleGross / SharpCoachPlugin

Rider C# plugin for easy code generation of mapping classes
MIT License
4 stars 2 forks source link

Add conditional LINQ methods call when mapping collections #9

Closed TonySkorik closed 1 year ago

TonySkorik commented 2 years ago

When mapping the collections of object this plugin generates the Select LINQ clause.

OrderLines = tmpOrders.OrderLines.Select(...)

If the LINQ target is null - System.ArgumentNullException gets thrown at the run time.

It might be a good idea to call all the generated LINQ methods conditionally (either through conditional access operator or via more verbose ternary operator) or add a corresponding setting - whether the extension should generate collection mappings using conditional access.

DeagleGross commented 2 years ago

Thanks for an issue!

I'll implement it in a https://github.com/DeagleGross/SharpCoachPlugin/issues/6 (supporting not only classes, but collections also), but the good thing you've suggested is providing a special setting using plugin-settings-page.