Skip to content

add: byte stream support.#296

Open
akeit0 wants to merge 2 commits intomainfrom
fix-file-loading
Open

add: byte stream support.#296
akeit0 wants to merge 2 commits intomainfrom
fix-file-loading

Conversation

@akeit0
Copy link
Copy Markdown
Collaborator

@akeit0 akeit0 commented Apr 5, 2026

This PR makes files.lua pass.

But need new ILuaByteStream inteface.

@akeit0 akeit0 requested review from Copilot and nuskey8 and removed request for Copilot April 5, 2026 07:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds byte-stream support to Lua file loading so loadfile/LoadFileAsync can distinguish binary vs text chunks, and expands the test suite around BOM handling, load modes, I/O buffering, and read sequencing.

Changes:

  • Introduces ILuaByteStream and makes LuaStream implement it, enabling byte-based reads.
  • Updates LuaStateExtensions.LoadFileAsync and LuaState.Load(ReadOnlySpan<byte>) to enforce mode (b/t) and support binary chunk loading.
  • Adds new NUnit tests for BOM stripping, mode rejection behavior, _ENV handling, io.read sequencing, and line buffering.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Lua.Tests/LuaTests.cs Adjusts files.lua patching to account for BOM handling and skips unsupported binary/string.dump coverage.
tests/Lua.Tests/LoadFileModeTests.cs Adds tests asserting LoadFileAsync rejects chunks when mode disallows their type.
tests/Lua.Tests/LoadFileBomTests.cs Adds tests ensuring UTF-8 BOM at start of file is ignored by loadfile.
tests/Lua.Tests/LoadEnvironmentTests.cs Adds tests for explicit nil environments via load/loadfile.
tests/Lua.Tests/IoReadSequenceTests.cs Adds regression test for io.read returning earlier results even when a later fixed read hits EOF.
tests/Lua.Tests/IoBufferingTests.cs Adds test for line-buffered writes only becoming visible after newline.
src/Lua/LuaStateExtensions.cs Updates LoadFileAsync to optionally use byte-stream reads and enforce mode rules.
src/Lua/LuaState.cs Enforces mode rules in Load(ReadOnlySpan<byte>) for binary/text chunks.
src/Lua/IO/LuaStream.cs Implements ILuaByteStream and updates buffering logic for setvbuf("line") / "no".
src/Lua/IO/ILuaByteStream.cs Adds the new byte-stream interface.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants