Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Method

ReadToEnd

func ReadToEnd(maxUtf8Bytes: int) -> Task<Result<string, TextReadError>>

Declaring type: StreamReader
Module: System.IO
Assembly: System.Runtime.dll
Source file: StreamReader.rvn

Implements TextReader.ReadToEnd

Returns a Task; await completion. Reads remaining text subject to a UTF-8 output-byte bound.

Parameters

Name Type Description
maxUtf8Bytes Int32 Nonnegative maximum UTF-8 bytes in the returned text. StreamReader accepts up to 65536; zero succeeds only at EOF. Source reads are separately bounded by the same number plus one overflow byte.

Return value

Task<Result<String, TextReadError>>

The completed task contains: The remaining text, or TextReadError.

Remarks

StreamReader checks Closed before bounds and reads no input for invalid bounds. It consumes at most one byte beyond the bound to distinguish exact-bound EOF. Errors can leave input advanced; there is no rollback. Decoding is strict and preserves a BOM. Development ReadToEnd rejects malformed completed input during chunk processing, without waiting for EOF; an underlying chunk can already have advanced the cursor beyond the malformed byte. An over-limit read is reported before decoding that read. Truncated final sequences return InvalidUtf8. Failure returns no partial text and does not roll back input. Repeated reading at EOF returns empty text. Host execution and allocation budgets still apply.