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: 2 additions & 1 deletion .config/CredScanSuppressions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"tool": "Credential Scanner",
"suppressions": [
"suppressions":
[
{
"file": "src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TDSServerArguments.cs",
"justification": "Test projects should be skipped"
Expand Down
9 changes: 6 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static

dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
Expand All @@ -80,7 +80,7 @@ dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal

dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case

# Code style defaults
dotnet_sort_system_directives_first = true
Expand Down Expand Up @@ -172,6 +172,9 @@ indent_size = 2

# Shell scripts
[*.sh]
indent_size = 2
end_of_line = lf
[*.{cmd, bat}]

[*.{bat,cmd,ps1}]
indent_size = 2
end_of_line = crlf
6 changes: 1 addition & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5.0.1
with:
# TODO: Update this to .NET 10 once PR #3686 is complete.
# TODO: Replace this with global-json-file once PR #3797 is complete.
dotnet-version: 9.x
dotnet-quality: ga
#global-json-file: global.json
global-json-file: global.json

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
17 changes: 13 additions & 4 deletions BUILDGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This document provides all the necessary details to build the driver and run tests present in the repository.

## .NET SDK

The projects in this repo require the .NET 9.0 SDK to build. Please ensure you
have the latest version of that SDK installed.

Tests and tools may require different .NET Runtimes that may be installed
independently. For example, tests targeting .NET 8.0 will need that runtime
installed.

## 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:
Expand Down Expand Up @@ -112,7 +121,7 @@ Manual Tests require the below setup to run:
|AADSecurePrincipalSecret | (Optional) A Secret defined for a registered application which has been granted permission to the database defined in the AADPasswordConnectionString. | {Secret} |
|AzureKeyVaultURL | (Optional) Azure Key Vault Identifier URL | `https://{keyvaultname}.vault.azure.net/` |
|AzureKeyVaultTenantId | (Optional) The Azure Active Directory tenant (directory) Id of the service principal. | _{Tenant ID of Active Directory}_ |
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
|SupportsIntegratedSecurity | (Optional) Whether or not the USER running tests has integrated security access to the target SQL Server.| `true` OR `false`|
|LocalDbAppName | (Optional) If Local Db Testing is supported, this property configures the name of Local DB App instance available in client environment. Empty string value disables Local Db testing. | Name of Local Db App to connect to.|
|LocalDbSharedInstanceName | (Optional) If LocalDB testing is supported and the instance is shared, this property configures the name of the shared instance of LocalDB to connect to. | Name of shared instance of LocalDB. |
|FileStreamDirectory | (Optional) If File Stream is enabled on SQL Server, pass local directory path to be used for setting up File Stream enabled database. | `D:\\escaped\\absolute\\path\\to\\directory\\` |
Expand All @@ -131,7 +140,7 @@ Manual Tests require the below setup to run:
- Windows (`netfx x86`):

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

Expand All @@ -142,11 +151,11 @@ dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.S
```

- AnyCPU:

Project reference only builds Driver with `AnyCPU` platform, and underlying process decides to run the tests with a compatible architecture (x64, x86, ARM64).

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"
```
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ When targeting .NET on Windows, a package reference to [Microsoft.Data.SqlClient

| Topic | Link to File |
| :---- | :------------- |
| Coding Style | [coding-style.md](/policy/coding-style.md) |
| Best Practices | [coding-best-practices.md](/policy/coding-best-practices.md) |
| Review Process | [review-process.md](/policy/review-process.md) |
| Guidelines for building the driver | [BUILDGUIDE.md](BUILDGUIDE.md) |
| Guidelines for Contributors | [CONTRIBUTING.md](CONTRIBUTING.md) |
| Changelog for all driver releases | [CHANGELOG.md](CHANGELOG.md) |
| Support Policy | [SUPPORT.md](SUPPORT.md) |
| Build Guide | [BUILDGUIDE.md](/BUILDGUIDE.md) |
| Changelog | [CHANGELOG.md](CHANGELOG.md) |
| Code of Conduct | [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) |
| Coding Style | [coding-style.md](/policy/coding-style.md) |
| Contributing | [CONTRIBUTING.md](CONTRIBUTING.md) |
| Copyright Information | [COPYRIGHT.md](COPYRIGHT.md) |
| Review Process | [review-process.md](/policy/review-process.md) |
| Support Policy | [SUPPORT.md](SUPPORT.md) |

## Our Featured Contributors

Expand Down
19 changes: 17 additions & 2 deletions eng/pipelines/common/templates/jobs/ci-build-nugets-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ parameters:
- name: artifactName
type: string
default: Artifacts

- name: platform
type: string
default: $(Platform)

- name: configuration
type: string
default: $(Configuration)
Expand All @@ -44,6 +44,21 @@ jobs:
- ${{ if ne(parameters.prebuildSteps, '') }}:
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration

# Install the .NET SDK.
- template: /eng/pipelines/steps/install-dotnet.yml@self

# When we're performing a Debug build, we still want to try _compiling_ the
# code in Release mode to ensure downstream pipelines don't encounter
# compilation errors. We won't use the Release artifacts for anything else
# though.
- ${{ if eq(parameters.configuration, 'Debug') }}:
- template: ../steps/ci-project-build-step.yml@self
parameters:
platform: ${{ parameters.platform }}
configuration: Release
operatingSystem: Windows
build: all

- template: ../steps/ci-project-build-step.yml@self
parameters:
platform: ${{ parameters.platform }}
Expand Down
31 changes: 16 additions & 15 deletions eng/pipelines/common/templates/jobs/ci-code-coverage-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# pipeline, and uploads them to CodeCov.

parameters:

# True to include debug steps.
- name: debug
type: boolean
Expand Down Expand Up @@ -62,16 +62,17 @@ jobs:
- pwsh: 'Get-ChildItem env: | Sort-Object Name'
displayName: '[Debug] List Environment Variables'

- template: ../steps/ensure-dotnet-version.yml@self
# Install the .NET SDK.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
packageType: sdk
version: '9.0'
debug: ${{ parameters.debug }}

# Install additional dotnet tools.
- pwsh: |
dotnet tool install --global dotnet-coverage
dotnet tool install --global dotnet-reportgenerator-globaltool
displayName: Install dotnet tools

- ${{ each targetFramework in parameters.targetFrameworks }}:
- task: DownloadPipelineArtifact@2
displayName: 'Download Coverage Reports [${{ targetFramework }}]'
Expand Down Expand Up @@ -107,7 +108,7 @@ jobs:
$toProcess = @()

foreach ($file in $files) {
$toProcess += @{
$toProcess += @{
File = $file.FullName
OutputFile = "$OutputDirectoryName\$counter.coveragexml"
}
Expand All @@ -117,10 +118,10 @@ jobs:

$jobs = @()
foreach ($file in $toProcess){
$jobs += Start-ThreadJob -ScriptBlock {
$jobs += Start-ThreadJob -ScriptBlock {
$params = $using:file
& dotnet-coverage merge $($params.File) --output $($params.OutputFile) --output-format xml
}
& dotnet-coverage merge $($params.File) --output $($params.OutputFile) --output-format xml
}
}

Write-Host "Merging started..."
Expand All @@ -133,7 +134,7 @@ jobs:

MergeFiles -InputDirectoryPath "$(netFxDir)" -OutputDirectoryName "coverageNetFxXml"
MergeFiles -InputDirectoryPath "$(netCoreDir)" -OutputDirectoryName "coverageNetCoreXml"

Write-Host "Removing original coverage files..."
Remove-Item $(netFxDir) -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $(netCoreDir) -Recurse -Force -ErrorAction SilentlyContinue
Expand All @@ -150,15 +151,15 @@ jobs:

- pwsh: |
$jobs = @()
$jobs += Start-ThreadJob -ScriptBlock {
$jobs += Start-ThreadJob -ScriptBlock {
& reportgenerator "-reports:coverageNetFxXml\*.coveragexml" "-targetdir:coveragereportNetFx" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netfx\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
}

$jobs += Start-ThreadJob -ScriptBlock {
$jobs += Start-ThreadJob -ScriptBlock {
& reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportNetCore" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\netcore\src;$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\src" "-classfilters:+Microsoft.Data.*"
}

$jobs += Start-ThreadJob -ScriptBlock {
$jobs += Start-ThreadJob -ScriptBlock {
& reportgenerator "-reports:coverageNetCoreXml\*.coveragexml" "-targetdir:coveragereportAddOns" "-reporttypes:Cobertura;" "-assemblyfilters:+microsoft.data.sqlclient.alwaysencrypted.azurekeyvaultprovider.dll" "-sourcedirs:$(Build.SourcesDirectory)\src\Microsoft.Data.SqlClient\add-ons\AzureKeyVaultProvider" "-classfilters:+Microsoft.Data.*"
}

Expand Down Expand Up @@ -186,9 +187,9 @@ jobs:
- ${{if eq(parameters.upload, true)}}:
- pwsh: |
#download Codecov CLI
$ProgressPreference = 'SilentlyContinue'
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://cli.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe

./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetFx\Cobertura.xml" -F netfx
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportNetCore\Cobertura.xml" -F netcore
./codecov --verbose upload-process --fail-on-error -t $(CODECOV_TOKEN) -f "coveragereportAddOns\Cobertura.xml" -F addons
Expand Down
69 changes: 36 additions & 33 deletions eng/pipelines/common/templates/jobs/ci-run-tests-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ parameters:

- name: testSet
type: string

- name: publishTestResults
type: boolean
default: false

- name: configSqlFor
type: string # local, azure, or enclave
default: local

- name: operatingSystem
type: string
default: ''

- name: buildType
displayName: 'Build Type'
default: Project
Expand All @@ -75,8 +75,12 @@ parameters:

# The timeout, in minutes, for this job.
- name: timeout
type: string
default: 90
type: number

# True if this is an ARM64 job.
- name: isArm64
type: boolean
default: false

jobs:
- job: ${{ format('{0}', coalesce(parameters.jobDisplayName, parameters.image, 'unknown_image')) }}
Expand All @@ -98,6 +102,19 @@ jobs:
value: '$(dotnetx86Path)'

steps:

# Install the .NET SDK and Runtimes.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
debug: ${{ parameters.debug }}
${{ if parameters.isArm64 }}:
architecture: arm64
# ARM64 needs to specify slightly different runtime version formats.
# See the install-dotnet template docs for more info.
runtimes: ['8.0', '9.0']
${{ else }}:
runtimes: [8.x, 9.x]

- ${{ if ne(parameters.prebuildSteps, '') }}:
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration

Expand All @@ -117,6 +134,11 @@ jobs:
}
displayName: 'Verify Password'

- ${{ if eq(parameters.buildType, 'Project') }}:
- template: ../steps/ci-project-build-step.yml@self
parameters:
build: allNoDocs

- ${{ if ne(parameters.configProperties, '{}') }}:
- template: ../steps/update-config-file-step.yml@self # update config.json file
parameters:
Expand Down Expand Up @@ -189,7 +211,7 @@ jobs:
net start $svc_name
Get-Service $svc_name | Select-Object -Property Name, StartType, Status
}

displayName: 'Start Sql Browser'
condition: eq(variables['Agent.OS'], 'Windows_NT')
- ${{ elseif eq(parameters.configSqlFor, 'local') }}:
Expand Down Expand Up @@ -247,33 +269,14 @@ jobs:
# it should be acceptable to just install a specific version in all cases.
# @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation
# earlier in the job. There has to be a cleaner way of doing this.
# As it stands now, we install dotnet LTS if we're running netfx tests, and the appropriate netX
# version if we're running netcore tests. Technically LTS is not supported by the UseDotNet task
# but we know we're using install-dotnet since we're on windows (for now ... this will not work
# forever and needs a serious rethinking).
- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
- ${{ if startswith(parameters.targetFramework, 'net4')}}:
- template: ../steps/ensure-dotnet-version.yml
parameters:
installDir: "$(dotnetx86RootPath)"
packageType: "sdk"
usePreview: "false"
version: "LTS"
windowsArchitecture: "x86"
- ${{ else }}:
- script: |
set FrameworkVersion=${{ parameters.targetFramework }}
echo %FrameworkVersion%
set TrimmedFrameworkVersion=%FrameworkVersion:~3%
echo %TrimmedFrameworkVersion%
echo ##vso[task.setvariable variable=netVersionX86]%TrimmedFrameworkVersion%
displayName: "Trim dotnet version"
- template: ../steps/ensure-dotnet-version.yml
parameters:
installDir: "$(dotnetx86RootPath)"
packageType: "sdk"
usePreview: "false"
version: $(netVersionX86)
# Install the .NET SDK and Runtimes for x86.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
architecture: x86
debug: ${{ parameters.debug }}
installDir: $(dotnetx86RootPath)
runtimes: [8.x, 9.x]

- template: ../steps/run-all-tests-step.yml@self
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ stages:
publishTestResults: true
configSqlFor: ${{ config.value.configSqlFor }}
operatingSystem: ${{ config.value.operatingSystem }}
isArm64: ${{ eq(config.value.isArm64, 'true') }}
${{if ne(config.value.configProperties, '{}') }}:
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
${{ if eq(x86TF, targetFramework) }}:
Expand Down Expand Up @@ -97,6 +98,7 @@ stages:
publishTestResults: true
configSqlFor: ${{ config.value.configSqlFor }}
operatingSystem: ${{ config.value.operatingSystem }}
isArm64: ${{ eq(config.value.isArm64, 'true') }}
${{if and(eq(usemanagedSNI, false), ne(config.value.configProperties, '{}')) }}:
${{ each x86TF in config.value.configProperties.x86TestTargetFrameworks }}:
${{ if eq(x86TF, targetFramework) }}:
Expand Down
Loading
Loading