Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ csharp_space_between_square_brackets = false

# Analyzers

# IDE0005: Remove unnecessary using directives
dotnet_diagnostic.IDE0005.severity = suggestion

dotnet_code_quality.ca1802.api_surface = private, internal

# CA2000: Dispose objects before losing scope
Expand Down
51 changes: 16 additions & 35 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,17 @@
<!-- Dependencies shared by multiple projects -->

<ItemGroup>
<PackageVersion Include="Azure.Core" Version="1.49.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Microsoft.DotNet.RemoteExecutor" Version="11.0.0-beta.25476.3" />
<PackageVersion Include="Microsoft.DotNet.XUnitExtensions" Version="11.0.0-beta.25476.3" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.78.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.SqlServer.SqlManagementObjects" Version="172.76.0" />
<PackageVersion Include="Microsoft.SqlServer.Types" Version="160.1000.6" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="System.Data.Odbc" Version="9.0.9" />
<PackageVersion Include="System.Security.Principal.Windows" Version="5.0.0" />
<PackageVersion Include="System.ServiceProcess.ServiceController" Version="9.0.9" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="xunit.runner.console" Version="2.9.3" />
<PackageVersion Include="Azure.Core" Version="1.51.1" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.83.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.13" />
</ItemGroup>

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<!--
We can't use a newer major version of this package because it pulls in
a newer major version of System.Text.Json that conflicts with our
explicit dependency on version 8.x of that package.
-->
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>

<!-- ===================================================================== -->
Expand All @@ -102,7 +82,7 @@
<!-- Azure Dependencies -->

<ItemGroup>
<PackageVersion Include="Azure.Identity" Version="1.17.0" />
<PackageVersion Include="Azure.Identity" Version="1.18.0" />
</ItemGroup>

<!-- ===================================================================== -->
Expand All @@ -111,21 +91,21 @@
<ItemGroup>
<PackageVersion Include="Microsoft.Data.SqlClient.SNI" Version="6.0.2" />
<PackageVersion Include="Microsoft.Data.SqlClient.SNI.runtime" Version="6.0.2" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.14.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.14.0" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.16.0" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.16.0" />
<PackageVersion Include="System.Buffers" Version="4.6.1" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="10.0.3" />
<PackageVersion Include="System.Memory" Version="4.6.3" />
<PackageVersion Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.6" />
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
<PackageVersion Include="System.Text.Json" Version="10.0.3" />
<PackageVersion Include="System.ValueTuple" Version="4.6.2" />
<PackageVersion Include="System.Threading.Channels" Version="10.0.3" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="9.0.9" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.9" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.9" />
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="9.0.13" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.13" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="9.0.13" />
</ItemGroup>

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))">
Expand All @@ -138,6 +118,7 @@
<!-- AKV Dependencies -->

<ItemGroup>
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.8.0" />
<PackageVersion Include="Azure.Security.KeyVault.Keys" Version="4.9.0" />
</ItemGroup>

</Project>
7 changes: 4 additions & 3 deletions doc/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<!-- Import parent Directory.Packages.props -->
<Import Project="..\Directory.Packages.props" />
<ItemGroup>
<!-- Reference latest stable version of MDS and AKV provider -->
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.4" />
<PackageVersion Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="6.1.2" />
<!-- Reference SqlClient package versions that support our needs. -->
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.0-preview4.26064.3" />
<PackageVersion Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="7.0.0-preview1.26064.3" />
<PackageVersion Include="Microsoft.Data.SqlClient.Extensions.Azure" Version="1.0.0-preview1.26064.3" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ namespace AzureKeyVaultProvider_ColumnEncryptionKeyCacheScope
// <Snippet1>
class Program
{
#pragma warning disable CS0649 // Field is never assigned to
private static string connectionString;
#pragma warning restore CS0649

static void Main()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ConnectionStringSettings_RetrieveFromConfigByName;
namespace ConnectionStringSettings_RetrieveFromConfigByName;

using System;
using System.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ConnectionStringSettings_RetrieveFromConfigByProvider;
namespace ConnectionStringSettings_RetrieveFromConfigByProvider;

using System;
using System.Data;
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/ConnectionStrings_Encrypt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ConnectionStrings_Encrypt;
namespace ConnectionStrings_Encrypt;

using System;
using System.Configuration;
Expand Down
8 changes: 5 additions & 3 deletions doc/samples/Microsoft.Data.SqlClient.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<OutputType>Library</OutputType>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- TODO: Enable nullable and fix nullable warnings in samples. -->
<!-- <Nullable>enable</Nullable> -->
<LangVersion>Latest</LangVersion>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Core" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
<PackageReference Include="Microsoft.Data.SqlClient.Extensions.Azure" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
Expand All @@ -26,5 +28,5 @@
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlUserDefinedTypeAttribute_Type1;
namespace SqlUserDefinedTypeAttribute_Type1;

//-----------------------------------------------------------------------------
//<Snippet5>
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlBulkCopy_RowArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ private static string GetConnectionString()
"Initial Catalog=AdventureWorks;";
}
}
// </Snippet>
// </Snippet1>
2 changes: 1 addition & 1 deletion doc/samples/SqlClientDiagnosticCounter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlClientDiagnosticCounter;
namespace SqlClientDiagnosticCounter;

// <Snippet1>
using System;
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlClientEventSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlClientEventSource;
namespace SqlClientEventSource;

// <Snippet1>
using System;
Expand Down
39 changes: 20 additions & 19 deletions doc/samples/SqlCommand_BeginExecuteReaderAsyncBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if NETFRAMEWORK
#nullable enable

// <Snippet1>
using System;
Expand All @@ -24,8 +25,8 @@ public Form1()

private void InitializeComponent() { }

// Hook up the form's Load event handler (you can double-click on
// the form's design surface in Visual Studio), and then add
// Hook up the form's Load event handler (you can double-click on
// the form's design surface in Visual Studio), and then add
// this code to the form's class:
// You need this delegate in order to fill the grid from
// a thread other than the form's thread. See the HandleCallback
Expand All @@ -36,7 +37,7 @@ private void InitializeComponent() { }
private delegate void DisplayStatusDelegate(string Text);

// This flag ensures that the user does not attempt
// to restart the command or close the form while the
// to restart the command or close the form while the
// asynchronous command is executing.
private bool isExecuting;

Expand Down Expand Up @@ -71,7 +72,7 @@ private void FillGrid(SqlDataReader reader)
finally
{
// Closing the reader also closes the connection,
// because this reader was created using the
// because this reader was created using the
// CommandBehavior.CloseConnection value.
if (reader != null)
{
Expand All @@ -92,32 +93,32 @@ private void HandleCallback(IAsyncResult result)
// You may not interact with the form and its contents
// from a different thread, and this callback procedure
// is all but guaranteed to be running from a different thread
// than the form. Therefore you cannot simply call code that
// than the form. Therefore you cannot simply call code that
// fills the grid, like this:
// FillGrid(reader);
// Instead, you must call the procedure from the form's thread.
// One simple way to accomplish this is to call the Invoke
// method of the form, which calls the delegate you supply
// from the form's thread.
// from the form's thread.
FillGridDelegate del = new FillGridDelegate(FillGrid);
this.Invoke(del, reader);
// Do not close the reader here, because it is being used in
// Do not close the reader here, because it is being used in
// a separate thread. Instead, have the procedure you have
// called close the reader once it is done with it.
}
catch (Exception ex)
{
// Because you are now running code in a separate thread,
// Because you are now running code in a separate thread,
// if you do not handle the exception here, none of your other
// code catches the exception. Because there is none of
// code catches the exception. Because there is none of
// your code on the call stack in this thread, there is nothing
// higher up the stack to catch the exception if you do not
// handle it here. You can either log the exception or
// invoke a delegate (as in the non-error case in this
// higher up the stack to catch the exception if you do not
// handle it here. You can either log the exception or
// invoke a delegate (as in the non-error case in this
// example) to display the error on the form. In no case
// can you simply display the error without executing a delegate
// as in the try block here.
// You can create the delegate instance as you
// as in the try block here.
// You can create the delegate instance as you
// invoke it, like this:
this.Invoke(new DisplayStatusDelegate(DisplayStatus), "Error: " +
ex.Message);
Expand All @@ -130,8 +131,8 @@ private void HandleCallback(IAsyncResult result)

private string GetConnectionString()
{
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file.
// To avoid storing the connection string in your code,
// you can retrieve it from a configuration file.

return "Data Source=(local);Integrated Security=true;" +
"Initial Catalog=AdventureWorks";
Expand All @@ -153,7 +154,7 @@ private void button1_Click(object sender, System.EventArgs e)
{
DisplayStatus("Connecting...");
connection = new SqlConnection(GetConnectionString());
// To emulate a long-running query, wait for
// To emulate a long-running query, wait for
// a few seconds before retrieving the real data.
command = new SqlCommand("WAITFOR DELAY '0:0:5';" +
"SELECT ProductID, Name, ListPrice, Weight FROM Production.Product",
Expand All @@ -162,8 +163,8 @@ private void button1_Click(object sender, System.EventArgs e)

DisplayStatus("Executing...");
isExecuting = true;
// Although it is not required that you pass the
// SqlCommand object as the second parameter in the
// Although it is not required that you pass the
// SqlCommand object as the second parameter in the
// BeginExecuteReader call, doing so makes it easier
// to call EndExecuteReader in the callback procedure.
AsyncCallback callback = new AsyncCallback(HandleCallback);
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_Events.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.Data.SqlClient;
using System.Data;

Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_FillDataSet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.Data.SqlClient;
using System.Data;

Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_MergeIdentity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlDataAdapter_MergeIdentity;
namespace SqlDataAdapter_MergeIdentity;

using System;
using System.Data;
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_Paging.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.Data.SqlClient;
using System.Data;

Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_Properties.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlDataAdapter_Properties;
namespace SqlDataAdapter_Properties;

// <Snippet1>
using System;
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/SqlDataAdapter_RowUpdated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ namespace SqlDataAdapter_RowUpdated;

public class Form1 : Form
{
#pragma warning disable CS0169 // Field is never used
private DataSet DataSet1;
private DataGrid dataGrid1;
#pragma warning restore CS0169

// handler for RowUpdating event
private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlDataAdapter_Update.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace SqlDataAdapterUpdateExample;
namespace SqlDataAdapterUpdateExample;

using System;
using System.Data;
Expand Down
2 changes: 1 addition & 1 deletion doc/samples/SqlFunctionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public static IEnumerable GetFileDetails(string directoryPath)

}
}
//<Snippet1>
//</Snippet1>
1 change: 0 additions & 1 deletion doc/samples/SqlParameterCollection_AddWithValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ private static void UpdateDemographics(Int32 customerID,
}
}
}
// </Snippet1>
static private string GetConnectionString()
{
// To avoid storing the connection string in your code,
Expand Down
2 changes: 2 additions & 0 deletions doc/samples/SqlRowUpdatingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ namespace SqlRowUpdatingEventArgsCS;

public class Form1 : Form
{
#pragma warning disable CS0169 // Field is never used
private DataSet DataSet1;
private DataGrid dataGrid1;
#pragma warning restore CS0169


// handler for RowUpdating event
Expand Down
4 changes: 4 additions & 0 deletions doc/samples/SspiContextProvider_CustomProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#if NET
// <Snippet1>
#nullable enable

using System;
using System.Buffers;
using System.Net.Security;
Expand Down Expand Up @@ -53,3 +56,4 @@ static void Main()
}
}
// </Snippet1>
#endif
2 changes: 1 addition & 1 deletion doc/samples/TransactionIsolationLevels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Data;
// <Snippet1>
using Microsoft.Data.SqlClient;
Expand Down
Loading
Loading