Skip to content

Commit 0208d81

Browse files
authored
Refactor and update sample project build. (dotnet#3816)
* Refactor and update sample project build. Scope: Make samples build with nor or minimal changes to actual snippets usied in docs. Added namespaces to organize code and prevent naming conflicts. Used filename as namespace, and for files with names of classes, added "CS" to namespace Adjusted `using` directives to include necessary references to make build pass. Wrapped code snippets in conditional compilation directives for mostly .NET Framework-specific APIs. Made some changes to the .csproj file to enable local "dotnet build" - happy to revert as needed. * Fix indent * Update comment style
1 parent a990f90 commit 0208d81

File tree

228 files changed

+607
-134
lines changed

Some content is hidden

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

228 files changed

+607
-134
lines changed

doc/samples/ApplicationClientIdAzureAuthenticationProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System;
33
using Microsoft.Data.SqlClient;
44

5-
namespace CustomAppIdAuthProviderExample
5+
namespace ApplicationClientIdAzureAuthenticationProvider
66
{
77
public class Program
88
{

doc/samples/AzureKeyVaultProviderExample_2_0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.Data.SqlClient;
77
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
88

9-
namespace Microsoft.Data.SqlClient.Samples
9+
namespace AzureKeyVaultProviderExample_2_0
1010
{
1111
public class AzureKeyVaultProviderExample_2_0
1212
{

doc/samples/AzureKeyVaultProviderWithEnclaveProviderExample.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if false
2+
using System;
23
//<Snippet1>
34
using System.Collections.Generic;
45
using System.Security.Cryptography;
@@ -7,7 +8,7 @@
78
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
89
using Microsoft.IdentityModel.Clients.ActiveDirectory;
910

10-
namespace AKVEnclaveExample
11+
namespace AzureKeyVaultProviderWithEnclaveProviderExample
1112
{
1213
class Program
1314
{
@@ -264,3 +265,4 @@ public CustomerRecord(int id, string fName, string lName)
264265
}
265266
}
266267
//</Snippet1>
268+
#endif

doc/samples/AzureKeyVaultProviderWithEnclaveProviderExample_2_0.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.Data.SqlClient;
77
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
88

9-
namespace AKVEnclaveExample_2_0
9+
namespace AzureKeyVaultProviderWithEnclaveProviderExample_2_0
1010
{
1111
class Program
1212
{

doc/samples/AzureKeyVaultProvider_ColumnEncryptionKeyCacheScope.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using Microsoft.Data.SqlClient;
44
using Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider;
55

6-
namespace AzureKeyVaultProviderExample
6+
namespace AzureKeyVaultProvider_ColumnEncryptionKeyCacheScope
77
{
88
// <Snippet1>
99
class Program

doc/samples/ConnectionStringSettings_RetrieveFromConfig.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
namespace ConnectionStringSettings_RetrieveFromConfig;
2+
3+
using System;
24
// <Snippet1>
35
using System.Configuration;
46

doc/samples/ConnectionStringSettings_RetrieveFromConfigByName.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
namespace ConnectionStringSettings_RetrieveFromConfigByName;
2+
3+
using System;
24
using System.Configuration;
35

46
class Program

doc/samples/ConnectionStringSettings_RetrieveFromConfigByProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
namespace ConnectionStringSettings_RetrieveFromConfigByProvider;
2+
3+
using System;
24
using System.Data;
35
using Microsoft.Data.SqlClient;
46
using System.Configuration;

doc/samples/ConnectionStringsWeb_Encrypt.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using System;
1+
/*
2+
#if NETFRAMEWORK
3+
namespace ConnectionStringsWeb_Encrypt;
4+
5+
using System;
26
using System.Configuration;
37
using System.Web.Configuration;
48
@@ -35,3 +39,5 @@ static void ToggleWebEncrypt()
3539
}
3640
// </Snippet1>
3741
}
42+
#endif
43+
*/

doc/samples/ConnectionStrings_Encrypt.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
namespace ConnectionStrings_Encrypt;
2+
3+
using System;
24
using System.Configuration;
35

46
class Program
@@ -7,7 +9,7 @@ static void Main()
79
{
810
}
911
// <Snippet1>
10-
static void ToggleConfigEncryption(string exeFile)
12+
static void ToggleConfigEncryption(string exeConfigName)
1113
{
1214
// Takes the executable file name without the
1315
// .config extension.

0 commit comments

Comments
 (0)