Skip to content

Commit eecd66e

Browse files
Merge branch 'main' into dev/cheena/merge-from-gh
2 parents 74b35ea + a947223 commit eecd66e

File tree

300 files changed

+46472
-24973
lines changed

Some content is hidden

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

300 files changed

+46472
-24973
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ This update brings the below changes over the previous release:
12541254
- Improved performance of Managed SNI by enhancing utilization of resources [#173](https://github.com/dotnet/SqlClient/pull/173) - Ported [dotnet/corefx#35363](https://github.com/dotnet/corefx/pull/35363) and [dotnet/corefx#40732](https://github.com/dotnet/corefx/pull/40732)
12551255
- Improved performance of Managed SNI RPC Parameter Usage [#209](https://github.com/dotnet/SqlClient/pull/209) - Ported [dotnet/corefx#34049](https://github.com/dotnet/corefx/pull/34049)
12561256
- Changed enclave key map to be lazy initialized [#372](https://github.com/dotnet/SqlClient/pull/372)
1257-
- Changed `Recieve()` and `ReceiveAsync()` implementation to receive null packets on failure [#350](https://github.com/dotnet/SqlClient/pull/350)
1257+
- Changed `Receive()` and `ReceiveAsync()` implementation to receive null packets on failure [#350](https://github.com/dotnet/SqlClient/pull/350)
12581258
- Changed `EnclaveProviderBase` caching implementation to support Async Scenarios _(Introduces breaking changes)_ [#346](https://github.com/dotnet/SqlClient/pull/346)
12591259

12601260
## [Stable Release 1.1.0] - 2019-11-20

doc/samples/CustomDeviceCodeFlowAzureAuthenticationProvider.cs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5+
using System.Threading;
56
using System.Threading.Tasks;
67
using Microsoft.Data.SqlClient;
78
using Microsoft.Identity.Client;
@@ -14,49 +15,52 @@ namespace CustomAuthenticationProviderExamples
1415
/// </summary>
1516
public class CustomDeviceCodeFlowAzureAuthenticationProvider : SqlAuthenticationProvider
1617
{
17-
private const string clientId = "my-client-id";
18-
private const string clientName = "My Application Name";
19-
private const string s_defaultScopeSuffix = "/.default";
18+
private const string ClientId = "my-client-id";
19+
private const string ClientName = "My Application Name";
20+
private const string DefaultScopeSuffix = "/.default";
2021

2122
// Maintain a copy of the PublicClientApplication object to cache the underlying access tokens it provides
2223
private static IPublicClientApplication pcApplication;
2324

2425
public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters)
2526
{
26-
string[] scopes = new string[] { parameters.Resource.EndsWith(s_defaultScopeSuffix) ? parameters.Resource : parameters.Resource + s_defaultScopeSuffix };
27+
string[] scopes = [ parameters.Resource.EndsWith(DefaultScopeSuffix) ? parameters.Resource : parameters.Resource + DefaultScopeSuffix ];
2728

2829
IPublicClientApplication app = pcApplication;
2930
if (app == null)
3031
{
31-
pcApplication = app = PublicClientApplicationBuilder.Create(clientId)
32+
pcApplication = app = PublicClientApplicationBuilder.Create(ClientId)
3233
.WithAuthority(parameters.Authority)
33-
.WithClientName(clientName)
34+
.WithClientName(ClientName)
3435
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
35-
.Build();
36+
.Build();
3637
}
3738

3839
AuthenticationResult result;
40+
using CancellationTokenSource connectionTimeoutCancellation = new CancellationTokenSource(TimeSpan.FromSeconds(parameters.ConnectionTimeout));
3941

4042
try
4143
{
4244
IEnumerable<IAccount> accounts = await app.GetAccountsAsync();
43-
result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault()).ExecuteAsync();
45+
result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault())
46+
.ExecuteAsync(connectionTimeoutCancellation.Token);
4447
}
4548
catch (MsalUiRequiredException)
4649
{
47-
result = await app.AcquireTokenWithDeviceCode(scopes,
48-
deviceCodeResult => CustomDeviceFlowCallback(deviceCodeResult)).ExecuteAsync();
50+
result = await app.AcquireTokenWithDeviceCode(scopes, deviceCodeResult => CustomDeviceFlowCallback(deviceCodeResult))
51+
.ExecuteAsync(connectionTimeoutCancellation.Token);
4952
}
5053

5154
return new SqlAuthenticationToken(result.AccessToken, result.ExpiresOn);
5255
}
5356

54-
public override bool IsSupported(SqlAuthenticationMethod authenticationMethod) => authenticationMethod.Equals(SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow);
57+
public override bool IsSupported(SqlAuthenticationMethod authenticationMethod)
58+
=> authenticationMethod.Equals(SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow);
5559

56-
private static Task<int> CustomDeviceFlowCallback(DeviceCodeResult result)
60+
private static Task CustomDeviceFlowCallback(DeviceCodeResult result)
5761
{
5862
Console.WriteLine(result.Message);
59-
return Task.FromResult(0);
63+
return Task.CompletedTask;
6064
}
6165
}
6266

doc/samples/SqlBatch_ExecuteReader.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static void RunBatch(string connString)
1515
using var connection = new SqlConnection(connString);
1616
connection.Open();
1717

18-
var batch = new SqlBatch(connection);
18+
using var batch = new SqlBatch(connection);
1919

2020
const int count = 10;
2121
const string parameterName = "parameter";
@@ -26,9 +26,6 @@ static void RunBatch(string connString)
2626
batch.BatchCommands.Add(batchCommand);
2727
}
2828

29-
// Optionally Prepare
30-
batch.Prepare();
31-
3229
var results = new List<int>(count);
3330
using (SqlDataReader reader = batch.ExecuteReader())
3431
{

doc/samples/SqlBulkCopy_ColumnMapping.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ static void Main()
4747
new SqlBulkCopyColumnMapping("Name", "ProdName");
4848
bulkCopy.ColumnMappings.Add(mapName);
4949

50-
SqlBulkCopyColumnMapping mapMumber =
50+
SqlBulkCopyColumnMapping mapNumber =
5151
new SqlBulkCopyColumnMapping("ProductNumber", "ProdNum");
52-
bulkCopy.ColumnMappings.Add(mapMumber);
52+
bulkCopy.ColumnMappings.Add(mapNumber);
5353

5454
// Write from the source to the destination.
5555
try

doc/samples/SqlBulkCopy_ColumnMappingRemoveAt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void Main()
116116
bulkCopy.DestinationTableName = "dbo.BulkCopyDemoOrderDetail";
117117

118118
// Rather than clearing mappings that are not necessary
119-
// for the next bulk copyo peration, the unneeded mappings
119+
// for the next bulk copy operation, the unneeded mappings
120120
// are removed with the RemoveAt method.
121121
bulkCopy.ColumnMappings.RemoveAt(2);
122122
bulkCopy.ColumnMappings.RemoveAt(1);
Lines changed: 183 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,187 @@
1-
<?xml version="1.0"?>
2-
<docs>
3-
<members name="SqlDataSourceEnumerator">
1+
<docs>
2+
<members name="SqlDataSourceEnumerator">
43
<SqlDataSourceEnumerator>
5-
<summary>Provides a mechanism for enumerating all available instances of SQL Server within the local network.</summary>
6-
<remarks>
7-
<format type="text/markdown"><![CDATA[
8-
9-
## Remarks
10-
SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class exposes this information to the application developer, providing a <xref:System.Data.DataTable> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the `Connection Properties` dialog box, expands the drop-down list containing all the available servers.
11-
12-
]]></format>
13-
</remarks>
14-
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
15-
</SqlDataSourceEnumerator>
16-
<GetDataSources>
17-
<summary>Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances.</summary>
18-
<returns>A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances.</returns>
19-
<remarks>
20-
<format type="text/markdown"><![CDATA[
21-
22-
## Remarks
23-
The table returned by this method contains the following columns, all of which contain strings:
24-
25-
|Column|Description|
26-
|------------|-----------------|
27-
|**ServerName**|Name of the server.|
28-
|**InstanceName**|Name of the server instance. Blank if the server is running as the default instance.|
29-
|**IsClustered**|Indicates whether the server is part of a cluster.|
30-
|**Version**|Version of the server:<br /><br />10.0.xx for SQL Server 2008<br />10.50.x for SQL Server 2008 R2<br />11.0.xx for SQL Server 2012<br />12.0.xx for SQL Server 2014<br />13.0.xx for SQL Server 2016<br />14.0.xx for SQL Server 2017|
31-
32-
> [!NOTE]
33-
> Due to the nature of the mechanism used by <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical.
34-
35-
## Examples
36-
The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window.
37-
38-
[!code-csharp[SqlDataSourceEnumerator.Example#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)]
39-
40-
]]></format>
41-
</remarks>
42-
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
43-
</GetDataSources>
4+
<summary>
5+
Provides a mechanism for enumerating all available instances of SQL Server within the local network.
6+
</summary>
7+
<remarks>
8+
SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> class exposes this information to the application developer, providing a <see cref="T:System.Data.DataTable" /> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the <c>Connection Properties</c> dialog box, expands the drop-down list containing all the available servers.
9+
</remarks>
10+
<seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">
11+
Enumerating Instances of SQL Server
12+
</seealso>
13+
</SqlDataSourceEnumerator>
14+
<GetDataSources>
15+
<summary>
16+
Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances.
17+
</summary>
18+
<returns>
19+
A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances.
20+
</returns>
21+
<remarks>
22+
<para>
23+
The table returned by this method contains the following columns, all of which contain strings:
24+
</para>
25+
<para>
26+
<list type="table">
27+
<listheader>
28+
<term>Column</term>
29+
<description>Description</description>
30+
</listheader>
31+
<item>
32+
<term><b>ServerName</b></term>
33+
<description>Name of the server.</description>
34+
</item>
35+
<item>
36+
<term><b>InstanceName</b></term>
37+
<description>Name of the server instance. Blank if the server is running as the default instance.</description>
38+
</item>
39+
<item>
40+
<term><b>IsClustered</b></term>
41+
<description>Indicates whether the server is part of a cluster.</description>
42+
</item>
43+
<item>
44+
<term><b>Version</b></term>
45+
<description>
46+
Version of the server:
47+
<list type="bullet">
48+
<item>10.0.xx for SQL Server 2008</item>
49+
<item>10.50.x for SQL Server 2008 R2</item>
50+
<item>11.0.xx for SQL Server 2012 </item>
51+
<item>12.0.xx for SQL Server 2014</item>
52+
<item>13.0.xx for SQL Server 2016</item>
53+
<item>14.0.xx for SQL Server 2017</item>
54+
</list>
55+
</description>
56+
</item>
57+
</list>
58+
<note type="note">
59+
Due to the nature of the mechanism used by <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical.
60+
</note>
61+
</para>
62+
</remarks>
63+
<example>
64+
<para>
65+
The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window.
66+
</para>
67+
<!-- SqlDataSourceEnumeratorExample -->
68+
<code language="c#">
69+
using System;
70+
using Microsoft.Data.Sql;
71+
72+
class Program
73+
{
74+
static void Main()
75+
{
76+
// Retrieve the enumerator instance and then the data.
77+
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
78+
System.Data.DataTable table = instance.GetDataSources();
79+
80+
// Display the contents of the table.
81+
DisplayData(table);
82+
83+
Console.WriteLine("Press any key to continue.");
84+
Console.ReadKey();
85+
}
86+
87+
private static void DisplayData(System.Data.DataTable table)
88+
{
89+
foreach (System.Data.DataRow row in table.Rows)
90+
{
91+
foreach (System.Data.DataColumn col in table.Columns)
92+
{
93+
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
94+
}
95+
Console.WriteLine("============================");
96+
}
97+
}
98+
}
99+
</code>
100+
</example>
101+
<seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">
102+
Enumerating Instances of SQL Server
103+
</seealso>
104+
</GetDataSources>
44105
<Instance>
45-
<summary>Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/>, which can be used to retrieve information about available SQL Server instances.</summary>
46-
<value>An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator"/> used to retrieve information about available SQL Server instances.</value>
47-
<remarks>
48-
<format type="text/markdown"><![CDATA[
49-
50-
## Remarks
51-
The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class does not provide a constructor. Use the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.Instance%2A> property to retrieve an instance of the class instead.
52-
53-
[!code-csharp[SqlDataSourceEnumeratorExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)]
54-
55-
## Examples
56-
The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <xref:System.Data.DataTable.Select%2A> method to filter the rows in the table returned by the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources%2A> method.
57-
[!code-csharp[SqlDataSourceEnumeratorVersionExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorVersionExample.cs#1)]
58-
59-
]]></format>
60-
</remarks>
61-
<related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
62-
106+
<summary>
107+
Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> , which can be used to retrieve information about available SQL Server instances.
108+
</summary>
109+
<value>
110+
An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> used to retrieve information about available SQL Server instances.
111+
</value>
112+
<remarks>
113+
<para>
114+
The <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> class does not provide a constructor. Use the <see cref="P:Microsoft.Data.Sql.SqlDataSourceEnumerator.Instance" /> property to retrieve an instance of the class instead.
115+
</para>
116+
<!-- SqlDataSourceEnumeratorExample -->
117+
<code language="c#">
118+
using System;
119+
using Microsoft.Data.Sql;
120+
121+
class Program
122+
{
123+
static void Main()
124+
{
125+
// Retrieve the enumerator instance and then the data.
126+
SqlDataSourceEnumerator instance =
127+
SqlDataSourceEnumerator.Instance;
128+
System.Data.DataTable table = instance.GetDataSources();
129+
130+
// Display the contents of the table.
131+
DisplayData(table);
132+
133+
Console.WriteLine("Press any key to continue.");
134+
Console.ReadKey();
135+
}
136+
137+
private static void DisplayData(System.Data.DataTable table)
138+
{
139+
foreach (System.Data.DataRow row in table.Rows)
140+
{
141+
foreach (System.Data.DataColumn col in table.Columns)
142+
{
143+
Console.WriteLine("{0} = {1}", col.ColumnName, row[col]);
144+
}
145+
Console.WriteLine("============================");
146+
}
147+
}
148+
}
149+
</code>
150+
</remarks>
151+
<example>
152+
<para>
153+
The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <see cref="M:System.Data.DataTable.Select" /> method to filter the rows in the table returned by the <see cref="M:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources" /> method.
154+
</para>
155+
<!-- SqlDataSourceEnumeratorVersionExample -->
156+
<code language="c#">
157+
using System;
158+
using Microsoft.Data.Sql;
159+
160+
class Program
161+
{
162+
static void Main()
163+
{
164+
// Retrieve the enumerator instance, and
165+
// then retrieve the data sources.
166+
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
167+
System.Data.DataTable table = instance.GetDataSources();
168+
169+
// Filter the sources to just show SQL Server 2012 instances.
170+
System.Data.DataRow[] rows = table.Select("Version LIKE '11%'");
171+
foreach (System.Data.DataRow row in rows)
172+
{
173+
Console.WriteLine(row["ServerName"]);
174+
}
175+
176+
Console.WriteLine("Press any key to continue.");
177+
Console.ReadKey();
178+
}
179+
}
180+
</code>
181+
</example>
182+
<seealso href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">
183+
Enumerating Instances of SQL Server
184+
</seealso>
63185
</Instance>
64-
</members>
186+
</members>
65187
</docs>

0 commit comments

Comments
 (0)