Skip to content

Commit

Permalink
[Communciation] - Remove nullable reftypes from the public surface of…
Browse files Browse the repository at this point in the history
… the Identity and Common package (#18334)
  • Loading branch information
RezaJooyandeh authored Feb 1, 2021
1 parent 3f05212 commit 378ab06
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Dispose() { }
}
public partial class CommunicationTokenRefreshOptions
{
public CommunicationTokenRefreshOptions(bool refreshProactively, System.Func<System.Threading.CancellationToken, string> tokenRefresher, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<string>>? asyncTokenRefresher = null, string? initialToken = null) { }
public CommunicationTokenRefreshOptions(bool refreshProactively, System.Func<System.Threading.CancellationToken, string> tokenRefresher, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<string>> asyncTokenRefresher = null, string initialToken = null) { }
}
public partial class CommunicationUserIdentifier : Azure.Communication.CommunicationIdentifier
{
Expand All @@ -56,9 +56,9 @@ public CommunicationUserIdentifier(string id) { }
}
public partial class MicrosoftTeamsUserIdentifier : Azure.Communication.CommunicationIdentifier
{
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string? id = null, Azure.Communication.CommunicationCloudEnvironment? cloud = default(Azure.Communication.CommunicationCloudEnvironment?)) { }
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string id = null, Azure.Communication.CommunicationCloudEnvironment? cloud = default(Azure.Communication.CommunicationCloudEnvironment?)) { }
public Azure.Communication.CommunicationCloudEnvironment Cloud { get { throw null; } }
public string? Id { get { throw null; } }
public string Id { get { throw null; } }
public bool IsAnonymous { get { throw null; } }
public string UserId { get { throw null; } }
public override bool Equals(Azure.Communication.CommunicationIdentifier other) { throw null; }
Expand All @@ -67,8 +67,8 @@ public partial class MicrosoftTeamsUserIdentifier : Azure.Communication.Communic
}
public partial class PhoneNumberIdentifier : Azure.Communication.CommunicationIdentifier
{
public PhoneNumberIdentifier(string phoneNumber, string? id = null) { }
public string? Id { get { throw null; } }
public PhoneNumberIdentifier(string phoneNumber, string id = null) { }
public string Id { get { throw null; } }
public string PhoneNumber { get { throw null; } }
public override bool Equals(Azure.Communication.CommunicationIdentifier other) { throw null; }
public override int GetHashCode() { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Threading.Tasks;
using Azure.Core;

#nullable enable

namespace Azure.Communication
{
internal sealed class AutoRefreshTokenCredential : ICommunicationTokenCredential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<RootNamespace>Azure.Communication</RootNamespace>
<EnableApiCompat>false</EnableApiCompat>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public class CommunicationTokenRefreshOptions
internal bool RefreshProactively { get; }
internal Func<CancellationToken, string> TokenRefresher { get; }
internal Func<CancellationToken, ValueTask<string>> AsyncTokenRefresher { get; }

#nullable enable
internal string? InitialToken { get; }
#nullable restore

/// <summary>
/// Initializes a new instance of <see cref="CommunicationTokenRefreshOptions"/>.
Expand All @@ -28,8 +31,8 @@ public class CommunicationTokenRefreshOptions
public CommunicationTokenRefreshOptions(
bool refreshProactively,
Func<CancellationToken, string> tokenRefresher,
Func<CancellationToken, ValueTask<string>>? asyncTokenRefresher = null,
string? initialToken = null)
Func<CancellationToken, ValueTask<string>> asyncTokenRefresher = null,
string initialToken = null)
{
Argument.AssertNotNull(tokenRefresher, nameof(tokenRefresher));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Azure.Communication
public class MicrosoftTeamsUserIdentifier : CommunicationIdentifier
{
/// <summary>The full id of the Microsoft Teams User identifier.</summary>
public string? Id { get; }
public string Id { get; }

/// <summary>The id of the Microsoft Teams user. If the user isn't anonymous, the id is the AAD object id of the user.</summary>
public string UserId { get; }
Expand All @@ -33,7 +33,7 @@ public class MicrosoftTeamsUserIdentifier : CommunicationIdentifier
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="userId"/> is empty.
/// </exception>
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string? id = null, CommunicationCloudEnvironment? cloud = null)
public MicrosoftTeamsUserIdentifier(string userId, bool isAnonymous = false, string id = null, CommunicationCloudEnvironment? cloud = null)
{
Argument.AssertNotNullOrEmpty(userId, nameof(userId));
UserId = userId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Diagnostics;
using Azure.Core;

namespace Azure.Communication
Expand All @@ -10,7 +9,7 @@ namespace Azure.Communication
public class PhoneNumberIdentifier : CommunicationIdentifier
{
/// <summary>The full id of the phone number.</summary>
public string? Id { get; }
public string Id { get; }

/// <summary>The phone number in E.164 format.</summary>
public string PhoneNumber { get; }
Expand All @@ -24,7 +23,7 @@ public class PhoneNumberIdentifier : CommunicationIdentifier
/// <exception cref="System.ArgumentException">
/// Thrown when the <paramref name="phoneNumber"/> is empty.
/// </exception>
public PhoneNumberIdentifier(string phoneNumber, string? id = null)
public PhoneNumberIdentifier(string phoneNumber, string id = null)
{
Argument.AssertNotNullOrEmpty(phoneNumber, nameof(phoneNumber));
PhoneNumber = phoneNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Azure.Core;
using Azure.Core.Pipeline;

#nullable enable

namespace Azure.Communication
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ namespace Azure.Communication.Identity
public partial class CommunicationIdentityClient
{
protected CommunicationIdentityClient() { }
public CommunicationIdentityClient(string connectionString, Azure.Communication.Identity.CommunicationIdentityClientOptions? options = null) { }
public CommunicationIdentityClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Identity.CommunicationIdentityClientOptions? options = null) { }
public CommunicationIdentityClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Identity.CommunicationIdentityClientOptions? options = null) { }
public CommunicationIdentityClient(string connectionString) { }
public CommunicationIdentityClient(string connectionString, Azure.Communication.Identity.CommunicationIdentityClientOptions options) { }
public CommunicationIdentityClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.Identity.CommunicationIdentityClientOptions options = null) { }
public CommunicationIdentityClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.Identity.CommunicationIdentityClientOptions options = null) { }
public virtual Azure.Response<Azure.Communication.CommunicationUserIdentifier> CreateUser(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CommunicationUserIdentifier>> CreateUserAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<(Azure.Communication.CommunicationUserIdentifier user, Azure.Core.AccessToken token)> CreateUserWithToken(System.Collections.Generic.IEnumerable<Azure.Communication.Identity.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<PackageTags>Microsoft Azure Communication Identity Service;Microsoft;Azure;Azure Communication Service;Azure Communication Identity Service;Identity;Communication;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
<EnableApiCompat>false</EnableApiCompat>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,25 @@ public class CommunicationIdentityClient
/// <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 CommunicationIdentityClient(Uri endpoint, AzureKeyCredential keyCredential, CommunicationIdentityClientOptions? options = default)
public CommunicationIdentityClient(Uri endpoint, AzureKeyCredential keyCredential, CommunicationIdentityClientOptions options = default)
: this(
AssertNotNull(endpoint, nameof(endpoint)),
options ?? new CommunicationIdentityClientOptions(),
AssertNotNull(keyCredential, nameof(keyCredential)))
{ }

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

/// <summary> Initializes a new instance of <see cref="CommunicationIdentityClient"/>.</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 CommunicationIdentityClient(string connectionString, CommunicationIdentityClientOptions? options = default)
public CommunicationIdentityClient(string connectionString, CommunicationIdentityClientOptions options)
: this(
options ?? new CommunicationIdentityClientOptions(),
ConnectionString.Parse(AssertNotNull(connectionString, nameof(connectionString))))
Expand All @@ -44,7 +52,7 @@ public CommunicationIdentityClient(string connectionString, CommunicationIdentit
/// <param name="endpoint">The URI of the Azure Communication Services resource.</param>
/// <param name="tokenCredential">The <see cref="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 CommunicationIdentityClient(Uri endpoint, TokenCredential tokenCredential, CommunicationIdentityClientOptions? options = default)
public CommunicationIdentityClient(Uri endpoint, TokenCredential tokenCredential, CommunicationIdentityClientOptions options = default)
: this(
AssertNotNull(endpoint, nameof(endpoint)),
options ?? new CommunicationIdentityClientOptions(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
For this release, see notes - https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/communication/Azure.ResourceManager.Communication/README.md and https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/communication/Azure.ResourceManager.Communication/CHANGELOG.md.
</Description>
<PackageTags>azure;management;communication</PackageTags>
<Nullable>enable</Nullable>
<!--
AZC0001 - Azure.ResourceManager.Communication namespace needs to be registered in the analyzer
-->
Expand Down

0 comments on commit 378ab06

Please sign in to comment.