softwerkab / fortnox-csharp-api-sdk

.NET SDK for Fortnox API.
MIT License
52 stars 64 forks source link

Initialize the collection #155

Closed vanillajonathan closed 3 years ago

vanillajonathan commented 3 years ago

https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/guidelines-for-collections

DO NOT return null values from collection properties or from methods returning collections. Return an empty collection or an empty array instead.

DO NOT use ArrayList or List<T> in public APIs.

richardrandak commented 3 years ago

Hello! Thanks for the pull request. However, if we do this change, we should change it for all connectors, not just voucher, to keep keep it consistent.

vanillajonathan commented 3 years ago

Yes, I think all collections should be initialized to empty collections, this makes it easier to use and you can iterate over them without worrying about null values.

richardrandak commented 3 years ago

I see one issue with initialized collections. Current SDK behaviour is that only populated properties are serialized when UPDATE request is called. If the collection is auto-initialized, that would mean, the collection property would be populated (with empty collection) and therefore, would be updated to empty one without user's knowledge