diff --git a/csharp/Directory.Build.props b/csharp/Directory.Build.props
new file mode 100644
index 0000000..bbe4a9a
--- /dev/null
+++ b/csharp/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ net8.0;net9.0
+
+
diff --git a/csharp/Microsoft.Azure.Databricks.Client.Sample/Microsoft.Azure.Databricks.Client.Sample.csproj b/csharp/Microsoft.Azure.Databricks.Client.Sample/Microsoft.Azure.Databricks.Client.Sample.csproj
index cf063a2..d315238 100644
--- a/csharp/Microsoft.Azure.Databricks.Client.Sample/Microsoft.Azure.Databricks.Client.Sample.csproj
+++ b/csharp/Microsoft.Azure.Databricks.Client.Sample/Microsoft.Azure.Databricks.Client.Sample.csproj
@@ -1,8 +1,6 @@
-
Exe
- net8.0;net9.0
latest
false
enable
diff --git a/csharp/Microsoft.Azure.Databricks.Client.Test/Microsoft.Azure.Databricks.Client.Test.csproj b/csharp/Microsoft.Azure.Databricks.Client.Test/Microsoft.Azure.Databricks.Client.Test.csproj
index b2fc07d..1007976 100644
--- a/csharp/Microsoft.Azure.Databricks.Client.Test/Microsoft.Azure.Databricks.Client.Test.csproj
+++ b/csharp/Microsoft.Azure.Databricks.Client.Test/Microsoft.Azure.Databricks.Client.Test.csproj
@@ -1,7 +1,5 @@
-
- net8.0;net9.0
latest
false
enable
diff --git a/csharp/Microsoft.Azure.Databricks.Client.sln b/csharp/Microsoft.Azure.Databricks.Client.sln
index 3eeee5d..0226ef1 100644
--- a/csharp/Microsoft.Azure.Databricks.Client.sln
+++ b/csharp/Microsoft.Azure.Databricks.Client.sln
@@ -12,6 +12,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0D112210-7B29-455F-B677-6491F870228B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
+ Directory.Build.props = Directory.Build.props
+ Directory.Packages.props = Directory.Packages.props
+ nuget.config = nuget.config
EndProjectSection
EndProject
Global
diff --git a/csharp/Microsoft.Azure.Databricks.Client/ApiClient.cs b/csharp/Microsoft.Azure.Databricks.Client/ApiClient.cs
index 3743fe5..a30a81b 100644
--- a/csharp/Microsoft.Azure.Databricks.Client/ApiClient.cs
+++ b/csharp/Microsoft.Azure.Databricks.Client/ApiClient.cs
@@ -1,18 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-
-using Microsoft.Azure.Databricks.Client.Converters;
+#nullable enable
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
+using System.Text.Json.Serialization.Metadata;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Azure.Databricks.Client.Converters;
+
namespace Microsoft.Azure.Databricks.Client;
public abstract class ApiClient : IDisposable
@@ -52,7 +55,16 @@ protected static ClientApiException CreateApiException(HttpResponseMessage respo
return new ClientApiException(errorContent, statusCode);
}
- private static async Task SendRequest(HttpClient httpClient, HttpMethod method, string requestUri, TBody body, CancellationToken cancellationToken = default)
+ protected static async Task SendRequest(HttpClient httpClient, HttpMethod method, string requestUri, HttpContent? content, JsonTypeInfo typeInfo, CancellationToken cancellationToken = default)
+ {
+ using var response = await FetchResponse(httpClient, method, requestUri, content, cancellationToken).ConfigureAwait(false);
+ await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+
+ return await JsonSerializer.DeserializeAsync(responseStream, typeInfo, cancellationToken).ConfigureAwait(false);
+ }
+
+ [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.DeserializeAsync(Stream, JsonSerializerOptions, CancellationToken)")]
+ private static async Task SendRequest(HttpClient httpClient, HttpMethod method, string requestUri, TBody? body, CancellationToken cancellationToken = default)
{
using var response = await FetchResponse(httpClient, method, requestUri, body, cancellationToken).ConfigureAwait(false);
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
@@ -60,18 +72,21 @@ private static async Task SendRequest(HttpClient httpCl
return await JsonSerializer.DeserializeAsync(responseStream, Options, cancellationToken).ConfigureAwait(false);
}
- private static async Task SendRequest(HttpClient httpClient, HttpMethod method, string requestUri, TBody body, CancellationToken cancellationToken = default)
+ [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.DeserializeAsync(Stream, JsonSerializerOptions, CancellationToken)")]
+ private static async Task SendRequest(HttpClient httpClient, HttpMethod method, string requestUri, TBody? body, CancellationToken cancellationToken = default)
{
await FetchResponse(httpClient, method, requestUri, body, cancellationToken).ConfigureAwait(false);
}
+ [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.DeserializeAsync(Stream, JsonSerializerOptions, CancellationToken)")]
private static async Task SendHeadRequest(HttpClient httpClient, HttpMethod method,
- string requestUri, TBody body = default, CancellationToken cancellationToken = default)
+ string requestUri, TBody? body = default, CancellationToken cancellationToken = default)
{
using var response = await FetchResponse(httpClient, method, requestUri, body, cancellationToken).ConfigureAwait(false);
return response.Content.Headers;
}
+ [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.DeserializeAsync(Stream, JsonSerializerOptions, CancellationToken)")]
private static async Task FetchResponse(HttpClient httpClient, HttpMethod method,
string requestUri, TBody body, CancellationToken cancellationToken = default)
{
@@ -90,54 +105,81 @@ private static async Task FetchResponse(HttpClient h
return response;
}
- protected static async Task HttpGet(HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default)
+ private static async Task FetchResponse(HttpClient httpClient, HttpMethod method,
+ string requestUri, HttpContent? content, CancellationToken cancellationToken = default)
+ {
+ var request = new HttpRequestMessage(method, requestUri)
+ {
+ Content = content,
+ };
+
+ var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ if (!response.IsSuccessStatusCode)
+ {
+ throw CreateApiException(response);
+ }
+
+ return response;
+ }
+
+ [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.DeserializeAsync(Stream, JsonSerializerOptions, CancellationToken)")]
+ protected static async Task HttpGet(HttpClient httpClient, string requestUri, CancellationToken cancellationToken = default)
{
return await SendRequest