You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also, the exception thrown on a failed cast is strange. It says Exception_InvalidOperation_NotAsyncQueryableSource - but there is no async queryable involved in this method. There are other methods higher up in the file where a lot of async stuff is going on. But not this one. Thus my suspicion that this might be a copy and paste thing.
But I am hesitant since this is deep in the core and hasn't been touched for years. And there might be expectations further down the road that need this type check, although this is not visible here.
Additional context
Why am I bothering? I'm currently trying to mock enough PnP types via their interfaces to accomplish something. But those hard type guards (here the check for BaseQueryableDataModelCollection) sabotage this. There are other places like this and they might make my approach fail. But I have not given up, yet.
The text was updated successfully, but these errors were encountered:
Mocking PnP types is not straightforward - at least not using a library like Moq that can only do interfaces. I've already raised a ticket for that: #1373
@wizofaus Yes, I can confirm that. I have something working, but it is not pretty. Appreciate the ticket - seems like we had the same pain at the same time :D
Category
Describe the bug
The issue might be a copy and paste oversight in
QueryableExtensions.cs
. I'm not sure where to put this, so I'm opening a ticket.Here's the method in question:
pnpcore/src/sdk/PnP.Core/QueryModel/Linq/QueryableExtensions.cs
Lines 600 to 614 in d2adbd6
Is this type guard here really needed?
pnpcore/src/sdk/PnP.Core/QueryModel/Linq/QueryableExtensions.cs
Lines 608 to 611 in d2adbd6
Shouldn't this be sufficient instead (which compiles fine):
Also, the exception thrown on a failed cast is strange. It says
Exception_InvalidOperation_NotAsyncQueryableSource
- but there is no async queryable involved in this method. There are other methods higher up in the file where a lot of async stuff is going on. But not this one. Thus my suspicion that this might be a copy and paste thing.So I'm wondering if I can replace this:
with this:
But I am hesitant since this is deep in the core and hasn't been touched for years. And there might be expectations further down the road that need this type check, although this is not visible here.
Additional context
Why am I bothering? I'm currently trying to mock enough PnP types via their interfaces to accomplish something. But those hard type guards (here the check for BaseQueryableDataModelCollection) sabotage this. There are other places like this and they might make my approach fail. But I have not given up, yet.
The text was updated successfully, but these errors were encountered: