NetFabric/NetFabric.Hyperlinq

Issue with `AsAsyncValueEnumerable().SingleAsync`

Mike-E-angelo opened this issue ยท 10 comments

Please see the tests here:
https://github.com/Mike-E-angelo/Stash/blob/master/Hyperlinq.SingleAsync/Hyperlinq.SingleAsync/SingleTests.cs#L13-L32

In it, I have Hyperlinq and System.Linq.Async polling an IAsyncEnumerable created from an EF.CompileQueryAsync call with their respective SingleAsync method.

System.Linq.Async passes while Hyperlinq does not, even though Hyperlinq reports that Option<T>.IsSome is true.

This seems wrong to me. ๐Ÿ˜

Strange! All my tests are passing...๐Ÿง
image
Maybe I'm not checking it correctly.๐Ÿ˜ฐ

FWIW EFCore has thrown me for a couple loops in my world, too. ๐Ÿ˜…

I'm trying to compile your test to reproduce the behavior. I think I have the same packages and namespaces but I'm getting a compile error. It says there's an ambiguous reference for the Where method used in the compiled query.

[CS0121] 
The call is ambiguous between the following methods or properties:
'System.Linq.AsyncEnumerable.Where<TSource>(System.Collections.Generic.IAsyncEnumerable<TSource>, System.Func<TSource, bool>)' 
and 
'System.Linq.Queryable.Where<TSource>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource, bool>>)'

It's strange. Do you know why this is happening?

Wow, that is strange. dotnet clean and dotnet restore --force are my usual go-tos for such oddities.

However, I do not think that will assist you here. Are you compiling the project as-is or are you copy/pasting/transplanting it into a new project?

I'm copy/pasting into my tests project

I see that DbSet<TEntity> implements both IQueriable<TEntity> and IAsyncEnumerable<TEntity>. I now question how it didn't cause problems before.๐Ÿง

Hah, well if it helps, I ended up making a customized Hyperlinq build to work around #372 (before we landed on a solution). It's only accessible on my machine, though. Guess that doesn't help. ๐Ÿ˜

So, long story short, somewhere in time I refactored SingleAsync() to something really stupid. The unit tests didn't catch it because the test returned ValueTask but looks like xUnit awaits only if the method returns Task. That means exceptions were simply ignored. ๐Ÿ˜ฑ

I fixed the return type for all asynchronous tests and found a couple more failing tests. Unfortunately, the assertions on one of them have very strange behavior and I'm still trying to understand what's going on.

Glad to hear of your success, @aalmada. Your pain is my gain. ๐Ÿ˜

Fixed by #381