Why does CreateAsync return Task<IEnumerable<TItem>>?
See original GitHub issuereturn Task<IEnumerable<TItem>>
while
returns ValueTask<IEnumerable<TItem>>
any reasons why they are not alike?
Also, notice the xml doc is not up to date. Happy to send a PR if wanted. It seems though changing the interface return type is a breaking change so I wanted to ask first
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
UserManager.CreateAsync .Success always returns false
UserManager.CreateAsync returns an IdentityResult that would also contain any errors why the action was not successful.
Read more >UserManager<TUser>.CreateAsync Method
Creates the specified user in the backing store with no password, as an asynchronous operation.
Read more >override createAsync in IdentityUserAppService not executed ...
Im trying custom create user by admin in abp,so override createAsync in IdentityUserAppService,but this part of code not executed
Read more >Issues in Optimizely when creating large number of users ...
Hi, We are trying to create around 100k users in Optimizely programmatically but the issue is can't able to run _userManager.CreateAsync ...
Read more >ASP.NET Core - Create a User
This Async method returns a result that tells us if the instance was a success or a failure and if it failed, it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
😍🤩Glad my rambling was helpful
I understand that reasons why when doing concurrent processing with WhenAll you need to return Task. I was more wondering from the interface perspective. Because aren’t you technically now leaking implementation details to the interface definition?
It seems that the return type is basically bound to the implementation that happens to fan out
CreateAsync
but from an interface definition perspective, you could also argue that an implementor of the interface could implement this interface internally by using a transactional batch and then there would be mostly synchronous calls to the batch and oneExecuteAsync
call which then would allow to essentially return ValueTask again and thus benefit from the value task pooling.I think my feedback is that it is suprising that the concurrency implementation detail suddendly leaks into the interface definition. From the perspective of the implementation you could also return a ValueTask and then still internally do a when all and be compliant with the Value Task returning API like the following
then you allow implementors of the interface to decide how the handle the creation of the multiple items and you are no longer “leaking” the implemenation of the DefaultRepository into the interface definition.