Skip to content

Commit 069c052

Browse files
author
SqlClient Azure DevOps
committed
Merge in 'main' changes
2 parents db64574 + eb4c0f0 commit 069c052

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1770
-562
lines changed

CHANGELOG.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,74 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66

7+
## [Preview Release 6.0.0-preview1.24240.8] - 2024-08-27
8+
9+
This update brings the below changes over the previous release:
10+
11+
### Breaking Changes
12+
13+
- Removed support for .NET Standard. [#2386](https://github.com/dotnet/SqlClient/pull/2386)
14+
- Removed UWP (uap) references. [#2483](https://github.com/dotnet/SqlClient/pull/2483)
15+
16+
### Added
17+
18+
- Added `TokenCredential` object to take advantage of token caching in `ActiveDirectoryAuthenticationProvider`. [#2380](https://github.com/dotnet/SqlClient/pull/2380)
19+
- Added `DateOnly` and `TimeOnly` support to `DataTable` as a structured parameter. [#2258](https://github.com/dotnet/SqlClient/pull/2258)
20+
- Added `Microsoft.Data.SqlClient.Diagnostics.SqlClientDiagnostic` type in .NET. [#2226](https://github.com/dotnet/SqlClient/pull/2226)
21+
- Added scope trace for `GenerateSspiClientContext`. [#2497](https://github.com/dotnet/SqlClient/pull/2497), [#2725](https://github.com/dotnet/SqlClient/pull/2725)
22+
23+
### Fixed
24+
25+
- Fixed `Socket.Connect` timeout issue caused by thread starvation. [#2777](https://github.com/dotnet/SqlClient/pull/2777)
26+
- Fixed pending data with `SqlDataReader` against an encrypted column. [#2618](https://github.com/dotnet/SqlClient/pull/2618)
27+
- Fixed Entra authentication when using infinite connection timeout in `ActiveDirectoryAuthenticationProvider`. [#2651](https://github.com/dotnet/SqlClient/pull/2651)
28+
- Fixed `GetSchema` by excluding unsupported engines due to lack of support for `ASSEMBLYPROPERTY` function. [#2593](https://github.com/dotnet/SqlClient/pull/2593)
29+
- Fixed SSPI retry negotiation with default port in .NET. [#2559](https://github.com/dotnet/SqlClient/pull/2559)
30+
- Fixed assembly path in .NET 8.0 and `.AssemblyAttributes`. [#2550](https://github.com/dotnet/SqlClient/pull/2550)
31+
- Fixed certificate chain validation. [#2487](https://github.com/dotnet/SqlClient/pull/2487)
32+
- Fixed clone of `SqlConnection` to include `AccessTokenCallback`. [#2525](https://github.com/dotnet/SqlClient/pull/2525)
33+
- Fixed issue with `DateTimeOffset` in table-valued parameters, which was introduced in 5.2. [#2453](https://github.com/dotnet/SqlClient/pull/2453)
34+
- Fixed `ArgumentNullException` on `SqlDataRecord.GetValue` when using user-defined data type on .NET. [#2448](https://github.com/dotnet/SqlClient/pull/2448)
35+
- Fixed `SqlBuffer` and `SqlGuild` when it's null. [#2310](https://github.com/dotnet/SqlClient/pull/2310)
36+
- Fixed `SqlBulkCopy.WriteToServer` state in a consecutive calls. [#2375](https://github.com/dotnet/SqlClient/pull/2375)
37+
- Fixed null reference exception with `SqlConnection.FireInfoMessageEventOnUserErrors` after introducing the batch command. [#2399](https://github.com/dotnet/SqlClient/pull/2399)
38+
39+
### Changed
40+
41+
- Updated Microsoft.Data.SqlClient.SNI version to `6.0.0-preview1.24226.4`. [#2772](https://github.com/dotnet/SqlClient/pull/2772)
42+
- Improved access to `SqlAuthenticationProviderManager.Instance` and avoid early object initiation. [#2636](https://github.com/dotnet/SqlClient/pull/2636)
43+
- Removed undocumented properties of `Azure.Identity` in `ActiveDirectoryAuthenticationProvider`. [#2562](https://github.com/dotnet/SqlClient/pull/2562)
44+
- Replaced `System.Runtime.Caching` with `Microsoft.Extensions.Caching.Memory`. [#2493](https://github.com/dotnet/SqlClient/pull/2493)
45+
- Updated `EnableOptimizedParameterBinding` to only accept text mode commands. [#2417](https://github.com/dotnet/SqlClient/pull/2417)
46+
- Updated `Azure.Identity` version from `1.10.3` to `1.11.4`. [#2577](https://github.com/dotnet/SqlClient/pull/2577)
47+
- Updated `Azure.Core` version from `1.35.0` to `1.38.0`. [#2462](https://github.com/dotnet/SqlClient/pull/2462)
48+
- Updated `Azure.Security.KeyVault.Keys` version from `4.4.0` to `4.5.0`. [#2462](https://github.com/dotnet/SqlClient/pull/2462)
49+
- Updated `Microsoft.IdentityModel.JsonWebTokens` and `Microsoft.IdentityModel.Protocols.OpenIdConnect` from `6.35.0` to `7.5.0`. [#2429](https://github.com/dotnet/SqlClient/pull/2429)
50+
- Removed direct dependency to `Microsoft.Identity.Client` to take the transient dependecy through `Azure.Identity`. [#2577](https://github.com/dotnet/SqlClient/pull/2577)
51+
- Removed unnecessary references `Microsoft.Extensions.Caching.Memory` and `System.Security.Cryptography.Cng` after removing .NET Standard. [#2577](https://github.com/dotnet/SqlClient/pull/2577)
52+
- Improved memory allocation when reader opened by `CommandBehavior.SequentialAccess` over the big string columns. [#2356](https://github.com/dotnet/SqlClient/pull/2356)
53+
- Improved SSPI by consolidating the context generation to single abstraction and using memory/span for SSPI generation. [#2255](https://github.com/dotnet/SqlClient/pull/2255), [#2447](https://github.com/dotnet/SqlClient/pull/2447)
54+
- Reverted the [#2281](https://github.com/dotnet/SqlClient/pull/2281) code changes on ManagedSNI. [#2395](https://github.com/dotnet/SqlClient/pull/2395)
55+
- Updated assembly version to 6.0.0.0. [#2382](https://github.com/dotnet/SqlClient/pull/2382)
56+
- Code health improvements: [#2366](https://github.com/dotnet/SqlClient/pull/2366), [#2369](https://github.com/dotnet/SqlClient/pull/2369), [#2381](https://github.com/dotnet/SqlClient/pull/2381), [#2390](https://github.com/dotnet/SqlClient/pull/2390), [#2392](https://github.com/dotnet/SqlClient/pull/2392), [#2403](https://github.com/dotnet/SqlClient/pull/2403), [#2410](https://github.com/dotnet/SqlClient/pull/2410), [#2413](https://github.com/dotnet/SqlClient/pull/2413), [#2425](https://github.com/dotnet/SqlClient/pull/2425), [#2428](https://github.com/dotnet/SqlClient/pull/2428), [#2440](https://github.com/dotnet/SqlClient/pull/2440), [#2443](https://github.com/dotnet/SqlClient/pull/2443), [#2450](https://github.com/dotnet/SqlClient/pull/2450), [#2466](https://github.com/dotnet/SqlClient/pull/2466), [#2486](https://github.com/dotnet/SqlClient/pull/2486), [#2521](https://github.com/dotnet/SqlClient/pull/2521), [#2522](https://github.com/dotnet/SqlClient/pull/2522), [#2533](https://github.com/dotnet/SqlClient/pull/2533), [#2552](https://github.com/dotnet/SqlClient/pull/2552), [#2560](https://github.com/dotnet/SqlClient/pull/2560), [#2726](https://github.com/dotnet/SqlClient/pull/2726), [#2751](https://github.com/dotnet/SqlClient/pull/2751), [#2811](https://github.com/dotnet/SqlClient/pull/2811)
57+
58+
## [Stable release 5.2.2] - 2024-08-27
59+
60+
### Fixed
61+
62+
- Fixed `AcquireTokenAsync` timeout handling for edge cases in `ActiveDirectoryAuthenticationProvider`. [#2650](https://github.com/dotnet/SqlClient/pull/2650)
63+
- Fixed issue with `Socket.Connect` in managed SNI. [#2779](https://github.com/dotnet/SqlClient/pull/2779)
64+
- Fixed path for `AssemblyAttributes` in obj folder causing NET 8.0 assembly to appear in NET 6.0 dll. [#2789](https://github.com/dotnet/SqlClient/pull/2789)
65+
- Fixed SSPI retry negotiation with default port in .NET. [#2815](https://github.com/dotnet/SqlClient/pull/2815)
66+
- Fixed `ArgumentNullException` on `SqlDataRecord.GetValue` when using user-defined data type on .NET. [#2816](https://github.com/dotnet/SqlClient/pull/2816)
67+
- Fixed pending data with `SqlDataReader` against an encrypted column. [#2817](https://github.com/dotnet/SqlClient/pull/2817)
68+
69+
### Changed
70+
71+
- Upgraded `Azure.Identity` version from 1.11.3 to 1.11.4 [#2648](https://github.com/dotnet/SqlClient/pull/2648) to address [CVE-2024-35255](https://github.com/advisories/GHSA-m5vv-6r4h-3vj9).
72+
- Upgraded `Microsoft.Identity.Client` version from 4.60.0 to 4.61.3 [#2648](https://github.com/dotnet/SqlClient/pull/2648) to address [CVE-2024-35255](https://github.com/advisories/GHSA-m5vv-6r4h-3vj9).
73+
- Added caching to `TokenCredential` objects to take advantage of token caching. [#2775](https://github.com/dotnet/SqlClient/pull/2775)
74+
775
## [Stable release 5.2.1] - 2024-05-31
876

977
This update brings the below changes over the previous release:
@@ -216,6 +284,21 @@ This update brings the below changes over the previous release:
216284
- Added Microsoft.SqlServer.Types to verify support for SqlHierarchyId and Spatial for .NET Core. [#1848](https://github.com/dotnet/SqlClient/pull/1848)
217285
- Code health improvements:[#1943](https://github.com/dotnet/SqlClient/pull/1943)[#1949](https://github.com/dotnet/SqlClient/pull/1949)[#1198](https://github.com/dotnet/SqlClient/pull/1198)[#1829](https://github.com/dotnet/SqlClient/pull/1829)
218286

287+
## [Stable release 5.1.6] - 2024-08-27
288+
289+
### Fixed
290+
291+
- Fixed Transient fault handling issue with `OpenAsync`. [#1983](https://github.com/dotnet/SqlClient/pull/1983) [#2508](https://github.com/dotnet/SqlClient/pull/2508)
292+
- Fixed `AcquireTokenAsync` timeout handling for edge cases in `ActiveDirectoryAuthenticationProvider`. [#2706](https://github.com/dotnet/SqlClient/pull/2706)
293+
- Fixed pending data with `SqlDataReader` against an encrypted column. [#2618](https://github.com/dotnet/SqlClient/pull/2618) [#2818](https://github.com/dotnet/SqlClient/pull/2818)
294+
295+
### Changed
296+
297+
- Upgraded `Azure.Identity` version from 1.11.3 to 1.11.4 [#2649] (https://github.com/dotnet/SqlClient/pull/2649) [#2529] (https://github.com/dotnet/SqlClient/pull/2529) to address [CVE-2024-35255](https://github.com/advisories/GHSA-m5vv-6r4h-3vj9).
298+
- Upgraded `Microsoft.Identity.Client` version from 4.60.0 to 4.61.3 [#2649] (https://github.com/dotnet/SqlClient/pull/2649) [#2529] (https://github.com/dotnet/SqlClient/pull/2529) to address [CVE-2024-35255](https://github.com/advisories/GHSA-m5vv-6r4h-3vj9).
299+
- Added caching to `TokenCredential` objects to take advantage of token caching. [#2776](https://github.com/dotnet/SqlClient/pull/2776)
300+
- Code health improvements: [#2490] (https://github.com/dotnet/SqlClient/pull/2490)
301+
219302
## [Stable release 5.1.5] - 2024-01-29
220303

221304
This update brings the below changes over the previous release:

README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/dotnet/sqlclient/master/LICENSE)
22
[![Nuget](https://img.shields.io/nuget/dt/Microsoft.Data.SqlClient?label=Nuget.org%20Downloads&style=flat-square&color=blue)](https://www.nuget.org/packages/Microsoft.Data.SqlClient)
3-
[![Gitter](https://img.shields.io/gitter/room/badges/shields.svg?style=flat-square&color=blue)](https://gitter.im/Microsoft/mssql-developers)
4-
[![Build status](https://sqlclientdrivers.visualstudio.com/public/_apis/build/status/ADO/CI-SqlClient)](https://sqlclientdrivers.visualstudio.com/public/_build/latest?definitionId=1139)
3+
[![Build status](https://sqlclientdrivers.visualstudio.com/public/_apis/build/status/ADO/CI-SqlClient)](https://sqlclientdrivers.visualstudio.com/public/_build/latest?definitionId=1879)
54

65
# Microsoft SqlClient Data Provider for SQL Server
76

8-
Welcome to the home of the Microsoft ADO.NET driver for SQL Server aka the Microsoft.Data.SqlClient GitHub repository.
9-
10-
Microsoft.Data.SqlClient is a data provider for Microsoft SQL Server and Azure SQL Database. Now in General Availability, it is a union of the two System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server features will be implemented in Microsoft.Data.SqlClient.
7+
Microsoft.Data.SqlClient is a .NET data provider for [Microsoft SQL Server]([url](https://aka.ms/sql)) and the [Azure SQL]([url](https://aka.ms/azure_sql)) family of databases. It grew from a union of the two System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server and Azure SQL features will only be implemented in Microsoft.Data.SqlClient.
118

129
## Supportability
1310

14-
The Microsoft.Data.SqlClient package supports the below environments:
11+
The Microsoft.Data.SqlClient package supports the following environments:
1512

1613
- .NET Framework 4.6.2+
17-
- .NET Core 3.1+
18-
- .NET Standard 2.0+
19-
20-
The source code of this library is now available under the MIT license.
14+
- .NET 6.0+
2115

2216
## Download
2317

2418
The Microsoft.Data.SqlClient NuGet package is available on [NuGet.org](https://www.nuget.org/packages/Microsoft.Data.SqlClient/).
2519

2620
## SNI Package References
2721

28-
For the .NET Framework driver on Windows, a package reference to [Microsoft.Data.SqlClient.SNI](https://www.nuget.org/packages/Microsoft.Data.SqlClient.SNI/) loads native `Microsoft.Data.SqlClient.SNI.x64.dll` and `Microsoft.Data.SqlClient.SNI.x86.dll` libraries into the client's build directories.
22+
When targeting .NET Framework on Windows, a package reference to [Microsoft.Data.SqlClient.SNI](https://www.nuget.org/packages/Microsoft.Data.SqlClient.SNI/) loads native `Microsoft.Data.SqlClient.SNI.<platform>.dll` libraries into the client's build directories.
2923

30-
For the .NET Core driver on Windows, a package reference to [Microsoft.Data.SqlClient.SNI.runtime](https://www.nuget.org/packages/Microsoft.Data.SqlClient.SNI.runtime/) loads `arm`, `arm64`, `x64` and `x86` native `Microsoft.Data.SqlClient.SNI.dll` libraries into the client's build directories.
24+
When targeting .NET on Windows, a package reference to [Microsoft.Data.SqlClient.SNI.runtime](https://www.nuget.org/packages/Microsoft.Data.SqlClient.SNI.runtime/) loads `arm64`, `x64` and `x86` native `Microsoft.Data.SqlClient.SNI.dll` libraries into subdirectories in the client's build directory.
3125

3226
## Helpful Links
3327

@@ -40,7 +34,6 @@ For the .NET Core driver on Windows, a package reference to [Microsoft.Data.SqlC
4034
| Support Policy | [SUPPORT.md](SUPPORT.md) |
4135
| Code of Conduct | [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) |
4236
| Copyright Information | [COPYRIGHT.md](COPYRIGHT.md) |
43-
| | |
4437

4538
## Our Featured Contributors
4639

@@ -65,7 +58,7 @@ All preview and stable driver release notes are available under [release-notes](
6558

6659
## Porting from System.Data.SqlClient
6760

68-
Refer to [porting-cheat-sheet.md](porting-cheat-sheet.md) for a safe porting experience from System.Data.SqlClient to Microsoft.Data.SqlClient and share your experience with us by advancing this guide for future developers.
61+
Refer to [porting-cheat-sheet.md](porting-cheat-sheet.md) for a safe porting experience from System.Data.SqlClient to Microsoft.Data.SqlClient and share your experience with us by enhancing this guide for future developers.
6962

7063
## Still have questions?
7164

doc/samples/AADAuthenticationCustomDeviceFlowCallback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//<Snippet1>
1+
//<Snippet1>
22
using System;
33
using System.Threading.Tasks;
44
using Microsoft.Identity.Client;

doc/samples/AzureKeyVaultProviderExample.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ public static void Main(string[] args)
7979
}
8080
}
8181

82+
// Maintain an instance of the ClientCredential object to take advantage of underlying token caching
83+
private static ClientCredential clientCredential = new ClientCredential(s_clientId, s_clientSecret);
84+
8285
public static async Task<string> AzureActiveDirectoryAuthenticationCallback(string authority, string resource, string scope)
8386
{
8487
var authContext = new AuthenticationContext(authority);
85-
ClientCredential clientCred = new ClientCredential(s_clientId, s_clientSecret);
86-
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);
88+
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCredential);
8789
if (result == null)
8890
{
8991
throw new InvalidOperationException($"Failed to retrieve an access token for {resource}");

doc/samples/AzureKeyVaultProviderWithEnclaveProviderExample.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ static void Main(string[] args)
8181
}
8282
}
8383

84+
// Maintain an instance of the ClientCredential object to take advantage of underlying token caching
85+
private static ClientCredential clientCredential = new ClientCredential(s_clientId, s_clientSecret);
86+
8487
public static async Task<string> AzureActiveDirectoryAuthenticationCallback(string authority, string resource, string scope)
8588
{
8689
var authContext = new AuthenticationContext(authority);
87-
ClientCredential clientCred = new ClientCredential(s_clientId, s_clientSecret);
88-
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);
90+
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCredential);
8991
if (result == null)
9092
{
9193
throw new InvalidOperationException($"Failed to retrieve an access token for {resource}");

doc/samples/CustomDeviceCodeFlowAzureAuthenticationProvider.cs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
//<Snippet1>
1+
//<Snippet1>
22
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
35
using System.Threading.Tasks;
4-
using Microsoft.Identity.Client;
56
using Microsoft.Data.SqlClient;
7+
using Microsoft.Identity.Client;
68

79
namespace CustomAuthenticationProviderExamples
810
{
@@ -12,28 +14,46 @@ namespace CustomAuthenticationProviderExamples
1214
/// </summary>
1315
public class CustomDeviceCodeFlowAzureAuthenticationProvider : SqlAuthenticationProvider
1416
{
17+
private const string clientId = "my-client-id";
18+
private const string clientName = "My Application Name";
19+
private const string s_defaultScopeSuffix = "/.default";
20+
21+
// Maintain a copy of the PublicClientApplication object to cache the underlying access tokens it provides
22+
private static IPublicClientApplication pcApplication;
23+
1524
public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters)
1625
{
17-
string clientId = "my-client-id";
18-
string clientName = "My Application Name";
19-
string s_defaultScopeSuffix = "/.default";
20-
2126
string[] scopes = new string[] { parameters.Resource.EndsWith(s_defaultScopeSuffix) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix };
2227

23-
IPublicClientApplication app = PublicClientApplicationBuilder.Create(clientId)
24-
.WithAuthority(parameters.Authority)
25-
.WithClientName(clientName)
26-
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
28+
IPublicClientApplication app = pcApplication;
29+
if (app == null)
30+
{
31+
pcApplication = app = PublicClientApplicationBuilder.Create(clientId)
32+
.WithAuthority(parameters.Authority)
33+
.WithClientName(clientName)
34+
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
2735
.Build();
36+
}
37+
38+
AuthenticationResult result;
39+
40+
try
41+
{
42+
IEnumerable<IAccount> accounts = await app.GetAccountsAsync();
43+
result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault()).ExecuteAsync();
44+
}
45+
catch (MsalUiRequiredException)
46+
{
47+
result = await app.AcquireTokenWithDeviceCode(scopes,
48+
deviceCodeResult => CustomDeviceFlowCallback(deviceCodeResult)).ExecuteAsync();
49+
}
2850

29-
AuthenticationResult result = await app.AcquireTokenWithDeviceCode(scopes,
30-
deviceCodeResult => CustomDeviceFlowCallback(deviceCodeResult)).ExecuteAsync();
3151
return new SqlAuthenticationToken(result.AccessToken, result.ExpiresOn);
3252
}
3353

3454
public override bool IsSupported(SqlAuthenticationMethod authenticationMethod) => authenticationMethod.Equals(SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow);
3555

36-
private Task CustomDeviceFlowCallback(DeviceCodeResult result)
56+
private static Task<int> CustomDeviceFlowCallback(DeviceCodeResult result)
3757
{
3858
Console.WriteLine(result.Message);
3959
return Task.FromResult(0);

0 commit comments

Comments
 (0)