Skip to content

Commit

Permalink
Remove nullable refs sms (Azure#18370)
Browse files Browse the repository at this point in the history
* Remove nullable ref-types from sms sdk

* Code review changes - add a basic constructor (with connection string only) for sms client

* code review changes

* fix for build check failures
  • Loading branch information
nmaredia authored and jongio committed Feb 9, 2021
1 parent fc681c8 commit 9dc6efc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Azure.Communication.Sms.SendSmsResponse> 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<Azure.Communication.Sms.SendSmsResponse> Send(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable<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<Azure.Response<Azure.Communication.Sms.SendSmsResponse>> 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<Azure.Response<Azure.Communication.Sms.SendSmsResponse>> SendAsync(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable<Azure.Communication.PhoneNumberIdentifier> 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<Azure.Communication.Sms.SendSmsResponse> 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<Azure.Communication.Sms.SendSmsResponse> Send(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable<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<Azure.Response<Azure.Communication.Sms.SendSmsResponse>> 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<Azure.Response<Azure.Communication.Sms.SendSmsResponse>> SendAsync(Azure.Communication.PhoneNumberIdentifier from, System.Collections.Generic.IEnumerable<Azure.Communication.PhoneNumberIdentifier> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageTags>Microsoft Azure Communication Sms Service;Microsoft;Azure;Azure Communication Service;Azure Communication Sms Service;Sms;Communication;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
22 changes: 15 additions & 7 deletions sdk/communication/Azure.Communication.Sms/src/SmsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,25 @@ public class SmsClient
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
/// <param name="keyCredential">The <see cref="AzureKeyCredential"/> used to authenticate requests.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
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(),
AssertNotNull(keyCredential, nameof(keyCredential)))
{ }

/// <summary> Initializes a new instance of <see cref="SmsClient"/>.</summary>
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
public SmsClient(string connectionString)
: this(
new SmsClientOptions(),
ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString))))
{ }

/// <summary> Initializes a new instance of <see cref="SmsClient"/>.</summary>
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
public SmsClient(string connectionString, SmsClientOptions? options = default)
public SmsClient(string connectionString, SmsClientOptions options)
: this(
options ?? new SmsClientOptions(),
ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString))))
Expand All @@ -44,7 +52,7 @@ public SmsClient(string connectionString, SmsClientOptions? options = default)
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
/// <param name="tokenCredential">The TokenCredential used to authenticate requests, such as DefaultAzureCredential.</param>
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions? options = default)
public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions options = default)
: this(
endpoint,
options ?? new SmsClientOptions(),
Expand Down Expand Up @@ -104,7 +112,7 @@ private SmsClient(Uri endpoint, SmsClientOptions options, AzureKeyCredential cre
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<SendSmsResponse>> 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));
Expand All @@ -123,7 +131,7 @@ public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdenti
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
public virtual Response<SendSmsResponse> 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));
Expand All @@ -140,7 +148,7 @@ public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, PhoneN
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}");
scope.Start();
Expand All @@ -166,7 +174,7 @@ public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdenti
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}");
scope.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SmsClientOptions : ClientOptions
/// <summary>
/// Initializes a new instance of the <see cref="SmsClientOptions"/>.
/// </summary>
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
{
Expand Down

0 comments on commit 9dc6efc

Please sign in to comment.