Skip to content

Make the experience better around FindAsync and cancellation tokens #35562

Description

@voroninp

What problem are you trying to solve?

FindAsync method has two overloads.

If someone makes a mistake and calls dbSet.FindAsync(id, cancellationToken) instead of dbSet.FindAsync([id], cancellationToken)
wrong overload version will be selected. Compiler won't complain.

Describe the solution you'd like

I believe, it's worth either having an additional prioritized overload:

Task<TEntity?> FindAsync(object id, CancellationToken cancellationToken);

Or just move cancellationToken out of the last component of the array.

Alternatively, it can be an analyzer.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions