infobip / infobip-api-csharp-client

Infobip API client library in C#, distributed as a NuGet package.
https://www.infobip.com/docs/api
MIT License
13 stars 19 forks source link

Problem with constructors #35

Open antonKrizmanic opened 3 months ago

antonKrizmanic commented 3 months ago

Hi, I have problem with the way how you implemented some of your constructors. Classes that I found for now with that implementation are SmsTextualMessage and SmsAdvancedTextualRequest.

Both have all parameters as optional, but in implementation of constructor there is check if some parameters are null. For example:

var smsRequest = new SmsAdvancedTextualRequest()
{
    Messages = [smsMessages]
};

will built without any error, but during execution exception will be thrown because of:

public SmsAdvancedTextualRequest(string bulkId = null, List<SmsTextualMessage> messages = null, SmsSendingSpeedLimit sendingSpeedLimit = null, SmsUrlOptions urlOptions = null, SmsTracking tracking = null, bool includeSmsCountInResponse = false)
{
    Messages = messages ?? throw new ArgumentNullException("messages");
    BulkId = bulkId;
    SendingSpeedLimit = sendingSpeedLimit;
    UrlOptions = urlOptions;
    Tracking = tracking;
    IncludeSmsCountInResponse = includeSmsCountInResponse;
}

I would expect build time error for this case

davorivankovic commented 3 months ago

Hi @antonKrizmanic,

Thank you for reporting this. We'll take a look and get back to you with more information.

Regards,