Skip to content

Polish C# scripting: ReadFile, cs_exec, frame budget#222

Draft
timfox wants to merge 1 commit into
mainfrom
cursor/csharp-scripting-polish-921a
Draft

Polish C# scripting: ReadFile, cs_exec, frame budget#222
timfox wants to merge 1 commit into
mainfrom
cursor/csharp-scripting-polish-921a

Conversation

@timfox
Copy link
Copy Markdown
Owner

@timfox timfox commented May 21, 2026

Summary

Completes the C# scripting polish pass on top of the initial Mono integration (USE_CSHARP, default OFF).

Changes

  • IdTech3.Engine.ReadFile: VFS read via internal call; blocks absolute paths, .., and backslashes (same policy as JavaScript readFile).
  • cs_exec: One-shot compile/run of console statements wrapped in Game.Script.Init without replacing the assembly loaded by cs_reload.
  • cs_frameCallbackBudgetMs: Soft per-frame cap for Game.Script.Frame plus the synthetic frame event (skips event dispatch when budget exceeded; 0 = unlimited).
  • Docs/tests: docs/CSHARP.md, scripting overview in docs/ARCHITECTURE.md, demo IdTech3.Engine.cs sync, tests/scripts/test_csharp_scripting.sh guards.

Validation

  • ./tests/scripts/test_csharp_scripting.sh — PASS
  • ./scripts/compile_engine.sh vulkan — PASS
  • ./scripts/compile_engine.sh vulkan csharp — PASS (when Mono dev packages installed)

Usage

cs_exec IdTech3.Engine.Print("hello from cs_exec");
cs_reload scripts/csharp/demo_hooks.cs

cs_autoInit remains 0 by default; CI unchanged.

Open in Web Open in Cursor 

- Add IdTech3.Engine.ReadFile internal call with safe relative VFS paths
- Add cs_exec one-shot compile/run (Game.Script.Init wrapper, no assembly swap)
- Enforce cs_frameCallbackBudgetMs for Frame + frame event dispatch
- Register cs_exec in cmd.c; sync demo IdTech3.Engine.cs
- Document scripting overview in ARCHITECTURE.md and update CSHARP.md/tests

Co-authored-by: Tim Fox <timfox@outlook.com>
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