Browse Source

MDS Review Process (#3349)

pull/3357/head
Paul Medynski 2 months ago
committed by GitHub
parent
commit
832e8da279
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 34
      .github/PULL_REQUEST_TEMPLATE/pr-template.md
  2. 2
      CONTRIBUTING.md
  3. 22
      README.md
  4. 102
      policy/coding-best-practices.md
  5. 0
      policy/coding-style.md
  6. 74
      policy/review-process.md

34
.github/PULL_REQUEST_TEMPLATE/pr-template.md

@ -0,0 +1,34 @@
## Description
Provide a summary of the changes being introduced. Important topics to cover
include:
- Description of the functionality.
- API changes, backwards compatibility, deprecations, etc.
- Documentation, localization.
- Bug fixes.
- Code hygiene, refactoring, improvements.
- Engineering processes (CI, pipelines, test coverage)
High quality descriptions will lead to a smoother review experience.
## Issues
Link to any relevant issues, bugs, or discussions (e.g., "Closes \#123", "Fixes
issue \#456").
## Testing
Describe the automated tests (unit, integration) you created or modified.
Provide justification for any gap in automated testing. List any manual testing
steps that were performed to ensure the changes work. 
## Guidelines
Please review the contribution guidelines before submitting a pull request:
- [Contributing](/CONTRIBUTING.md)
- [Code of Conduct](/CODE_OF_CONDUCT.md)
- [Best Practices](/policy/coding-best-practices.md)
- [Coding Style](/policy/coding-style.md)
- [Review Process](/policy/review-process.md)

2
CONTRIBUTING.md

@ -24,7 +24,7 @@ Please do:
- **DO** report each issue as a new issue (but check first if it's already been reported) - **DO** report each issue as a new issue (but check first if it's already been reported)
- **DO** respect Issue Templates and provide detailed information. It will make the process to reproduce the issue and provide a fix faster. - **DO** respect Issue Templates and provide detailed information. It will make the process to reproduce the issue and provide a fix faster.
- **DO** provide a minimal repro app demonstrating the problem in isolation will greatly speed up the process of identifying and fixing problems. - **DO** provide a minimal repro app demonstrating the problem in isolation will greatly speed up the process of identifying and fixing problems.
- **DO** follow our [coding style](coding-style.md) (C# code-specific) when working on a Pull Request.
- **DO** follow our [coding style](/policy/coding-style.md) (C# code-specific) when working on a Pull Request.
- **DO** give priority to the current style of the project or file you're changing even if it diverges from the general guidelines. - **DO** give priority to the current style of the project or file you're changing even if it diverges from the general guidelines.
- **DO** consider cross-platform compatibility and supportability for all supported SQL and Azure Servers and client configurations. - **DO** consider cross-platform compatibility and supportability for all supported SQL and Azure Servers and client configurations.
- **DO** include tests when adding new features. When fixing bugs, start with adding a test that highlights how the current behavior is broken. - **DO** include tests when adding new features. When fixing bugs, start with adding a test that highlights how the current behavior is broken.

22
README.md

@ -4,7 +4,7 @@
# Microsoft SqlClient Data Provider for SQL Server # Microsoft SqlClient Data Provider for SQL Server
Microsoft.Data.SqlClient is a .NET data provider for [Microsoft SQL Server]([url](https://aka.ms/sql)) and the [Azure SQL]([url](https://aka.ms/azure_sql)) family of databases. It grew from a union of the two System.Data.SqlClient components which live independently in .NET Framework and .NET Core. Going forward, support for new SQL Server and Azure SQL features will only be implemented in Microsoft.Data.SqlClient.
Microsoft.Data.SqlClient is a .NET data provider for [Microsoft SQL Server]([url](https://aka.ms/sql)) and the [Azure SQL]([url](https://aka.ms/azure_sql)) family of databases. It grew from a union of the two System.Data.SqlClient components which live independently in .NET and .NET Framework. Going forward, support for new SQL Server and Azure SQL features will only be implemented in Microsoft.Data.SqlClient.
## Supportability ## Supportability
@ -27,7 +27,9 @@ When targeting .NET on Windows, a package reference to [Microsoft.Data.SqlClient
| Topic | Link to File | | Topic | Link to File |
| :---- | :------------- | | :---- | :------------- |
| Coding Style | [coding-style.md](coding-style.md) |
| 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 building the driver | [BUILDGUIDE.md](BUILDGUIDE.md) |
| Guidelines for Contributors | [CONTRIBUTING.md](CONTRIBUTING.md) | | Guidelines for Contributors | [CONTRIBUTING.md](CONTRIBUTING.md) |
| Changelog for all driver releases | [CHANGELOG.md](CHANGELOG.md) | | Changelog for all driver releases | [CHANGELOG.md](CHANGELOG.md) |
@ -72,7 +74,7 @@ Check out our [FAQ](https://github.com/dotnet/SqlClient/wiki/Frequently-Asked-Qu
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://www.microsoft.com/en-us/msrc/definition-of-a-security-vulnerability), please report it to us as described below.
## Reporting Security Issues ## Reporting Security Issues
@ -86,13 +88,13 @@ You should receive a response within 24 hours. If for some reason you do not, pl
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly. This information will help us triage your report more quickly.

102
policy/coding-best-practices.md

@ -0,0 +1,102 @@
# Coding Best Practices
This document describes some typical programming pitfalls and best practices
related to C# and .NET.  It will grow and change as we encounter new situations
and the codebase evolves.
## Correctness & Business Logic
- Validate if the code adheres to what it is supposed to do. Compare the
implementation with the specification and ask questions, to get clarity.
- Employ `Debug.Assert()` statements to validate program state, but never
rely on them to control program flow. For example, `Debug.Assert()` must
never be used to validate input.
## Memory / Resource Management
- C# – Rent large buffers from ArrayPool<T> and return them promptly to
cut down on heap allocations and improve throughput. Have the buffers been
returned to the pool? Will they be returned if an exception is thrown?
- Prefer Span<T> for stack allocated buffers.
- Double check the depth of the call stack if using async/await. Stack depth of
unwinding async/await state-machines of more than 3 calls can cause
performance issues.
- Resource cleanup Dispose(), Close(), or the equivalent to release files,
sockets, database connections, and other external resources.
## Error Handling & Reliability 
- Prefer return values to throwing exceptions.  Returns are strongly typed and
checked by the compiler. Consider patterns like
`bool TryXYZ(..., out Result result)` instead of `Result XYZ(...)`.
- Exceptions should be reserved for exceptional circumstances, like constructor
failure or out-of-memory, where the calling code stands little chance of
recovering. Routine, expected error conditions should not be expressed as
exceptions.
- Document all exceptions that may be thrown from an API.
- Do not let undocumented exceptions escape from an API.
- Be permissive with what you accept, and strict with what you produce.
- Consider Constrained Execution Regions for .NET Framework implementations.
## Async, Concurrency & Thread Safety (if applicable)
- Avoid calling Task.Result, Task.Wait() or Task.GetAwaiter().GetResult(). If
needed, exercise extreme caution. These can cause deadlocks.
- When awaiting a task with the await keyword, always use
Task.ConfigureAwait(false) so that the task continuation may run on any thread
rather than marshalling back to the original calling thread.
## Backward Compatibility
- Someone will always depend on your undocumented behaviour.  It is just as much
an API promise as explicitly documented behaviour.
- Use language features to deprecate/obsolete APIs, and to issue warnings for
notable upcoming breaking changes.
## Security Considerations
- Never log passwords, secrets, or connection strings with credentials.
- Validate inputs to avoid SQL injection, even on metadata calls.
- Are there any user inputs going into SQL or shell commands directly?
- Are secrets being logged or exposed in stack traces?
- Are TLS/certificate settings handled safely and explicitly?
- Are we sending unbounded data streams to server prior to authentication e.g.
in feature extensions?
## Performance & Scalability 
- For major features or large PRs, always run the internal performance
benchmarks or performance testsuite to determine if the new changes are
causing any performance degradation.
## Observability (Logging / Tracing / Metrics) 
- Error messages should contain enough context to understand the state of the
program and find the source code responsible for emitting it.
- Instrument changes for metrics/tracing/logging to aid future field diagnosis,
debugging, and app behaviour analysis.
## Unit Tests / Integration
- Have you added unit tests and integration tests?
- Unit tests should not depend on external resources.  Code under unit test
should permit mocked resources to be provided/injected.
- Avoid tests that rely on timing.
## Configuration & Feature Flags 
- Is the change considered a breaking change? If breaking change is not
avoidable, has a Configuration/Feature flag been introduced for customers to
revert to old behavior?
## Code Coverage expectations
- Ideally these expectations  should be codified into scanning tool
configuration that lives in the repo.
- Specific metrics will be chosen based on realistic analysis of existing
coverage and will be re-evaluated as testing matures.
## Pipeline runs
- Is the CI passing? If not, then have you looked at the failures, and found the
cause for failures?

0
coding-style.md → policy/coding-style.md

74
policy/review-process.md

@ -0,0 +1,74 @@
# Review Process
This document describes guidelines and responsibilities for participants of
pull request reviews.
## Author Responsibilities
- **Describe the problem up front.** In the PR description, include a concise,
self-contained summary of the issue being solved and link to relevant specs,
issues, or discussions. For open-source PRs, capture the context in one clear
section so reviewers don’t have to sift through comment threads.
- **Ship code with tests.** Submit unit and integration tests alongside the
implementation to demonstrate expected behavior and prevent regressions.
- **Instrument for production.** Add meaningful tracing or logging so the
changes can be monitored and debugged once deployed.
- **Keep PRs focused.** Split large or mixed-purpose changes into smaller,
logical units (e.g., separate refactors from feature work).
- **Highlight important changes.**  Add your own comments to the diffs to call
out important changes that require extra scrutiny, or to explain a change
whose inclusion isn't self-evident.
- **Choose your reviewers.**  The author should assign an initial set of
required and optional reviewers.  Reviewers may change their role later after
discussing with the author.
- **Any open issue blocks completion.**  Do not complete a review with open
issues.  All issues must be resolved by the reviewer who created them, or
another reviewer delegate.  Do not override tooling that prevents completion.
- **Do not resolve reviewer issues.**  Only reviewers should resolve reviewer
issues.  Ideally the creator of the issue should resolve it, but reviewers may
close each other's issues under certain circumstances.
## Reviewer Responsibilities
- **Understand what you’re approving.** If anything is unclear, ask questions.
Require in-code comments that explain why a solution exists - not just what it
does. PR comments are not a substitute for code comments.
- **Read the full PR description.** Context matters; don’t skip it.
- **Review the changes, not the design.** A code review is not the time to
review a design choice.  If you think an alternative design would be better,
discuss with the author and team, and ask for a new PR if the new design is
implemented instead.
- **Demand tests.** If appropriate tests are missing, request them. When
testing truly isn’t feasible, insist on a documented rationale.
- **Note partial reviews.** If you reviewed only part of the code, say so in
the PR.
- **Delegate wisely.** If you cannot complete your reviewer role's
responsibilities, delegate to another subject-matter expert.
- **Own your approval.** You are accountable for the quality and correctness of
the code you sign off on.
- **Block completion on all open issues.** Any issue you open against a review
must be resolved to your satisfaction before a review may complete.
Resolution may include new code changes to fix a problem, new in-code
documentation to explain something, or a discussion within the PR itself.
- **Do not close other reviewer's issues.** The reviewer who created an issue
should be the one to resolve it.  Exceptions include explicit delegation or
OOTO absences.  Any delegations should be discussed with the team.
- **Never rubber-stamp.** Trust the author but verify the code - always conduct
a real review.
- **Review in a timely manner.**  Reviewers should aim to perform a review
within 2 business days of receiving the initial request, and 1 business day
for follow-up changes.  Reviewing a PR is higher priority than most other
tasks.
## Backwards Compatibility Awareness
Subtle changes may have backwards compatibility implications.  Below are some of
the code changes and side-effects to watch out for:
- Do these changes force updates to existing integration tests - a sign they may
introduce a breaking change?
- Will these changes modify the public API’s behavior in a way that could break
existing applications when they upgrade to the new binaries?
- For any non-security, breaking changes that impact customers, have we provided
an opt-out - such as a connection-string flag, AppContext switch, or similar
setting - that lets users revert to the previous behavior?
Loading…
Cancel
Save