neoCLR

IMPLEMENTATION NOTE · OPEN DESIGN

Read and write a small text file.

The current File helpers read and write UTF-8 text synchronously, with an explicit byte limit and typed Result errors.

Development after Preview 8 · September 21, 2026. The current API uses System.Storage, renamed from System.IO. The example requires a matching development build; published Preview 8 still uses the old namespace. File behavior is unchanged and the API remains open to feedback.

Bounded UTF-8 file I/O in Raven.

func Load(path: string, limit: int) -> Result<string, FileReadError> {
    let text = File.ReadAllText(path, limit)?
    return Ok(text)
}

Load propagates a read failure or returns the decoded String. The complete sample creates or replaces neoclr-file-demo.txt in its working directory, reads it back, and checks that an oversized write leaves the previous content intact. Run it in a disposable sample directory.

Complete executable sample → · VS Code setup →

Behavior and limits.

.NET File names are familiar; explicit byte limits and Result outcomes are different contracts. These are host file operations, not a complete filesystem abstraction. Writes are not transactional or guaranteed atomic, and errors can occur after opening a file.

Detailed contract and comparisons →

PROPOSED DIRECTION

Where we’re heading.

The System.Storage namespace leaves room for storage providers. A future Storage model would include StorageItem, File, Directory and storage providers, with Task-based file operations. None of that model is implemented by this namespace rename. A FileSystem capability and separate readable, writable and seekable stream contracts are proposed. They could support testing and virtual namespaces, but require lifetime, scheduling and error policies. Current whole-file helpers do not implement those proposals.

Related proposals and open questions →

What would you try?

Bring a small use case, the code you tried and the behavior you expected. Which part of this contract helps, and which part should change?

Share feedback on GitHub ↗