Simplify internal async callback code#2091
Merged
David-Engel merged 4 commits intodotnet:mainfrom Aug 9, 2023
Merged
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2091 +/- ##
==========================================
+ Coverage 70.67% 70.69% +0.01%
==========================================
Files 306 306
Lines 61995 62071 +76
==========================================
+ Hits 43816 43878 +62
- Misses 18179 18193 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Member
cheenamalhotra
left a comment
There was a problem hiding this comment.
I will take a closer look sometime soon, but just sharing a few thoughts I had when I started looking into it.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs
Show resolved
Hide resolved
David-Engel
approved these changes
Aug 4, 2023
Contributor
David-Engel
left a comment
There was a problem hiding this comment.
This definitely improves code readability. Thanks for the submission!
cheenamalhotra
approved these changes
Aug 9, 2023
edwardneal
added a commit
to edwardneal/SqlClient
that referenced
this pull request
May 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In previous PR's I optimized async paths to use state objects and cached delegates to static functions to avoid instance delegate invocations. The c# compiler now implements delegate caching directly for static lambdas and produces easier to read code. This PR converts the existing manual delegate caching to the compiler provided method.
It converts ExecuteXmlReaderAsync to use the cached context object pattern.
It converts ExecuteNonQueryAsync to use a cached context object, it was already using a context object so this just adds caching.
I suggest reviewing each commit individually. Side by side diffs make the changes look more confusing than they really are. Netcore only because when sqlcommand is merged I expect the netcore versions to be used since they're generally better for perf.