-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add feature detection properties to DbProviderFactory #37872
Conversation
src/System.Data.Common/src/System/Data/Common/DbProviderFactory.netcoreapp.cs
Outdated
Show resolved
Hide resolved
Ah, GitHub webhooks are down: |
4a36a88
to
fcbfd2a
Compare
src/System.Data.Common/src/System/Data/Common/DbProviderFactory.netcoreapp.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roji Just posted a couple of comments. Assuming you address them this looks good.
{ | ||
get | ||
{ | ||
if (!_canCreateDataAdapter.HasValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code thread safe? I cannot actually think of any race condition that matters, but bringing it up in case others can. E.g. I am not sure if Nullable<T>
assignment is atomic, but I am also not sure it matters because worse case you may end up creating the adapter multiple times, and I don't think the property will return wrong results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment of a reference is atomic, i.e. no value tearing can occur. So yes, at worst multiple data adapters may get created, but I think the code is be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the spec paragraph on reference atomicity:
Reads and writes of the following data types are atomic: bool, char, byte, sbyte, short, ushort, uint, int, float, and reference types. In addition, reads and writes of enum types with an underlying type in the previous list are also atomic. Reads and writes of other types, including long, ulong, double, and decimal, as well as user-defined types, are not guaranteed to be atomic. Aside from the library functions designed for that purpose, there is no guarantee of atomic read-modify-write, such as in the case of increment or decrement.
{ | ||
get | ||
{ | ||
if (!_canCreateCommandBuilder.HasValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
CanCreateDataAdapter, CanCreateCommandBuilder Closes #35564
76f3b54
to
748a5d8
Compare
@divega merging this assuming that there's no thread-safety issues - at the very worse we'll fix later. |
CanCreateDataAdapter, CanCreateCommandBuilder
Closes #35564