Skip to content

[#14] Address Copilot review follow-ups - #124

Merged
SkowronskiAndrew merged 1 commit into
mainfrom
issue14-followup
Jul 27, 2026
Merged

[#14] Address Copilot review follow-ups#124
SkowronskiAndrew merged 1 commit into
mainfrom
issue14-followup

Conversation

@SkowronskiAndrew

@SkowronskiAndrew SkowronskiAndrew commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #122 (merged), addressing the Copilot review comments that arrived after merge. All changes are small robustness/accuracy improvements to the UTF-8 path marshalling work; no behavior change for normal use.

Changes

  • CreateArchive: marshal only the first count entries of sourceFiles/aliases (what the native call actually consumes) instead of every array element, and validate count against the array lengths up front. Previously a count larger than the arrays could make native read past the marshalled data.
  • GetArchiveNode comment: clarify that the concern is Windows specific, slim down.

Testing

  • dotnet test UnityFileSystem.Tests — non-ASCII path tests green (10/10 across versions); full build clean.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Follow-up robustness and accuracy tweaks to the UTF-8 path marshalling work in the UnityFileSystem native interop layer and its non-ASCII-path test helpers.

Changes:

  • Tightens CreateArchive marshalling to allocate/marshal only the first count entries and validates count against input array lengths.
  • Clarifies platform behavior in the StringBuilder return-value marshalling comment.
  • Makes non-ASCII-path test temp-directory cleanup best-effort to avoid masking failures from the test body.

Reviewed changes

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

File Description
UnityFileSystem/DllWrapper.cs Adds count bounds validation and marshals only the consumed subset of string arrays; updates marshalling behavior comment.
UnityFileSystem.Tests/UnityFileSystemTests.cs Wraps temp-directory deletion in a best-effort cleanup path for non-ASCII tests.

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

Comment thread UnityFileSystem/DllWrapper.cs Outdated
Comment on lines +198 to +202
// Strings returned from native (here and in the other StringBuilder-based calls) come back as
// UTF-8 bytes but are marshalled as the system ANSI code page, so only ASCII round-trips correctly.
// These are internal archive/serialized-file names, which Unity keeps ASCII, so it's not an issue in
// practice. Input paths, by contrast, are marshalled as UTF-8 (LPUTF8Str) to support non-ASCII paths.
// UTF-8 bytes but are marshalled as the system ANSI code page. On Windows that's a lossy code page,
// so only ASCII round-trips correctly (on macOS/Linux it happens to be UTF-8). These are internal
// archive/serialized-file names, which Unity keeps ASCII, so it's not an issue in practice. Input
// paths, by contrast, are marshalled as UTF-8 (LPUTF8Str) to support non-ASCII paths on all platforms.
Comment on lines +30 to +33
// Best-effort cleanup: a delete failure (e.g. a handle not yet released on Windows)
// must not mask a test failure thrown from the block above.
try { Directory.Delete(dir, true); }
catch { /* ignore */ }
- CreateArchive: marshal only the first `count` entries (matching what native
  consumes) and validate `count` against the array lengths, instead of
  marshalling every element.
- Comment rewrite
@SkowronskiAndrew
SkowronskiAndrew marked this pull request as ready for review July 27, 2026 15:35
@SkowronskiAndrew
SkowronskiAndrew merged commit 1ca6f56 into main Jul 27, 2026
5 checks passed
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