Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Shared for TdsEnums.cs #1369

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4dd0249
Merge netfx into netcore for TdsEnums.cs
lcheunglci Oct 21, 2021
850fde5
Move TdsEnums.cs from netcore to shared src and update references in …
lcheunglci Oct 21, 2021
321b8ab
Fix compiler error due to updated relative path to the documentation …
lcheunglci Oct 21, 2021
c03f6fd
Update file to conform to coding style cleaning up IDE0090
lcheunglci Oct 21, 2021
431f1b7
Merge branch 'main' into MergeShared-TdsEnums
lcheunglci Oct 22, 2021
b1d3720
Add test coverage to SqlCollation for FirstSupportedCollationVersion …
lcheunglci Oct 25, 2021
92897eb
Merge branch 'main' into Test-CodeCoverage
lcheunglci Oct 25, 2021
02a65c6
Add tests to SqlConnectionStringBuilder to all properties that throws…
lcheunglci Oct 26, 2021
16c0a64
Add a test cases for SqlClientLogger for code coverage
lcheunglci Oct 26, 2021
60172e4
Add code coverage for SqlClientFactory covering CreateDataSourceEnume…
lcheunglci Oct 26, 2021
296049b
Add tests to SqlParameterCollection for code coverage
lcheunglci Oct 27, 2021
2d57ffe
Add missing code coverage to SqlCommandSet
lcheunglci Oct 29, 2021
dfd6457
Merge branch 'main' into Test-CodeCoverage-part1
lcheunglci Nov 1, 2021
8b5ee21
remove unnecessary asserts
Nov 17, 2021
b0ba491
Update Microsoft.Data.SqlClient.csproj
Nov 17, 2021
7bce454
Merge remote-tracking branch 'upstream/main'
Nov 18, 2021
cd4aea7
Merge remote-tracking branch 'upstream/main'
Nov 23, 2021
2c09672
Merge remote-tracking branch 'upstream/main'
Nov 24, 2021
965ce94
Merge remote-tracking branch 'upstream/main'
Nov 24, 2021
7179deb
Merge remote-tracking branch 'upstream/main'
Nov 25, 2021
e67ad3f
Merge remote-tracking branch 'upstream/main'
Jan 4, 2022
b435719
Merge remote-tracking branch 'upstream/main'
Jan 17, 2022
d0fac74
Merge remote-tracking branch 'upstream/main' into pr/1369
Jan 20, 2022
c379b99
Revert "Merge remote-tracking branch 'upstream/main' into pr/1369"
Jan 20, 2022
4e11176
Merge branch 'main' into pr/1369
Jan 20, 2022
ec1b93e
Merge remote-tracking branch 'upstream/main'
Jan 20, 2022
8a2ce5e
Merge branch 'main' into pr/1369
Jan 20, 2022
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
133 changes: 31 additions & 102 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ This document provides all the necessary details to build the driver and run tes
## Visual Studio Pre-Requisites

This project should be built with Visual Studio 2019+ for the best compatibility. The required set of components are provided in the below file:

- **Visual Studio 2019** with imported components: [VS19Components](/tools/vsconfig/VS19Components.vsconfig)

Once the environment is setup properly, execute the desired set of commands below from the _root_ folder to perform the respective operations:
Expand All @@ -20,11 +19,6 @@ msbuild
# Both .NET Framework (NetFx) and .NET Core drivers are built by default (as supported by Client OS).
```

```bash
msbuild -t:clean
# Cleans all build directories.
```

```bash
msbuild -p:Configuration=Release
# Builds the driver in 'Release' Configuration for `AnyCPU` platform.
Expand All @@ -35,6 +29,11 @@ msbuild -p:Platform=Win32
# Builds the .NET Framework (NetFx) driver for Win32 (x86) platform on Windows in 'Debug' Configuration.
```

```bash
msbuild -t:clean
# Cleans all build directories.
```

```bash
msbuild -t:restore
# Restores Nuget Packages.
Expand Down Expand Up @@ -73,90 +72,37 @@ msbuild -t:BuildTestsNetFx
# Build the tests for the .NET Framework (NetFx) driver in 'Debug' Configuration. Default .NET Framework version is 4.6.1.
```

```bash
msbuild -t:BuildTestsNetCore -p:TestSet=1
# Build a subset of the manual tests. Valid values: '1', '2', '3', 'AE'. Omit to build all tests.
```

## Running Tests

There are 2 ways to run tests, using MsBuild or Dotnet SDK.

### Running from Build.proj

```bash
msbuild -t:RunFunctionalTests
# Run all functional tests for *default* target framework (.NET Core 3.1).
```

```bash
msbuild -t:RunManualTests
# Run all manual tests for *default* target framework (.NET Core 3.1).
```

```bash
msbuild -t:RunTests -p:configuration=Release
# Run both functional and manual tests for *default* target framework (.NET Core 3.1).
```

To specify custom target framework, use `TF` property:

```bash
msbuild -t:RunTests -p:configuration=Release -p:TF=net5.0
msbuild -t:RunTests -p:configuration=Release -p:TF=net48
# Runs tests for specified target framework.
# TargetNetCoreVersion and TargetNetFxVersion are not to be used with TF property, they will take precedence over TF if provided.
```

To capture test and code coverage results in a custom directory:

```bash
msbuild -t:RunTests -p:ResultsDirectory=MyDirectory
# Runs tests with test and code coverage results placed in provided results directory.
# Default results directory is "TestResults".
```

Other properties can be set alongside as needed.

### Running using Dotnet SDK (traditional)

#### Run Functional Tests
## Run Functional Tests

- Windows (`netfx x86`):

```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="Win32" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```

- Windows (`netfx x64`):

```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="x64" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```

- AnyCPU:

Windows (`netcoreapp`):

```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests"
```

Unix (`netcoreapp`):

```bash
dotnet test "src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Unixnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonlinuxtests&category!=nonuaptests"
```

#### Run Manual Tests

### Pre-Requisites for running Manual tests
## Run Manual Tests

### Pre-Requisites for running Manual tests:
Manual Tests require the below setup to run:

- SQL Server with enabled Shared Memory, TCP and Named Pipes Protocols and access to the Client OS.
- Databases "NORTHWIND" and "UdtTestDb" present in SQL Server, created using SQL scripts [createNorthwindDb.sql](tools/testsql/createNorthwindDb.sql) and [createUdtTestDb.sql](tools/testsql/createUdtTestDb.sql). To setup an Azure Database with "NORTHWIND" tables, use SQL Script: [createNorthwindAzureDb.sql](tools/testsql/createNorthwindAzureDb.sql).
- Make a copy of the configuration file [config.default.json](src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json) and rename it to `config.json`. Update the values in `config.json`:
* SQL Server with enabled Shared Memory, TCP and Named Pipes Protocols and access to the Client OS.
* Databases "NORTHWIND" and "UdtTestDb" present in SQL Server, created using SQL scripts [createNorthwindDb.sql](tools/testsql/createNorthwindDb.sql) and [createUdtTestDb.sql](tools/testsql/createUdtTestDb.sql). To setup an Azure Database with "NORTHWIND" tables, use SQL Script: [createNorthwindAzureDb.sql](tools/testsql/createNorthwindAzureDb.sql).
* Make a copy of the configuration file [config.default.json](src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json) and rename it to `config.json`. Update the values in `config.json`:

|Property|Description|Value|
|------|--------|-------------------|
Expand All @@ -179,40 +125,36 @@ Manual Tests require the below setup to run:
|IsAzureSynpase | (Optional) When set to 'true', test suite runs compatible tests for Azure Synapse/Parallel Data Warehouse. | `true` OR `false`|
|MakecertPath | The full path to makecert.exe. This is not required if the path is present in the PATH environment variable. | `D:\\escaped\\absolute\\path\\to\\makecert.exe` |

### Commands to run Manual Tests

- Windows (`netfx x86`):
### Commands to run Manual Tests:

- Windows (`netfx x86`):
```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="Win32" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```

- Windows (`netfx x64`):

- Windows (`netfx x64`):
```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="x64" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```

- Windows (`netfx`):
- AnyCPU:

Windows (`netfx`):
```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetfx" --no-build -v n --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests"
```

- Windows (`netcoreapp`):

Windows (`netcoreapp`):
```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests"
```

- Unix (`netcoreapp`):

Unix (`netcoreapp`):
```bash
dotnet test "src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Unixnetcoreapp" --no-build -v n --filter "category!=nonnetcoreapptests&category!=failing&category!=nonlinuxtests&category!=nonuaptests"
```

## Run A Single Test

```bash
dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Platform="AnyCPU" -p:Configuration="Release" -p:TestTargetOS="Windowsnetcoreapp" --no-build -v n --filter "FullyQualifiedName=Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.CspProviderExt.TestKeysFromCertificatesCreatedWithMultipleCryptoProviders"
```
Expand All @@ -228,12 +170,11 @@ Tests can be built and run with custom "Reference Type" property that enables di

> ************** IMPORTANT NOTE BEFORE PROCEEDING WITH "PACKAGE" AND "NETSTANDARDPACKAGE" REFERENCE TYPES ***************
> CREATE A NUGET PACKAGE WITH BELOW COMMAND AND ADD TO LOCAL FOLDER + UPDATE NUGET CONFIG FILE TO READ FROM THAT LOCATION
>
> ```bash
> ```
> msbuild -p:configuration=Release
> ```

### Building Tests with Reference Type
### Building Tests:

For .NET Core, all 4 reference types are supported:

Expand All @@ -257,19 +198,18 @@ msbuild -t:BuildTestsNetFx -p:ReferenceType=Project
msbuild -t:BuildTestsNetFx -p:ReferenceType=Package
```

### Running Tests with Reference Type
### Running Tests:

Provide property to `dotnet test` commands for testing desired reference type.

```bash
```
dotnet test -p:ReferenceType=Project ...
```

## Testing with Custom TargetFramework (traditional)
## Testing with Custom TargetFramework

Tests can be built and run with custom Target Frameworks. See the below examples.

### Building Tests with custom target framework
### Building Tests:

```bash
msbuild -t:BuildTestsNetFx -p:TargetNetFxVersion=net462
Expand All @@ -283,7 +223,7 @@ msbuild -t:BuildTestsNetCore -p:TargetNetCoreVersion=netcoreapp3.1
# Applicable values: netcoreapp3.1 | net5.0 | net6.0
```

### Running Tests with custom target framework (traditional)
### Running Tests:

```bash
dotnet test -p:TargetNetFxVersion=net462 ...
Expand All @@ -299,31 +239,25 @@ dotnet test -p:TargetNetCoreVersion=netcoreapp3.1 ...

Managed SNI can be enabled on Windows by enabling the below AppContext switch:

`Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows`
**"Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows"**

## Set truncation on for scaled decimal parameters

Scaled decimal parameter truncation can be enabled by enabling the below AppContext switch:

`Switch.Microsoft.Data.SqlClient.TruncateScaledDecimal`
**"Switch.Microsoft.Data.SqlClient.TruncateScaledDecimal"**

## Enabling row version null behavior

`SqlDataReader` returns a `DBNull` value instead of an empty `byte[]`. To enable the legacy behavior, you must enable the following AppContext switch on application startup:

`Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior`
**"Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior"**

## Enabling OS secure protocols preference

TLS 1.3 has been excluded due to the fact that the driver lacks full support. To enable OS preferences as before, enable the following AppContext switch on application startup:

`Switch.Microsoft.Data.SqlClient.EnableSecureProtocolsByOS`

## Suppressing TLS security warning

When connecting to a server, if a protocol lower than TLS 1.2 is negotiated, a security warning is output to the console. This warning can be suppressed on SQL connections with `Encrypt = false` by enabling the following AppContext switch on application startup:

`Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning`
**"Switch.Microsoft.Data.SqlClient.EnableSecureProtocolsByOS"**

## Debugging SqlClient on Linux from Windows

Expand All @@ -332,17 +266,14 @@ For enhanced developer experience, we support debugging SqlClient on Linux from
This project is also included in `docker-compose.yml` to demonstrate connectivity with SQL Server docker image.

To run the same:

1. Build the Solution in Visual Studio
2. Set `docker-compose` as Startup Project
3. Run "Docker-Compose" launch configuration.
4. You will see similar message in Debug window:

```log
Connected to SQL Server v15.00.4023 from Unix 4.19.76.0
The program 'dotnet' has exited with code 0 (0x0).
```

5. Now you can write code in [Program.cs](/src/Microsoft.Data.SqlClient/tests/DockerLinuxTest/Program.cs) to debug SqlClient on Linux!

### Troubleshooting Docker issues
Expand All @@ -352,7 +283,6 @@ There may be times where connection cannot be made to SQL Server, we found below
- Clear Docker images to create clean image from time-to-time, and clear docker cache if needed by running `docker system prune` in Command Prompt.

- If you face `Microsoft.Data.SqlClient.SNI.dll not found` errors when debugging, try updating the below properties in the netcore\Microsoft.Data.SqlClient.csproj file and try again:

```xml
<OSGroup>Unix</OSGroup>
<TargetsWindows>false</TargetsWindows>
Expand All @@ -375,14 +305,13 @@ dotnet test <test_properties...> --collect:"XPlat Code Coverage"

## Run Performance Tests

### Running Performance test project directly
### Running Performance test project directly:

Project location from Root: `src\Microsoft.Data.SqlClient\tests\PerformanceTests\Microsoft.Data.SqlClient.PerformanceTests.csproj`
Configure `runnerconfig.json` file with connection string and preferred settings to run Benchmark Jobs.

```bash
```
cd src\Microsoft.Data.SqlClient\tests\PerformanceTests
dotnet run -c Release -f netcoreapp3.1|net5.0
```

_Only "**Release** Configuration" applies to Performance Tests_
23 changes: 0 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,6 @@
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Stable release 4.0.1] - 2022-01-17

### Added

Added AppContext switch `SuppressInsecureTLSWarning` to allow suppression of TLS security warning when using `Encrypt=false` in the connection string. [#1457](https://github.com/dotnet/SqlClient/pull/1457)

### Fixed

- Fixed Kerberos authentication failure when using .NET 6. [#1411](https://github.com/dotnet/SqlClient/pull/1411)
- Fixed connection failure when using `SqlLocalDB` instance pipe name. [#1433](https://github.com/dotnet/SqlClient/pull/1433)
- Fixed a failure when executing concurrent queries requiring enclaves. [#1451](https://github.com/dotnet/SqlClient/pull/1451)
- Updated obsolete API calls targeting .NET 6. [#1401](https://github.com/dotnet/SqlClient/pull/1401)

## [Stable Release 4.0.0] - 2021-11-18

### Added

- Added missing `SqlClientLogger` class to .NET Core refs and missing `SqlClientLogger.LogWarning` method in .NET Framework refs [#1392](https://github.com/dotnet/SqlClient/pull/1392)

### Changed

- Avoid throwing unnecessary exception when an invalid `SqlNotificationInfo` value is received from SQL Server [#1378](https://github.com/dotnet/SqlClient/pull/1378)
- Updated `Microsoft.Data.SqlClient.SNI` (.NET Framework dependency) and `Microsoft.Data.SqlClient.SNI.runtime` (.NET Core/Standard dependency) version to `v4.0.0` [#1391](https://github.com/dotnet/SqlClient/pull/1391)

## [Preview Release 4.0.0-preview3.21293.2] - 2021-10-20

Expand Down
Loading