Skip to content

RandomAccess.Write methods should perform full writes #55473

@stephentoub

Description

@stephentoub

Every use we have of RandomAccess.Write{Async} now is incorrect, as they all assume the methods will fully write all the data that was supplied. This highlights how error-prone the current design is, with Write not guaranteeing this and instead returning the number of bytes written. We've trained developers with every other Write method in .NET that such methods write all the supplied data (in contrast to Read methods which may not fill the supplied buffer).

We should change the RandomAccess.Write{Async} methods to return void/ValueTask.

If we don't do that, every use of RandomAccess.Write{Async} needs to be fixed, and an analyzer needs to be written that warns when the result isn't consumed.

cc: @adamsitnik, @jeffhandley

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions