This document provides guidance for AI coding agents working with the Microsoft.Data.SqlClient repository.
Before making changes, agents should be aware of:
| File | Purpose |
|---|---|
| README.md | Project overview |
| BUILDGUIDE.md | Build and test instructions |
| CONTRIBUTING.md | Contribution guidelines |
| .github/copilot-instructions.md | Copilot-specific instructions |
The .github/instructions/ directory contains comprehensive guides:
| Guide | Coverage |
|---|---|
| architecture.instructions.md | Project structure, unified project model |
| tds-protocol.instructions.md | TDS protocol, packet handling |
| ado-pipelines.instructions.md | Azure DevOps CI/CD pipelines |
| onebranch-pipeline-design.instructions.md | OneBranch multi-product pipeline design spec |
| testing.instructions.md | Test framework, running tests |
| connection-pooling.instructions.md | Connection pool internals |
| api-design.instructions.md | Public API design principles |
| features.instructions.md | Feature reference, keywords |
| documentation.instructions.md | Documentation and samples |
| external-resources.instructions.md | Docs links, version matrix, external references |
| ado-work-items-markdown.instructions.md | Ensure Azure DevOps work item descriptions are Markdown and preserve newlines |
This repository provides reusable prompts in .github/prompts/ for common maintainer workflows. Use these to guide agents through multi-step operations.
For code reviews, use the sqlclient-code-review skill and its references/policies
from protected host configuration or an established trusted base repository and
immutable SHA, not the reviewed PR's head/worktree. If that trusted copy is missing
or inaccessible, report the blocker rather than loading review guidance from the checkout.
| Prompt | Purpose |
|---|---|
| fix-bug.prompt.md | Diagnose and fix a bug with tests and documentation |
| implement-feature.prompt.md | Plan and implement a new feature end-to-end |
| triage-issue.prompt.md | Triage a new GitHub issue with labeling and categorization |
| perf-optimization.prompt.md | Investigate and implement performance improvements |
| release-notes.prompt.md | Generate release notes for a specific milestone |
| update-build-pipelines.prompt.md | Modify Azure DevOps CI/CD pipeline configuration |
- Cross-Platform Compatibility: Code must work on .NET Framework 4.6.2+ and .NET 10.0+
- Backward Compatibility: No breaking changes without proper deprecation
- Test-First Development: All changes require tests
- Security by Default: Secure defaults, no credential logging
- Protocol Compliance: Follow MS-TDS specifications
- Performance Optimization: Use pooling, async, efficient allocations
- Observability: EventSource tracing, meaningful errors
When using shell/terminal tools, follow these rules strictly:
- Treat non-zero terminal exit codes as immediate failures to investigate; do not continue as if the command succeeded.
- If a bash session exits, assume it is dead and start a new command/session; do not wait for additional output from that session.
- After any command expected to gather data, verify output was actually returned before proceeding.
- If command execution failed, report the failure clearly and retry with a corrected command instead of waiting.
- Avoid
set -ein this automation context; prefer single-purpose commands with explicit follow-up checks so failures are visible without killing the shell unexpectedly. - Prefer shorter command batches over long chained scripts when collecting evidence; this makes bash exits easier to detect and recover from.
- Interactive agents, working under direct human guidance, may create and use branches under
dev/<name>/when the human specifies or approves the namespace and branch name (e.g.,dev/paul/aot/phase-1.1). - Autonomous agents, working without interactive human direction, must create branches under
dev/automation/(e.g.,dev/automation/fix-connection-timeout). - Do not create branches outside these namespaces or directly under
dev/.
Read the testing guide before writing or changing tests. These rules are mandatory for unit tests and should be strongly considered for manual and functional tests, even when nearby older tests use different conventions:
- Use commented Arrange, Act, Assert, Cleanup sections in that order. Act and Assert are required; include Arrange only for needed setup and Cleanup only for special teardown. Within a section with multiple groups of steps, comment each group to explain what happens and, when unclear, why.
- For theory data that cannot use
[InlineData], use[MemberData], never[ClassData], and declare the data member's return type asTheoryData<...>. - Keep each unit test file focused on the class it is named for:
TdsParserTeststestsTdsParser. - Name unit tests
{MethodName}_{Input}_{ExpectedOutput}, without the tested class name; for example,ExecuteReader_NullParameter_ThrowsorExecuteReader_ValidParameters_ReturnsReader. - Mirror the tested source file's folder structure under
UnitTests/. For example,src/Microsoft/Data/SqlClient/Parser/TdsParser.csmaps totests/UnitTests/Microsoft/Data/SqlClient/Parser/TdsParserTests.cswithin the SqlClient project. - Put utilities used only by unit tests in
tests/UnitTests/Utilities/. - Put utilities shared across test projects in TestCommon (
tests/Common/); fuzz, stress, and performance test projects are excluded from this sharing rule. - Split separate scenarios into separate tests. Do not use switches or flags to turn one test into multiple behaviors, including sync/async switches. Theories may vary inputs for one behavior.
- Write and run beneficial tests: exercise the intended product behavior, assert meaningful outcomes, and ensure the assertions would detect a regression. Check test results to confirm the intended tests actually ran; skipped tests and zero matches do not establish coverage.
- Understand the issue from the bug report
- Locate relevant code in
src/Microsoft.Data.SqlClient/src/(do NOT modify legacynetcore/src/ornetfx/src/) - Check
.github/instructions/features.instructions.mdfor existing AppContext switches (including failover compatibility switches) before introducing behavior changes - Write a failing test that reproduces the issue
- Implement the fix
- Ensure all tests pass
- Update documentation if behavior changes
- Review the feature specification
- Plan the implementation (see
implement-featureprompt) - Update reference assemblies if adding public APIs
- Implement with tests
- Add samples to
doc/samples/ - Do not edit
CHANGELOG.mddirectly; instead, add a suggested release-note entry (per.github/copilot-instructions.md) in the PR description or via the release-notes workflow/prompt.
- Add to
SqlConnectionStringBuilder - Update connection string parser
- Default to backward-compatible value
- Add tests for new keyword
- Document in feature reference
- Reference MS-TDS specification
- Update
TdsEnums.csfor new constants - Implement in
TdsParser.csand related files - Test against multiple SQL Server versions
- Consider backward compatibility
- Profile the issue using benchmarks or traces
- Identify allocation hotspots (see
perf-optimizationprompt) - Apply patterns:
ArrayPool<T>,Span<T>, static/cached instances, source generation - Verify no regressions with existing tests
See the policy/ directory for:
- coding-best-practices.md - Programming standards
- coding-style.md - Code formatting guidelines
- review-process.md - PR review requirements
- Check existing tests for usage patterns
- Reference similar implementations in the codebase
- Consult the Microsoft Docs for API behavior specifications
- For protocol questions, refer to MS-TDS open specifications
This document is automatically loaded as context for AI agents working in this repository.