Skip to content

Problem with constructors #35

@antonKrizmanic

Description

@antonKrizmanic

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions