Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add feature detection properties to DbProviderFactory #37872

Merged
merged 1 commit into from
May 30, 2019

Conversation

roji
Copy link
Member

@roji roji commented May 22, 2019

CanCreateDataAdapter, CanCreateCommandBuilder

Closes #35564

@roji roji requested review from divega and ajcvickers May 22, 2019 18:53
@stephentoub stephentoub reopened this May 22, 2019
@stephentoub
Copy link
Member

Ah, GitHub webhooks are down:
https://www.githubstatus.com/
"We deployed a fix and are processing the Webhook backlog. "

@roji roji closed this May 22, 2019
@roji roji reopened this May 22, 2019
@roji roji force-pushed the DbProviderFactoryFeatureDetection branch 2 times, most recently from 4a36a88 to fcbfd2a Compare May 22, 2019 19:47
@roji roji closed this May 22, 2019
@roji roji reopened this May 22, 2019
Copy link

@divega divega left a 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)
Copy link

@divega divega May 30, 2019

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.

Copy link
Member Author

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.

Copy link
Member Author

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)
Copy link

Choose a reason for hiding this comment

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

Idem

Copy link
Member Author

Choose a reason for hiding this comment

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

Idem

src/System.Data.Common/src/System.Data.Common.csproj Outdated Show resolved Hide resolved
CanCreateDataAdapter, CanCreateCommandBuilder

Closes #35564
@roji roji force-pushed the DbProviderFactoryFeatureDetection branch from 76f3b54 to 748a5d8 Compare May 30, 2019 10:51
@roji
Copy link
Member Author

roji commented May 30, 2019

@divega merging this assuming that there's no thread-safety issues - at the very worse we'll fix later.

@roji roji merged commit 60d65af into dotnet:master May 30, 2019
@roji roji deleted the DbProviderFactoryFeatureDetection branch May 30, 2019 13:23
@karelz karelz added this to the 3.0 milestone Jul 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing feature detection properties to DbProviderFactory
5 participants