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.
This moves the netcore
SqlStatistics
implementation to shared and applies some minor style changes.It also adds a new ref struct called ValueSqlStatisticsScope and a factory method on
SqlStatistics.TimedScope
to create them. This will enable the use of statistics to be made less verbose. Fromto:
The struct is a ref struct for two reasons. 1) it prevents it being included in async closures which is good because async implementations don't start and end in the same method in this library implementation most of the time. 2) is keeps it on the stack in the same way that the original variable was used again preventing leakage.
The reason for the struct being ref and not implementing IDispose despite being used in a using block are noted at the type definition. ref structs can't implement interfaces because interface dispatch requires the variable to be boxed and ref types can't be. The compiler uses pattern matching on ref structs and the dispose interface method so that it can be used in using blocks idiomatically.
The changes to consumers to use the new scope will be done in a separate PR.