Skip to content

Conversation

@benrr101
Copy link
Contributor

Description

In the final installment of merging the SqlCommand class, I've mopped up the remaining methods and whatnot into the main SqlCommand partial and a new partial for batch RPC methods (not convinced this is the right idea, but otherwise the main partial becomes way too big, imo). This PR completes the SqlCommand merge (and leaves one class left to merge). As with the other PRs as part of this series, each commit merges a small collection of members. It is recommended to step through the commits one at a time to review.

This PR merges the following members:

  • _cachedAsyncState
  • _cachedMetaData
  • _currentlyExecutingBatch
  • _internalEndExecuteInitiated
  • _reconnectionCompletionSource
  • _rpcArrayOf1
  • _RPCList
  • s_cancelIgnoreFailure
  • AddBatchCommand
  • BuildParamList (combine a bunch of StringBuilder.Append into AppendFormat)
  • CachedAsyncState
  • CachingQueryMetadataPostponed
  • CancelIgnoreFailure
  • CancelIgnoreFailureCallback
  • CheckNotificationStateAndAutoEnlist
  • CheckThrowSNIException (made private, rewritten as ?.)
  • ClearBatchCommand (made private)
  • CountSendableParameters (inverted the logic)
  • CreateLocalCompletionTask
  • DebugForceAsyncWriteDelay
  • DeriveParameters
  • GetBatchCommand
  • GetCommandText
  • GetCurrentBatchCommand
  • GetCurrentBatchIndex
  • GetCurrentParameterCollection
  • GetErrors
  • GetParameterCount
  • GetParameterDirectionFromOleDbDirection
  • GetParameterForOutputValueExtraction (made static, rewrote to remove boolean "found" flag and just return directly)
  • GetRecordsAffected
  • GetResetOptionsString (made static, renamed to GetOptionsResetString)
  • GetRPCObject
  • GetSetStringOptionsString (made static, renamed to GetOptionsSetString)
  • GetStateObject
  • IsProviderRetriable
  • MaxRPCNameLength
  • MetaData
  • NotifyDependency (rewritten as ?.)
  • OnConnectionClosed (rewritten as ?.)
  • OnStatementCompleted
  • ParseAndQuoteIdentifier
  • PreSql2008ProcParamsNames
  • ProcParamsColIndex
  • PutStateObject
  • QuoteIdentifier (using netcore version with Span)
  • RegisterForConnectionCloseNotification
  • ReliablePutStateObject
  • SetBatchRPCMode
  • SetBatchRPCModeReadyToExecute
  • SetUpRPCParameters
  • ShouldSendParameter
  • Sql2008ProcParamsNames
  • SqlNotificationContext
  • ThrowIfReconnectionHasBeenCanceled (inverted if statement, using conditional access)
  • TriggerInternalEndAndRetryIfNecessary
  • UnquoteProcedureName
  • UnquoteProcedurePart
  • ValidateCommand
  • ValidateAsyncCommand
  • VerifyEndExecuteState
  • WaitForAsyncResults
  • WriteBeginExecuteEvent
  • WriteEndExecuteEvent (inverted if and renamed synchronous to isSynchronous)

Issues

More work towards #1261

Testing

CI should validate 😬

* GetRecordsAffected
* GetCurrentBatchCommand
* GetBatchCommand
* GetCurrentBatchIndex
* GetErrors
…cachedMetaData, _reconnectionCompletionSource, _intrnalEndExecuteInitiated, CachingQueryMetadataPostponed, IsProviderRetriable, ProcParamsColIndex, PreSql2008ProcParamsNames, Sql2008ProcParamsNames, MetaData
…ctionClosed (rewritten as ?.), NotifyDependency (rewritten as ?.)
…g), GetResetOptionsString (made static, renamed to GetOptionsResetString), GetCommandText
… remove boolean "found" flag and just return directly)
…Notification, and netfx-only SqlNotificationContext
@benrr101 benrr101 added this to the 7.0.0-preview3 milestone Oct 30, 2025
@benrr101 benrr101 requested a review from a team as a code owner October 30, 2025 17:59
Copilot AI review requested due to automatic review settings October 30, 2025 17:59
@benrr101 benrr101 added the Common Project 🚮 Things that relate to the common project project label Oct 30, 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 consolidates SqlCommand platform-specific code by removing separate SqlCommand.netfx.cs and SqlCommand.netcore.cs files and moving shared implementation into the main SqlCommand.cs file. The changes also create a new SqlCommand.Batch.cs partial file for batch-related functionality and update method signatures for consistency.

Key Changes:

  • Eliminated platform-specific SqlCommand partial files (netfx and netcore)
  • Consolidated shared implementation into main SqlCommand.cs
  • Created SqlCommand.Batch.cs for batch RPC operations
  • Renamed parameter synchronous to isSynchronous in WriteEndExecuteEvent calls

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
SqlCommand.cs Added consolidated implementation including AsyncState, batch fields, and helper methods previously split across platform files
SqlCommand.Batch.cs New partial containing batch RPC mode methods
SqlCommand.Xml.cs Updated parameter name from synchronous to isSynchronous
SqlCommand.Scalar.cs Updated parameter name from synchronous to isSynchronous
SqlCommand.Reader.cs Updated parameter name and added explicit parameter for GetRPCObject and BuildParamList calls
SqlCommand.NonQuery.cs Updated parameter name from synchronous to isSynchronous
SqlCommand.Encryption.cs Added explicit forSpDescribeParameterEncryption parameter to GetRPCObject call
SqlCommand.netfx.cs File deleted - content moved to shared files
SqlCommand.netcore.cs File deleted - content moved to shared files
Microsoft.Data.SqlClient.csproj (both) Removed references to deleted platform files, added reference to SqlCommand.Batch.cs
SqlUtil.cs Added TODO comment for PendingBeginXXXExists method

@priyankatiwari08 priyankatiwari08 self-assigned this Oct 31, 2025
* fAddSeparation => fAddSeparator
* revert order or scale/precision
* value => val
* FIX BUG numChars GetActualScale => GetActualSize
Copy link
Contributor Author

@benrr101 benrr101 left a comment

Choose a reason for hiding this comment

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

Adding annotations for bug fixes

@paulmedynski paulmedynski self-assigned this Nov 4, 2025
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 85.46798% with 118 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.60%. Comparing base (0e8ae37) to head (6e2188e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...lClient/src/Microsoft/Data/SqlClient/SqlCommand.cs 85.29% 106 Missing ⚠️
...t/src/Microsoft/Data/SqlClient/SqlCommand.Batch.cs 76.59% 11 Missing ⚠️
.../src/Microsoft/Data/SqlClient/SqlCommand.Reader.cs 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3738      +/-   ##
==========================================
- Coverage   76.78%   76.60%   -0.19%     
==========================================
  Files         273      272       -1     
  Lines       44914    44189     -725     
==========================================
- Hits        34487    33849     -638     
+ Misses      10427    10340      -87     
Flag Coverage Δ
addons 90.82% <ø> (ø)
netcore 76.74% <85.46%> (-0.05%) ⬇️
netfx 76.18% <84.97%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@benrr101 benrr101 merged commit 2216abd into main Nov 5, 2025
252 checks passed
@benrr101 benrr101 deleted the dev/russellben/merge/sqlcommand-nocer-mopup branch November 5, 2025 00:32
mdaigle pushed a commit that referenced this pull request Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Common Project 🚮 Things that relate to the common project project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants