Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google.Cloud.Firestore package causes ambiguous reference issue when used with EntityFrameworkCore #5216

Closed
aaronwestre opened this issue Jul 30, 2020 · 3 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@aaronwestre
Copy link

This issue is present when referencing the Google.Cloud.Firestore package versions 2.0.0 or 2.1.0

When both Google.Cloud.Firestore and Microsoft.EntityFrameworkCore referenced, there is an ambiguity introduced for Linq-style extension methods such as Where() and OrderBy().

There are work-arounds, but this issue does not exist in earlier versions of the Google.Cloud.Firestore nuget package.

Here is a minimal diagnostic solution:

https://github.com/aaronwestre/sandbox/tree/master/libraries/googlefirestore

@jskeet
Copy link
Collaborator

jskeet commented Jul 30, 2020

Thank you for the report, and for including a complete example. This isn't really caused by the Firestore library directly - it's just because we have a dependency on System.Linq.Async. Even if we didn't include that dependency ourselves, many users would want to add a direct dependency on System.Linq.Async themselves, which would cause the same problem - processing an IAsyncEnumerable is simply much simpler with System.Linq.Async. (And I'd be reluctant to try to remove that dependency anyway, in terms of implementation cost.)

You can see exactly the same issue if you remove the Firestore package reference, and add a direct dependency on System.Linq.Async in your project. (There's extensive discussion of this issue here.)

The workaround of changing the using directive to using static System.Linq.Queryable; is probably the simplest one here.

I'll leave this issue open for a bit in case you have other suggestions, but I think the workaround is your best course of action here.

@jskeet jskeet added the type: question Request for information or clarification. Not an issue. label Jul 30, 2020
@jskeet jskeet self-assigned this Jul 30, 2020
@aaronwestre
Copy link
Author

Thanks for explaining @jskeet that makes sense. The Using static solution you mentioned will work.
What I was particularly confused about was why the ambiguity problem occurs with only a package reference and no "Using Google.Cloud.Firestore" statement anywhere.

@jskeet
Copy link
Collaborator

jskeet commented Jul 30, 2020

Right - and it's precisely because of the extra dependency, rather than any code directly in the library.

Arguably System.Linq.Async should have put its extension methods in a different namespace, but hindsight is always 2020...
I'll close this now as it sounds like we're as close to a solution as possible - i.e. the workaround + explanation.

@jskeet jskeet closed this as completed Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants