diff --git a/sdk/dotnet/src/Microsoft.Datasync.Client/DatasyncClient.cs b/sdk/dotnet/src/Microsoft.Datasync.Client/DatasyncClient.cs index 65b621df..4151a856 100644 --- a/sdk/dotnet/src/Microsoft.Datasync.Client/DatasyncClient.cs +++ b/sdk/dotnet/src/Microsoft.Datasync.Client/DatasyncClient.cs @@ -123,7 +123,7 @@ public DatasyncClient(Uri endpoint, AuthenticationProvider authenticationProvide Endpoint = endpoint.NormalizeEndpoint(); ClientOptions = clientOptions ?? new DatasyncClientOptions(); - HttpClient = new ServiceHttpClient(Endpoint, authenticationProvider, ClientOptions); + ServiceHttpClient = new ServiceHttpClient(Endpoint, authenticationProvider, ClientOptions); if (ClientOptions.SerializerSettings != null) { Serializer.SerializerSettings = ClientOptions.SerializerSettings; @@ -147,13 +147,18 @@ public DatasyncClient(Uri endpoint, AuthenticationProvider authenticationProvide /// /// Gets the associated with the Azure Mobile App. /// - internal ServiceHttpClient HttpClient { get; } + internal ServiceHttpClient ServiceHttpClient { get; } + + /// + /// The underlying that is used to communicate with the service. + /// + public HttpClient HttpClient { get => ServiceHttpClient.HttpClient; } /// /// The id used to identify this installation of the application to /// provide telemetry data. /// - public string InstallationId { get => HttpClient.InstallationId; } + public string InstallationId { get => ServiceHttpClient.InstallationId; } /// /// The number of pending operations, or null if the offline store has not been defined. @@ -311,7 +316,7 @@ public virtual async Task PushTablesAsync(IEnumerable tables, PushOption /// A to observe. /// A task that returns the for the response when complete. public Task SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken = default) - => HttpClient.HttpClient.SendAsync(request, completionOption, cancellationToken); + => ServiceHttpClient.HttpClient.SendAsync(request, completionOption, cancellationToken); /// /// Sends a HTTP request to the remote service, using the in-built HTTP client. @@ -320,7 +325,7 @@ public Task SendAsync(HttpRequestMessage request, HttpCompl /// A to observe. /// A task that returns the for the response when complete. public Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) - => HttpClient.HttpClient.SendAsync(request, cancellationToken); + => ServiceHttpClient.HttpClient.SendAsync(request, cancellationToken); #endregion /// @@ -357,7 +362,7 @@ protected virtual void Dispose(bool disposing) if (disposing) { SyncContext.Dispose(); - HttpClient.Dispose(); + ServiceHttpClient.Dispose(); } } #endregion diff --git a/sdk/dotnet/src/Microsoft.Datasync.Client/Table/RemoteTable.cs b/sdk/dotnet/src/Microsoft.Datasync.Client/Table/RemoteTable.cs index 3461c344..0250451a 100644 --- a/sdk/dotnet/src/Microsoft.Datasync.Client/Table/RemoteTable.cs +++ b/sdk/dotnet/src/Microsoft.Datasync.Client/Table/RemoteTable.cs @@ -287,7 +287,7 @@ protected async Task SendRequestAsync(ServiceRequest request, Cancellati { try { - var response = await ServiceClient.HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); + var response = await ServiceClient.ServiceHttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false); return GetJTokenFromResponse(response); } catch (DatasyncInvalidOperationException ex) when (ex.IsConflictStatusCode()) diff --git a/sdk/dotnet/test/Microsoft.Datasync.Client.Test/DatasyncClient.Test.cs b/sdk/dotnet/test/Microsoft.Datasync.Client.Test/DatasyncClient.Test.cs index 271cf589..28a5d7b1 100644 --- a/sdk/dotnet/test/Microsoft.Datasync.Client.Test/DatasyncClient.Test.cs +++ b/sdk/dotnet/test/Microsoft.Datasync.Client.Test/DatasyncClient.Test.cs @@ -83,7 +83,7 @@ public void CtorString_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(testcase.BaseEndpoint); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Theory, ClassData(typeof(EndpointTestCases))] @@ -94,7 +94,7 @@ public void CtorStringAuth_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(testcase.BaseEndpoint, authProvider); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Fact] @@ -120,7 +120,7 @@ public void CtorUri_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(new Uri(testcase.BaseEndpoint)); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Theory, ClassData(typeof(EndpointTestCases))] @@ -131,7 +131,7 @@ public void CtorUriAuth_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(new Uri(testcase.BaseEndpoint), authProvider); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.NotNull(client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Fact] @@ -160,7 +160,7 @@ public void CtorStringOptions_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(testcase.BaseEndpoint, options); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.Same(options, client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Theory, ClassData(typeof(EndpointTestCases))] @@ -172,7 +172,7 @@ public void CtorStringAuthOptions_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(testcase.BaseEndpoint, authProvider, options); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.Same(options, client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Fact] @@ -199,7 +199,7 @@ public void CtorUriOptions_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(new Uri(testcase.BaseEndpoint), options); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.Same(options, client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Theory, ClassData(typeof(EndpointTestCases))] @@ -211,7 +211,7 @@ public void CtorUriAuthOptions_Valid_SetsEndpoint(EndpointTestCase testcase) var client = new DatasyncClient(new Uri(testcase.BaseEndpoint), authProvider, options); Assert.Equal(testcase.NormalizedEndpoint, client.Endpoint.ToString()); Assert.Same(options, client.ClientOptions); - Assert.NotNull(client.HttpClient); + Assert.NotNull(client.ServiceHttpClient); } [Fact]