Skip to content

Commit 5d2d5f4

Browse files
committed
Merge branch 'main' of github.com:dotnet/SqlClient into dev/paul/duplicate-runs
2 parents 2fa8826 + a68e00f commit 5d2d5f4

81 files changed

Lines changed: 4763 additions & 1248 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,59 @@
1-
# editorconfig.org
1+
# IDE text editor configuration:
2+
#
3+
# https://editorconfig.org/
24

3-
# top-most EditorConfig file
5+
# This is the top-most EditorConfig file for our repo.
46
root = true
57

6-
# Default settings:
7-
# A newline ending every file
8-
# Use 4 spaces as indentation
8+
# =================================================================================================
9+
# Default settings for all file types.
10+
911
[*]
10-
insert_final_newline = true
11-
indent_style = space
12-
indent_size = 4
1312

14-
[*.{json,jsonc}]
13+
# Use 2 spaces for indentation.
14+
indent_style = space
1515
indent_size = 2
16+
# tab_width is irrelevant, and will default to indent_size.
1617

17-
[*.{yml,yaml}]
18-
indent_size = 2
18+
# Don't mess with line endings.
19+
end_of_line = unset
20+
21+
# UTF-8 encoding without BOM.
22+
charset = utf-8
23+
24+
# Trim trailing whitespace.
25+
trim_trailing_whitespace = true
26+
27+
# Ensure files end with a newline.
28+
insert_final_newline = true
29+
30+
# We're not enforcing a max line length via tooling because there are legitimate cases for longer
31+
# lines (e.g., long URLs in comments, long strings, etc). However, we recommend keeping lines to
32+
# a maximum of 100 characters for readability.
33+
#
34+
# See: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#max_line_length
35+
#
36+
max_line_length = unset
37+
38+
# =================================================================================================
39+
# Shell scripts typically require line endings that match the platform's native line endings.
40+
41+
# Unix-like systems (Linux, macOS) use LF.
42+
[*.sh]
43+
end_of_line = lf
44+
45+
# Windows uses CRLF.
46+
[*.{bat,cmd,ps1}]
47+
end_of_line = crlf
48+
49+
# =================================================================================================
50+
# C# files.
1951

20-
# C# files
2152
[*.cs]
53+
54+
# We use 4 spaces for C# indentation.
55+
indent_size = 4
56+
2257
# New line preferences
2358
csharp_new_line_before_open_brace = all
2459
csharp_new_line_before_else = true
@@ -75,7 +110,7 @@ dotnet_naming_symbols.static_fields.applicable_kinds = field
75110
dotnet_naming_symbols.static_fields.required_modifiers = static
76111

77112
dotnet_naming_style.static_prefix_style.required_prefix = s_
78-
dotnet_naming_style.static_prefix_style.capitalization = camel_case
113+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
79114

80115
# internal and private fields should be _camelCase
81116
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
@@ -86,7 +121,7 @@ dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
86121
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
87122

88123
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
89-
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
124+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
90125

91126
# Code style defaults
92127
dotnet_sort_system_directives_first = true
@@ -160,16 +195,3 @@ dotnet_diagnostic.CA1416.severity = silent
160195
dotnet_code_quality.CA2100.excluded_type_names_with_derived_types = Microsoft.Data.SqlClient.ManualTesting.Tests.*
161196
dotnet_diagnostic.xUnit1031.severity=none
162197
dotnet_diagnostic.xUnit1030.severity=none
163-
164-
# Xml files
165-
[*.{xml,slnx,proj,csproj,stylecop,resx,ruleset,props,targets,config,nuspec}]
166-
indent_size = 2
167-
168-
# Shell scripts
169-
[*.sh]
170-
indent_size = 2
171-
end_of_line = lf
172-
173-
[*.{bat,cmd,ps1}]
174-
indent_size = 2
175-
end_of_line = crlf

.github/copilot-instructions.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
## 📚 Project Overview
1313
This project is a .NET data provider for SQL Server, enabling .NET applications to interact with SQL Server databases. It supports various features like connection pooling, transaction management, and asynchronous operations.
14-
The project is structured to support both .NET Framework and .NET Core, with platform-specific implementations in `netfx/` and `netcore/` directories.
14+
The project builds from a **single unified project** at `src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj` that multi-targets `net462`, `net8.0`, and `net9.0`. The legacy `netfx/` and `netcore/` directories are being phased out — only their `ref/` folders (which define the public API surface) remain active.
1515
The project includes:
16-
- **Public APIs**: Defined in `ref/` directories for both .NET Framework and .NET Core.
17-
- **Implementations**: Actual code in `src/` directories for both platforms.
16+
- **Public APIs**: Defined in `netcore/ref/` and `netfx/ref/` directories.
17+
- **Implementations**: All source code in `src/Microsoft.Data.SqlClient/src/`.
1818
- **Tests**: Located in the `tests/` directory, covering unit and integration tests.
1919
- **Unit Tests**: Located in `tests/UnitTests/` directory, which includes tests for individual components and methods.
2020
- **Functional Tests**: Located in `tests/FunctionalTests/` directory, which includes tests for various features and functionalities that can be run without a SQL Server instance.
@@ -92,13 +92,15 @@ When a new issue is created, follow these steps:
9292
- If the issue is a feature request, review the proposal and assess its feasibility.
9393
- If the issue is a task, follow the instructions provided in the issue description.
9494
- If the issue is an epic, break it down into smaller tasks or bugs and create sub-issues as needed.
95-
- Cross-reference issue descriptions with code in `src/` folders, especially in `netfx/src/` and `netcore/src/`.
95+
- Cross-reference issue descriptions with code in `src/Microsoft.Data.SqlClient/src/`. Do NOT add code to the legacy `netfx/src/` or `netcore/src/` directories.
9696
- If public APIs are changed, update corresponding `ref/` projects.
9797
- Add or update tests in `tests/` to validate the fix.
9898

9999
### 🧪 Writing Tests
100100
- For every bug fix, ensure there are unit tests and manual (integration) tests that cover the scenario.
101101
- For new features, write tests that validate the functionality.
102+
- Follow a test-driven approach: write failing tests before implementing fixes.
103+
- **Cover both sync and async code paths** where the API exposes both variants (e.g., `Open`/`OpenAsync`, `ExecuteReader`/`ExecuteReaderAsync`). Sync and async implementations often differ internally.
102104
- Use the existing test framework in the `tests/` directory.
103105
- Follow the naming conventions and structure of existing tests.
104106
- Ensure tests are comprehensive and cover edge cases.
@@ -123,12 +125,14 @@ When a new issue is created, follow these steps:
123125
- Add a comment summarizing the fix and referencing the PR
124126

125127
### ⚙️ Automating Workflows
126-
- Auto-label PRs based on folder paths (e.g., changes in `netcore/src``area-netcore`) and whether they add new public APIs or introduce a breaking change.
127-
- Suggest changelog entries for fixes in `CHANGELOG.md`
128+
- Auto-label PRs based on folder paths (e.g., changes in `src/Microsoft.Data.SqlClient/src/``Area\SqlClient`, changes in `tests/``Area\Testing`) and whether they add new public APIs or introduce a breaking change.
129+
- Suggest release note entries for fixes by updating files under `release-notes/` or by using the `release-notes` prompt (instead of editing `CHANGELOG.md` directly).
128130
- Tag reviewers based on `CODEOWNERS` file
129131

130132
## 🧠 Contextual Awareness
131-
- Always check for platform-specific differences between `netfx` and `netcore`
133+
- All source code is in `src/Microsoft.Data.SqlClient/src/`. Do NOT add code to legacy `netfx/src/` or `netcore/src/` directories.
134+
- Only `ref/` folders in `netcore/ref/` and `netfx/ref/` remain active for defining the public API surface.
135+
- Check for platform-specific differences using file suffixes (`.netfx.cs`, `.netcore.cs`, `.windows.cs`, `.unix.cs`) and conditional compilation (`#if NETFRAMEWORK`, `#if NET`, `#if _WINDOWS`, `#if _UNIX`).
132136
- Respect API compatibility rules across .NET versions
133137
- Do not introduce breaking changes without proper justification and documentation
134138
- Use the `doc/` directory for any new documentation or updates to existing documentation
@@ -138,9 +142,9 @@ When a new issue is created, follow these steps:
138142

139143
## Constraints
140144
- Do not modify the `CODEOWNERS` file directly.
141-
- Do not modify the `CHANGELOG.md` file directly.
145+
- Do not modify `CHANGELOG.md` unless executing a release workflow (see `release-notes` prompt).
142146
- Do not close issues without a fix or without providing a clear reason.
143147

144148
## 📝 Notes
145149
- Update policies and guidelines in the `policy/` directory as needed based on trending practices and team feedback.
146-
- Regularly review and update the `doc/` directory to ensure it reflects the current state of the project.
150+
- Regularly review and update the `doc/` directory to ensure it reflects the current state of the project.
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
---
2+
applyTo: "eng/pipelines/**/*.yml"
3+
---
4+
# Azure DevOps Pipelines Guide
5+
6+
## Overview
7+
8+
This repository uses Azure DevOps Pipelines for CI/CD. The pipeline configurations are located in `eng/pipelines/`.
9+
10+
**ADO Organization**: sqlclientdrivers
11+
**ADO Project**: ADO.NET
12+
13+
## Pipeline Structure
14+
15+
```
16+
eng/pipelines/
17+
├── abstractions/ # Abstractions package pipelines
18+
├── azure/ # Azure package pipelines
19+
├── common/ # Shared templates
20+
│ └── templates/
21+
│ ├── jobs/ # Reusable job templates
22+
│ ├── stages/ # Reusable stage templates
23+
│ └── steps/ # Reusable step templates
24+
├── jobs/ # Top-level job definitions
25+
├── libraries/ # Shared variable definitions
26+
├── stages/ # Stage definitions
27+
├── steps/ # Step definitions
28+
├── variables/ # Variable templates
29+
├── akv-official-pipeline.yml # AKV provider official/signing build
30+
├── dotnet-sqlclient-ci-core.yml # Core CI pipeline (reusable)
31+
├── dotnet-sqlclient-ci-package-reference-pipeline.yml # CI with package references
32+
├── dotnet-sqlclient-ci-project-reference-pipeline.yml # CI with project references
33+
├── dotnet-sqlclient-signing-pipeline.yml # Package signing pipeline
34+
├── sqlclient-pr-package-ref-pipeline.yml # PR validation (package ref)
35+
├── sqlclient-pr-project-ref-pipeline.yml # PR validation (project ref)
36+
└── stress-tests-pipeline.yml # Stress testing
37+
```
38+
39+
## Main Pipelines
40+
41+
### CI Core Pipeline (`dotnet-sqlclient-ci-core.yml`)
42+
Reusable core CI pipeline consumed by both project-reference and package-reference CI pipelines. Configurable parameters:
43+
44+
| Parameter | Description | Default |
45+
|-----------|-------------|---------|
46+
| `targetFrameworks` | Windows test frameworks | `[net462, net8.0, net9.0, net10.0]` |
47+
| `targetFrameworksUnix` | Unix test frameworks | `[net8.0, net9.0, net10.0]` |
48+
| `referenceType` | Project or Package reference | Required |
49+
| `buildConfiguration` | Debug or Release | Required |
50+
| `useManagedSNI` | Test with managed SNI | `[false, true]` |
51+
| `testJobTimeout` | Test job timeout (minutes) | Required |
52+
| `runAlwaysEncryptedTests` | Include AE tests | `true` |
53+
| `enableStressTests` | Include stress test stage | `false` |
54+
55+
### CI Reference Pipelines
56+
- `dotnet-sqlclient-ci-project-reference-pipeline.yml` — Full CI using project references (builds from source)
57+
- `dotnet-sqlclient-ci-package-reference-pipeline.yml` — Full CI using package references (tests against published NuGet packages)
58+
59+
### PR Validation Pipelines
60+
- `sqlclient-pr-project-ref-pipeline.yml` — PR validation with project references
61+
- `sqlclient-pr-package-ref-pipeline.yml` — PR validation with package references
62+
63+
These pipelines trigger on pull requests and run a subset of the full CI matrix to provide fast feedback.
64+
65+
### Official/Signing Pipeline (`dotnet-sqlclient-signing-pipeline.yml`)
66+
Signs and publishes NuGet packages. Used for official releases. Requires secure service connections and key vault access for code signing.
67+
68+
### AKV Official Pipeline (`akv-official-pipeline.yml`)
69+
Builds and signs the `Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider` add-on package separately from the main driver. Uses 1ES pipeline templates for compliance.
70+
71+
### Stress Tests Pipeline (`stress-tests-pipeline.yml`)
72+
Optional pipeline for long-running stress and endurance testing. Enabled via `enableStressTests` parameter in CI core.
73+
74+
## Build Stages
75+
76+
1. **build_abstractions_package_stage**: Build and pack abstractions
77+
2. **build_mds_akv_packages_stage**: Build main driver and AKV packages
78+
3. **build_azure_package_stage**: Build Azure extensions package
79+
4. **stress_tests_stage**: Optional stress testing
80+
5. **run_tests_stage**: Execute all test suites
81+
82+
## Test Configuration
83+
84+
### Test Sets
85+
Tests are divided into sets for parallelization:
86+
- `TestSet=1` — First partition of tests
87+
- `TestSet=2` — Second partition
88+
- `TestSet=3` — Third partition
89+
- `TestSet=AE` — Always Encrypted tests
90+
91+
### Test Filters
92+
Tests use category-based filtering. The default filter excludes both `failing` and `flaky` tests:
93+
```
94+
category!=failing&category!=flaky
95+
```
96+
97+
Category values:
98+
- `nonnetfxtests` — Excluded on .NET Framework
99+
- `nonnetcoreapptests` — Excluded on .NET Core
100+
- `nonwindowstests` — Excluded on Windows
101+
- `nonlinuxtests` — Excluded on Linux
102+
- `failing` — Known permanent failures (excluded from all runs)
103+
- `flaky` — Intermittently failing tests (quarantined, run separately)
104+
105+
### Flaky Test Quarantine in Pipelines
106+
Quarantined tests (`[Trait("Category", "flaky")]`) run in **separate pipeline steps** after the main test steps. This ensures:
107+
- Main test runs are **not blocked** by intermittent failures
108+
- Flaky tests are still **monitored** for regression or resolution
109+
- Code coverage is **not collected** for flaky test runs
110+
- Results appear in pipeline output for visibility
111+
112+
The quarantine steps are configured in:
113+
- `eng/pipelines/common/templates/steps/build-and-run-tests-netcore-step.yml`
114+
- `eng/pipelines/common/templates/steps/build-and-run-tests-netfx-step.yml`
115+
- `eng/pipelines/common/templates/steps/run-all-tests-step.yml`
116+
117+
### Test Timeout
118+
All test runs use `--blame-hang-timeout 10m` (configured in `build.proj`). Tests exceeding 10 minutes are killed and reported as failures.
119+
120+
### SNI Testing
121+
The `useManagedSNI` parameter controls testing with:
122+
- Native SNI (`false`) - Windows native library
123+
- Managed SNI (`true`) - Cross-platform managed implementation
124+
125+
## Variables
126+
127+
### Build Variables (`ci-build-variables.yml`)
128+
Common build configuration:
129+
- Package versions
130+
- Build paths
131+
- Signing configuration
132+
133+
### Runtime Variables
134+
Set via pipeline parameters or UI:
135+
- `Configuration` - Debug/Release
136+
- `Platform` - AnyCPU/x86/x64
137+
- `TF` - Target framework
138+
139+
## Creating Pipeline Changes
140+
141+
### Adding New Test Categories
142+
1. Add category attribute to tests: `[Category("newcategory")]`
143+
2. Update filter expressions in test job templates
144+
3. Document category purpose in test documentation
145+
146+
### Adding New Pipeline Parameters
147+
1. Define parameter in appropriate `.yml` file
148+
2. Add to parameter passing in calling templates
149+
3. Document in this file
150+
151+
### Modifying Build Steps
152+
1. Changes should be made in template files for reusability
153+
2. Test changes locally when possible
154+
3. Submit as PR - validation will run
155+
156+
## Best Practices
157+
158+
### Template Design
159+
- Use templates for reusable definitions
160+
- Pass parameters explicitly (avoid global variables)
161+
- Use descriptive stage/job/step names
162+
163+
### Variable Management
164+
- Use template variables for shared values
165+
- Use pipeline parameters for per-run configuration
166+
- Avoid hardcoding versions (use Directory.Packages.props)
167+
168+
### Test Infrastructure
169+
- Ensure tests are properly categorized
170+
- Handle test configuration files properly
171+
- Use test matrix for cross-platform coverage
172+
173+
## Troubleshooting
174+
175+
### Common Issues
176+
1. **Test failures due to missing config**: Ensure `config.json` exists
177+
2. **Platform-specific failures**: Check platform exclusion categories
178+
3. **Timeout issues**: Increase `testJobTimeout` parameter
179+
180+
### Debugging Pipelines
181+
- Enable debug mode via `debug: true` parameter
182+
- Use `dotnetVerbosity: diagnostic` for detailed output
183+
- Check build logs in Azure DevOps
184+
185+
## Security Considerations
186+
187+
- Pipelines use service connections for artifact publishing
188+
- Signing uses secure key vault integration
189+
- Sensitive configuration should use pipeline secrets
190+
- Never commit credentials in pipeline files
191+
192+
## Related Documentation
193+
194+
- [BUILDGUIDE.md](../../BUILDGUIDE.md) - Local build instructions
195+
- [Azure DevOps Documentation](https://learn.microsoft.com/azure/devops/pipelines/)

0 commit comments

Comments
 (0)