Skip to content

Refactor and update sample project build.#3816

Merged
mdaigle merged 4 commits intodotnet:mainfrom
ErikEJ:build-snippets
Feb 20, 2026
Merged

Refactor and update sample project build.#3816
mdaigle merged 4 commits intodotnet:mainfrom
ErikEJ:build-snippets

Conversation

@ErikEJ
Copy link
Contributor

@ErikEJ ErikEJ commented Nov 29, 2025

Scope: Make samples build with nor or minimal changes to actual snippets used in docs.

Added namespaces to organize code and prevent naming conflicts. Used filename as namespace, and for files with names of classes, added "CS" to namespace

Adjusted using directives to include necessary references to make build pass.

Wrapped code snippets in conditional compilation directives for mostly .NET Framework-specific APIs.

Made some changes to the .csproj file to enable local "dotnet build" - happy to revert as needed.

I will comment on any other type of changes made to a few samples.

Unsure about the sample for Microsoft.SqlServer.Server, but can revert these if needed. (and not build them)

Related to issue #3725

Scope: Make samples build with nor or minimal changes to actual snippets usied in docs.

Added namespaces to organize code and prevent naming conflicts. Used filename as namespace, and for files with names of classes, added "CS" to namespace

Adjusted `using` directives to include necessary references to make build pass.

Wrapped code snippets in conditional compilation directives for mostly  .NET Framework-specific APIs.

Made some changes to the .csproj file to enable local "dotnet build" - happy to revert as needed.
Copilot AI review requested due to automatic review settings November 29, 2025 13:25
@ErikEJ ErikEJ requested a review from a team as a code owner November 29, 2025 13:25
@github-project-automation github-project-automation bot moved this to To triage in SqlClient Board Nov 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors sample code files to enable building with minimal changes to documentation snippets. The primary changes include adding namespace declarations to prevent naming conflicts and wrapping .NET Framework-specific code in conditional compilation directives.

  • Adds unique namespaces to all sample files, typically using the filename as the namespace name (with "CS" suffix for files with class names)
  • Wraps .NET Framework-specific code in #if NETFRAMEWORK directives
  • Adds missing using directives required for compilation
  • Updates project configuration to support multi-targeting (net8.0 and net462)

Reviewed changes

Copilot reviewed 228 out of 228 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
TransactionIsolationLevels.cs Changed namespace from generic to filename-based
SqlVectorExample.cs Added namespace, missing using directives, and changed async to sync method call
SqlUserDefinedType*.cs Added namespaces and changed namespace references from Microsoft.Data.SqlClient.Server to Microsoft.SqlServer.Server
SqlRowUpdatingEventArgs.cs, SqlParameterCollection_*.cs, SqlDataAdapter_SelectCommand.cs, etc. Wrapped .NET Framework-specific code in conditional compilation directives
SqlDataReader_DataDiscoveryAndClassification.cs Fixed typo in Console method name
SqlDataAdapter_Properties.cs Removed nested namespace and unnecessary using directive
SqlCommand_ExecuteNonQuery_SP_DML.cs Removed unused variable declaration
SqlDataAdapter_SPIdentityReturn.cs Changed Int to int for type consistency
SqlConfigurableRetryLogic_SqlCommand.cs Added wrapper classes to separate code snippets
SqlClientEventSource.cs, SqlClientDiagnosticCounter.cs Added namespaces and missing using directives
RegisterCustomKeyStoreProvider_*.cs Added namespaces, using directives, and stub implementations for custom providers
SqlUserDefinedTypeAttribute_Type1.cs Fixed typo in Convert.Toint method calls
Microsoft.Data.SqlClient.Samples.csproj Added multi-targeting configuration and package reference
ConnectionStrings_Encrypt.cs Renamed parameter for clarity

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

This pull request has been marked as stale due to inactivity for more than 30 days.

If you would like to keep this pull request open, please provide an update or respond to any comments. Otherwise, it will be closed automatically in 7 days.

@github-actions github-actions bot added the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Jan 5, 2026
@ErikEJ
Copy link
Contributor Author

ErikEJ commented Jan 5, 2026

@paulmedynski Do you have time to respond?

@paulmedynski paulmedynski removed the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Jan 5, 2026
@paulmedynski
Copy link
Contributor

@dotnet/sqlclientdevteam - Can we get some more eyes on this and respond to some of my comments?

@cheenamalhotra cheenamalhotra moved this from In progress to In review in SqlClient Board Jan 13, 2026
@cheenamalhotra
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@cheenamalhotra cheenamalhotra added Waiting for Customer ⏳ Issues/PRs waiting for user response/action. and removed Waiting for Customer ⏳ Issues/PRs waiting for user response/action. labels Jan 13, 2026
@github-actions
Copy link

This pull request has been marked as stale due to inactivity for more than 30 days.

If you would like to keep this pull request open, please provide an update or respond to any comments. Otherwise, it will be closed automatically in 7 days.

@github-actions github-actions bot added the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Feb 12, 2026
@cheenamalhotra
Copy link
Member

cheenamalhotra commented Feb 18, 2026

/azp run

cheenamalhotra
cheenamalhotra previously approved these changes Feb 18, 2026
@dotnet dotnet deleted a comment from azure-pipelines bot Feb 18, 2026
@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@cheenamalhotra cheenamalhotra removed the Stale The Issue or PR has become stale and will be automatically closed shortly if no activity occurs. label Feb 18, 2026
@cheenamalhotra cheenamalhotra added this to the 7.0.0-preview4 milestone Feb 18, 2026
@ErikEJ
Copy link
Contributor Author

ErikEJ commented Feb 19, 2026

@paulmedynski @cheenamalhotra Comments addressed

I stayed on .NET 8 for now, as using .NET 10 caused package downgrade errors

This is the resolved version numbers in latest main, curious about 6.1.2 and not 6.1.4 ?

image

@paulmedynski
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@mdaigle mdaigle merged commit 0208d81 into dotnet:main Feb 20, 2026
294 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in SqlClient Board Feb 20, 2026
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (fbf872e) to head (f5f94d8).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #3816   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants