Add string overloads to DbDataReader.Get*() as extensions#36123
Add string overloads to DbDataReader.Get*() as extensions#36123roji merged 1 commit intodotnet:masterfrom TheBlueSky:dbdatareader-string-overloads-extensions
Conversation
|
The build failures are all from crypto tests, nothing in your work is failing as far as I can see, the link from the logs is here https://mc.dot.net/#/user/dotnet-bot/pr~2Fdotnet~2Fcorefx~2Frefs~2Fpull~2F36123~2Fmerge/test~2Ffunctional~2Fcli~2F/20190318.13 |
|
If you click on the send to helix step a log type window will pop out from the right. if you read that there's a bit of text that says "results will be available from" followed by a url, ctrl+click that url and you'll get to the page I linked. |
|
Thanks, @Wraith2. |
roji
left a comment
There was a problem hiding this comment.
I think the partial added to DbDataReader in the #35211 can now be removed.
Apart from this (and the extra partial to be added, noted below), LGTM.
@divega and/or @ajcvickers could you take a look and sign off as well please?
src/System.Data.Common/src/System/Data/Common/DbDataReaderExtensions.cs
Outdated
Show resolved
Hide resolved
|
@roji, what is |
This indeed seems like a leftover - it contains a backwards compatibility shim for the new resultset metadata API introduced in .NET Core 1.x. But I'm not sure I have the whole story and it's probably better to not go into it right now. Since it does contain a DbDataReaderExtensions class, it seems to make sense to a partial to it, in case it does get compiled in some scenario. (BTW thanks for the super quick turnaround on the PR!) |
src/System.Data.Common/src/System/Data/Common/DbDataReaderExtensions.netcoreapp.cs
Outdated
Show resolved
Hide resolved
src/System.Data.Common/tests/System/Data/Common/DbDataReaderTest.netcoreapp.cs
Outdated
Show resolved
Hide resolved
src/System.Data.Common/src/System/Data/Common/DbDataReaderExtensions.netcoreapp.cs
Outdated
Show resolved
Hide resolved
src/System.Data.Common/src/System/Data/Common/DbDataReaderExtensions.netcoreapp.cs
Outdated
Show resolved
Hide resolved
@saurabh500 I know this was some time ago, but do you have any insights on DbDataReaderExtensions.Facade.cs? |
|
The |
@divega The facade was added so that while using .Net Core and targeting a .Net framework version which didn't have the new API, the facade would kick in, and use the DataTable to construct IDBColumnSchema. It was added for backward compat. |
@saurabh500 the confusing part is there are actually two DbDataReaderExtensions defining
As @Wraith2 wrote above, I'm guessing the 2nd was meant for .NET Framework, since in .NET Core pre-2.0 DataTable didn't exist. However, I'm not sure if there's any sense in keeping this in the corefx repo today. |
|
@roji re DbDataReaderExtensions.Facade.cs, can you please create a separate issue so that we remember to follow up? Talked to @bricelam the other day about the possibility of using the code there as a fallback if IDbColummnSchemaGenerator isn’t implemented, but obviously we need to understand things better. |
|
@divega opened #36235 |
|
@TheBlueSky, @roji, @ajcvickers & everyone, I spoke with @terrajobst in person:
|
|
For 1, for the same reason that having the same name doesn't matter much for extension methods (we do it in EF Core) it also doesn't matter much what the name is at all. So I say let's go with |
|
.NET Framework and UAP builds fail. They pass when I ran them manually on my machine (works on my machine™)... I used the flow I found in https://github.com/dotnet/corefx/wiki/Build-and-run-tests; e.g., clean, rebuild, running the tests. What am I missing? |
|
The tests are trying to find the extensions and failing, the tests need to be netcoreapp specific. |
|
@Wraith2, not as per the last decision from @divega (#36123 (comment)) |
|
only if you run the tests on that framework which isn't the default, I think the updated docs are here: https://github.com/dotnet/corefx/issues/35661 |
|
@Wraith2 So I am guessing the command to build just the netcorapp tests should be: |
|
netcoreapp is the default (since we're working on corefx afterall…) so if you just want netcoreapp you don't have to specify the framework. But yes that looks right to me. In my PR's I don't change surface area and I'm quite careful about switching in of netcore/netstandard specific functionality so I rely on the build -allconfigurations to pick up compile problems like this and then the CI to flag test issues. |
|
@Wraith2 Thanks a lot (I am in the process of warming up to my first PR, I hope) - and how do you mark tests "netcoreapp only" ? |
|
I found this: |
|
Usually you'd put framework specific things in suffixed files, so in this PR you'll see that there's a The conditions you've found are a different axis, they're the platform axis not the framework axis. Still valid and useful but not for what you're looking for right now. |
I ran the build for each platform (.NET Core, .NET Framework, and UAP) in both Debug and Release configurations, then built and ran the test for each platform; however, I have not got that error (cannot convert from 'string' to 'int'). The CI builds are, obviously, doing something I'm not doing, but cannot figure it out. Also, this does not answer @divega comment that this should not be .NET Core specific. |
|
Ok, then the question becomes why aren't those overloads being found? |
|
@TheBlueSky @Wraith2, sorry, but my understanding of how this code is built and shipped has evolved a bit in the last few days. See Hence, I agree that the new tests need to somehow only run on .NET Core. Maybe the way new methods on DbProviderFactories are tested can serve as an example of the pattern to follow, since the situation of those new methods is very similar to what we are adding here. Otherwise, we can ask for assistance from someone with more experience on working on this repo. |
|
|
||
| namespace System.Data | ||
| { | ||
| public static partial class DataReaderExtensions |
There was a problem hiding this comment.
Sorry about all the back and forth on this, but the partial no longer seems necessary here.
|
@divega @ajcvickers re the naming of the extensions class, like @ajcvickers I don't think this is extremely important. However, even if a second DbDataReaderExtensions class would be confusing, IMHO it's still the best option, as it maintains the rule that extension classes are named exactly after the classes they extend, plus an "Extensions" suffix. DataReaderExtensions.cs seems even a bit more confusing as a second DbDataReaderExtensions, but if the latter really isn't an option, then DataCommonExtensions sounds somewhat better. In any case I don't have very strong feelings about this, and DataReaderExtensions is also acceptable. As to the CI test failures I'm just as mystified as the rest of you - @TheBlueSky affirms that they pass locally, and they logically should be working on other TFMs as the extension are supposed to appear there. @divega some assistance may help. |
|
Re the name of the sponsor class, I think either is fine. DbDataReader is the base class. In ADO.NET the pattern is that all derived classes have a different prefix. The extensions technically target the base class, but in practice apply to all DataReaders. I will try to get someone that can provide guidance. |
|
@divega, I looked at @divega and @roji, what is the final name for the class now? :) |
|
@TheBlueSky my understanding is that this is what we should do. We are effectively only adding this new extension methods to .NET Core. However, you may want to wait a bit to avoid more back and forth. @roji is following up internally to make sure our understanding is complete. |
|
@divega, sure, I'll wait. In the meantime, do you mind explaining to me if this repo is only for .NET Core, what does building against .NET Framework and UAP means? And what purpose does it serve? |
|
@TheBlueSky I like the name you already have, DataReaderExtensions, for the reasons I explained above. Unless someone else feels strongly that that shouldn’t be the name, no need to change it. I will let @roji close the loop on what configurations the code is built for, and what configurations are tested when he has finished collecting that information. |
|
@TheBlueSky agree that we should condition out the tests for netcoreapp only. As the naming has been agreed upon, I think after this we can finally merge. I admit I don't have a full understanding on exactly what is going on - here's an explanation from @ericstj on the CI builds and the different configurations:
I'm still not sure in what sense the local uap build is different from the CI one. However, in any case the lack of tests will not affect the availability of the APIs in any way, so we should just move ahead with this. |
|
@roji, thanks a lot. I'll rebase my local branch and push the changes later today. To help me understand how thing are going on here, do you think you can answer my following question?
|
My understanding of how corefx exactly works is very partial (am also a bit of a newcomer to the repo). If I understand things correctly, netfx is no longer actually built from this repo (at least not the System.Data.Common part) - this is a leftover from days where the inbox System.Data.Common was replaced with out-of-band packages. However, a build config does exist for netfx so we need to take it into account (possibly for other parts outside of System.Data.Common). The repo does build for UAP, but I'm not sure exactly how everything interacts and why the tests are failing. |
Also, add `GetFieldValueAsync<T>()` and `IsDBNullAsync()` string overloads. Addresses #31595
roji
left a comment
There was a problem hiding this comment.
Re-approve from my side, let's wait for a green light from either @divega or @ajcvickers and then I'll merge.
|
@roji Green light! 🚥 |
|
Thanks again @TheBlueSky! You had a lot of patience on this one 😆 |
|
Hooray! You're welcome, @roji; it was fun :) |
|
+1 Thanks @TheBlueSky for the contribution and for your patience! |

Also, add
GetFieldValueAsync<T>()andIsDBNullAsync()string overloads.Addresses #31595