Skip to content

Commit 950dcb0

Browse files
authored
Remove nullable refs sms (Azure#18370)
* 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
1 parent b559773 commit 950dcb0

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

sdk/communication/Azure.Communication.Sms/api/Azure.Communication.Sms.netstandard2.0.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ internal SendSmsResponse() { }
1313
public partial class SmsClient
1414
{
1515
protected SmsClient() { }
16-
public SmsClient(string connectionString, Azure.Communication.Sms.SmsClientOptions? options = null) { }
17-
public SmsClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Sms.SmsClientOptions? options = null) { }
18-
public SmsClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Sms.SmsClientOptions? options = null) { }
19-
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; }
20-
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; }
21-
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; }
22-
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; }
16+
public SmsClient(string connectionString) { }
17+
public SmsClient(string connectionString, Azure.Communication.Sms.SmsClientOptions options) { }
18+
public SmsClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Sms.SmsClientOptions options = null) { }
19+
public SmsClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Sms.SmsClientOptions options = null) { }
20+
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; }
21+
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; }
22+
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; }
23+
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; }
2324
}
2425
public partial class SmsClientOptions : Azure.Core.ClientOptions
2526
{
2627
public const Azure.Communication.Sms.SmsClientOptions.ServiceVersion LatestVersion = Azure.Communication.Sms.SmsClientOptions.ServiceVersion.V1;
27-
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) { }
28+
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) { }
2829
public enum ServiceVersion
2930
{
3031
V1 = 1,

sdk/communication/Azure.Communication.Sms/src/Azure.Communication.Sms.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<PackageTags>Microsoft Azure Communication Sms Service;Microsoft;Azure;Azure Communication Service;Azure Communication Sms Service;Sms;Communication;$(PackageCommonTags)</PackageTags>
1111
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
1212
<EnableApiCompat>false</EnableApiCompat>
13-
<Nullable>enable</Nullable>
1413
</PropertyGroup>
1514

1615
<ItemGroup>

sdk/communication/Azure.Communication.Sms/src/SmsClient.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,25 @@ public class SmsClient
2424
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
2525
/// <param name="keyCredential">The <see cref="AzureKeyCredential"/> used to authenticate requests.</param>
2626
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
27-
public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOptions? options = default)
27+
public SmsClient(Uri endpoint, AzureKeyCredential keyCredential, SmsClientOptions options = default)
2828
: this(
2929
AssertNotNull(endpoint, nameof(endpoint)),
3030
options ?? new SmsClientOptions(),
3131
AssertNotNull(keyCredential, nameof(keyCredential)))
3232
{ }
3333

34+
/// <summary> Initializes a new instance of <see cref="SmsClient"/>.</summary>
35+
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
36+
public SmsClient(string connectionString)
37+
: this(
38+
new SmsClientOptions(),
39+
ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString))))
40+
{ }
41+
3442
/// <summary> Initializes a new instance of <see cref="SmsClient"/>.</summary>
3543
/// <param name="connectionString">Connection string acquired from the Azure Communication Services resource.</param>
3644
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
37-
public SmsClient(string connectionString, SmsClientOptions? options = default)
45+
public SmsClient(string connectionString, SmsClientOptions options)
3846
: this(
3947
options ?? new SmsClientOptions(),
4048
ConnectionString.Parse(AssertNotNullOrEmpty(connectionString, nameof(connectionString))))
@@ -44,7 +52,7 @@ public SmsClient(string connectionString, SmsClientOptions? options = default)
4452
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
4553
/// <param name="tokenCredential">The TokenCredential used to authenticate requests, such as DefaultAzureCredential.</param>
4654
/// <param name="options">Client option exposing <see cref="ClientOptions.Diagnostics"/>, <see cref="ClientOptions.Retry"/>, <see cref="ClientOptions.Transport"/>, etc.</param>
47-
public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions? options = default)
55+
public SmsClient(Uri endpoint, TokenCredential tokenCredential, SmsClientOptions options = default)
4856
: this(
4957
endpoint,
5058
options ?? new SmsClientOptions(),
@@ -104,7 +112,7 @@ private SmsClient(Uri endpoint, SmsClientOptions options, AzureKeyCredential cre
104112
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
105113
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
106114
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
107-
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
115+
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
108116
{
109117
Argument.AssertNotNullOrEmpty(from.PhoneNumber, nameof(from));
110118
Argument.AssertNotNullOrEmpty(to.PhoneNumber, nameof(to));
@@ -123,7 +131,7 @@ public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdenti
123131
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
124132
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
125133
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
126-
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
134+
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, PhoneNumberIdentifier to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
127135
{
128136
Argument.AssertNotNullOrEmpty(from.PhoneNumber, nameof(from));
129137
Argument.AssertNotNullOrEmpty(to.PhoneNumber, nameof(to));
@@ -140,7 +148,7 @@ public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, PhoneN
140148
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
141149
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
142150
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
143-
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
151+
public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
144152
{
145153
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}");
146154
scope.Start();
@@ -166,7 +174,7 @@ public virtual async Task<Response<SendSmsResponse>> SendAsync(PhoneNumberIdenti
166174
/// <exception cref="ArgumentNullException"><paramref name="from"/> is null.</exception>
167175
/// <exception cref="ArgumentNullException"><paramref name="to"/> is null.</exception>
168176
/// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
169-
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions? sendSmsOptions = null, CancellationToken cancellationToken = default)
177+
public virtual Response<SendSmsResponse> Send(PhoneNumberIdentifier from, IEnumerable<PhoneNumberIdentifier> to, string message, SendSmsOptions sendSmsOptions = null, CancellationToken cancellationToken = default)
170178
{
171179
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SmsClient)}.{nameof(Send)}");
172180
scope.Start();

sdk/communication/Azure.Communication.Sms/src/SmsClientOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SmsClientOptions : ClientOptions
2222
/// <summary>
2323
/// Initializes a new instance of the <see cref="SmsClientOptions"/>.
2424
/// </summary>
25-
public SmsClientOptions(ServiceVersion version = LatestVersion, RetryOptions? retryOptions = default, HttpPipelineTransport? transport = default)
25+
public SmsClientOptions(ServiceVersion version = LatestVersion, RetryOptions retryOptions = default, HttpPipelineTransport transport = default)
2626
{
2727
ApiVersion = version switch
2828
{

0 commit comments

Comments
 (0)