From 7e2312ab1cf48075e9955581735a765cd2387d89 Mon Sep 17 00:00:00 2001 From: Nikkishah Maredia Date: Mon, 1 Feb 2021 14:34:20 -0800 Subject: [PATCH 1/4] Remove nullable ref-types from sms sdk --- .../src/Azure.Communication.Sms.csproj | 1 - .../Azure.Communication.Sms/src/SmsClient.cs | 14 +++++++------- .../src/SmsClientOptions.cs | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/sdk/communication/Azure.Communication.Sms/src/Azure.Communication.Sms.csproj b/sdk/communication/Azure.Communication.Sms/src/Azure.Communication.Sms.csproj index f9b41d42dd4b..224977caf0bf 100644 --- a/sdk/communication/Azure.Communication.Sms/src/Azure.Communication.Sms.csproj +++ b/sdk/communication/Azure.Communication.Sms/src/Azure.Communication.Sms.csproj @@ -10,7 +10,6 @@ Microsoft Azure Communication Sms Service;Microsoft;Azure;Azure Communication Service;Azure Communication Sms Service;Sms;Communication;$(PackageCommonTags) $(RequiredTargetFrameworks) false - enable diff --git a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs index 8180952ed5b1..87e8a2145da2 100644 --- a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs @@ -24,7 +24,7 @@ public class SmsClient /// The URI of the Azure Communication Services resource. /// The used to authenticate requests. /// Client option exposing , , , etc. - public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOptions? options = default) + public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOptions options = default) : this( AssertNotNull(endpoint, nameof(endpoint)), options ?? new SmsClientOptions(), @@ -34,7 +34,7 @@ public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOption /// Initializes a new instance of . /// Connection string acquired from the Azure Communication Services resource. /// Client option exposing , , , etc. - public SmsClient(string connectionString, SmsClientOptions? options = default) + public SmsClient(string connectionString, SmsClientOptions options = default) : this( options ?? new SmsClientOptions(), ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString)))) @@ -44,7 +44,7 @@ public SmsClient(string connectionString, SmsClientOptions? options = default) /// The URI of the Azure Communication Services resource. /// The TokenCredential used to authenticate requests, such as DefaultAzureCredential. /// Client option exposing , , , etc. - public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions? options = default) + public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions options = default) : this( endpoint, options ?? new SmsClientOptions(), @@ -104,7 +104,7 @@ private SmsClient(Uri endpoint, SmsClientOptions options, AzureKeyCredential cre /// is null. /// is null. /// is null. - public virtual async Task> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default) + public virtual async Task> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(from.PhoneNumber, nameof(from)); Argument.AssertNotNullOrEmpty(to.PhoneNumber, nameof(to)); @@ -123,7 +123,7 @@ public virtual async Task> SendAsync(PhoneNumberIdenti /// is null. /// is null. /// is null. - public virtual Response Send(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default) + public virtual Response Send(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(from.PhoneNumber, nameof(from)); Argument.AssertNotNullOrEmpty(to.PhoneNumber, nameof(to)); @@ -140,7 +140,7 @@ public virtual Response Send(PhoneNumberIdentifier from, PhoneN /// is null. /// is null. /// is null. - public virtual async Task> SendAsync(PhoneNumberIdentifier from, IEnumerable to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default) + public virtual async Task> SendAsync(PhoneNumberIdentifier from, IEnumerable to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}"); scope.Start(); @@ -166,7 +166,7 @@ public virtual async Task> SendAsync(PhoneNumberIdenti /// is null. /// is null. /// is null. - public virtual Response Send(PhoneNumberIdentifier from, IEnumerable to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default) + public virtual Response Send(PhoneNumberIdentifier from, IEnumerable to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}"); scope.Start(); diff --git a/sdk/communication/Azure.Communication.Sms/src/SmsClientOptions.cs b/sdk/communication/Azure.Communication.Sms/src/SmsClientOptions.cs index e81fa03e89db..9782a3f1b221 100644 --- a/sdk/communication/Azure.Communication.Sms/src/SmsClientOptions.cs +++ b/sdk/communication/Azure.Communication.Sms/src/SmsClientOptions.cs @@ -22,7 +22,7 @@ public class SmsClientOptions : ClientOptions /// /// Initializes a new instance of the . /// - public SmsClientOptions(ServiceVersion version = LatestVersion, RetryOptions? retryOptions = default, HttpPipelineTransport? transport = default) + public SmsClientOptions(ServiceVersion version = LatestVersion, RetryOptions retryOptions = default, HttpPipelineTransport transport = default) { ApiVersion = version switch { From 88131ef65ed9d24591cfa2bed9e564b612bb25d0 Mon Sep 17 00:00:00 2001 From: Nikkishah Maredia Date: Mon, 1 Feb 2021 15:54:12 -0800 Subject: [PATCH 2/4] Code review changes - add a basic constructor (with connection string only) for sms client --- .../Azure.Communication.Sms/src/SmsClient.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs index 87e8a2145da2..baee46383d28 100644 --- a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs @@ -31,6 +31,14 @@ public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOption AssertNotNull(keyCredential, nameof(keyCredential))) { } + /// Initializes a new instance of . + /// Connection string acquired from the Azure Communication Services resource. + public SmsClient(string connectionString) + : this( + new SmsClientOptions(), + ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString)))) + { } + /// Initializes a new instance of . /// Connection string acquired from the Azure Communication Services resource. /// Client option exposing , , , etc. From c98217b4fb907222a857bb432286633310cbb86b Mon Sep 17 00:00:00 2001 From: Nikkishah Maredia Date: Mon, 1 Feb 2021 16:08:59 -0800 Subject: [PATCH 3/4] code review changes --- sdk/communication/Azure.Communication.Sms/src/SmsClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs index baee46383d28..27d29ada3237 100644 --- a/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs +++ b/sdk/communication/Azure.Communication.Sms/src/SmsClient.cs @@ -42,7 +42,7 @@ public SmsClient(string connectionString) /// Initializes a new instance of . /// Connection string acquired from the Azure Communication Services resource. /// Client option exposing , , , etc. - public SmsClient(string connectionString, SmsClientOptions options = default) + public SmsClient(string connectionString, SmsClientOptions options) : this( options ?? new SmsClientOptions(), ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString)))) From e8cd695264cc47d09a62e7d7e0a57af0fa06c754 Mon Sep 17 00:00:00 2001 From: Nikkishah Maredia Date: Tue, 2 Feb 2021 11:01:56 -0800 Subject: [PATCH 4/4] fix for build check failures --- .../Azure.Communication.Sms.netstandard2.0.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sdk/communication/Azure.Communication.Sms/api/Azure.Communication.Sms.netstandard2.0.cs b/sdk/communication/Azure.Communication.Sms/api/Azure.Communication.Sms.netstandard2.0.cs index caa9ec7378ed..2e92fbc69eb1 100644 --- a/sdk/communication/Azure.Communication.Sms/api/Azure.Communication.Sms.netstandard2.0.cs +++ b/sdk/communication/Azure.Communication.Sms/api/Azure.Communication.Sms.netstandard2.0.cs @@ -13,18 +13,19 @@ internal SendSmsResponse() { } public partial class SmsClient { protected SmsClient() { } - public SmsClient(string connectionString, Azure.Communication.Sms.SmsClientOptions? options = null) { } - public SmsClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Sms.SmsClientOptions? options = null) { } - public SmsClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Sms.SmsClientOptions? options = null) { } - public virtual Azure.Response Send(Azure.Communication.PhoneNumberIdentifier from, Azure.Communication.PhoneNumberIdentifier to, string message, Azure.Communication.Sms.SendSmsOptions? sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.Response Send(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable to, string message, Azure.Communication.Sms.SendSmsOptions? sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> SendAsync(Azure.Communication.PhoneNumberIdentifier from, Azure.Communication.PhoneNumberIdentifier to, string message, Azure.Communication.Sms.SendSmsOptions? sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> SendAsync(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable to, string message, Azure.Communication.Sms.SendSmsOptions? sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public SmsClient(string connectionString) { } + public SmsClient(string connectionString, Azure.Communication.Sms.SmsClientOptions options) { } + public SmsClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Sms.SmsClientOptions options = null) { } + public SmsClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Sms.SmsClientOptions options = null) { } + public virtual Azure.Response Send(Azure.Communication.PhoneNumberIdentifier from, Azure.Communication.PhoneNumberIdentifier to, string message, Azure.Communication.Sms.SendSmsOptions sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response Send(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable to, string message, Azure.Communication.Sms.SendSmsOptions sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SendAsync(Azure.Communication.PhoneNumberIdentifier from, Azure.Communication.PhoneNumberIdentifier to, string message, Azure.Communication.Sms.SendSmsOptions sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> SendAsync(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable to, string message, Azure.Communication.Sms.SendSmsOptions sendSmsOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class SmsClientOptions : Azure.Core.ClientOptions { public const Azure.Communication.Sms.SmsClientOptions.ServiceVersion LatestVersion = Azure.Communication.Sms.SmsClientOptions.ServiceVersion.V1; - public SmsClientOptions(Azure.Communication.Sms.SmsClientOptions.ServiceVersion version = Azure.Communication.Sms.SmsClientOptions.ServiceVersion.V1, Azure.Core.RetryOptions? retryOptions = null, Azure.Core.Pipeline.HttpPipelineTransport? transport = null) { } + public SmsClientOptions(Azure.Communication.Sms.SmsClientOptions.ServiceVersion version = Azure.Communication.Sms.SmsClientOptions.ServiceVersion.V1, Azure.Core.RetryOptions retryOptions = null, Azure.Core.Pipeline.HttpPipelineTransport transport = null) { } public enum ServiceVersion { V1 = 1,