Skip to content

Improvements in StorageOperation command - #396

Merged
josesimoes merged 2 commits into
nanoframework:mainfrom
josesimoes:improve-storage-cmd
Jul 27, 2026
Merged

Improvements in StorageOperation command#396
josesimoes merged 2 commits into
nanoframework:mainfrom
josesimoes:improve-storage-cmd

Conversation

@josesimoes

@josesimoes josesimoes commented Jul 24, 2026

Copy link
Copy Markdown
Member

Description

  • Dropping name lenght property.
  • Replacing with null terminated string.
  • Adjust PrepareForSend methods accordingly.
  • Adjust parameter name to match declaration.

⚠️ this requires the connected device to run a fw version >1.17.0.257 with support for this new payload format

Motivation and Context

  • Simplification of data payload which allows much efficient code in the device.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updates storage operation wire-protocol payload construction to encode filenames as null-terminated UTF-8 data, append file data, remove the public NameLength field, and add the required namespace import.

Changes

Storage operation payload

Layer / File(s) Summary
Storage payload construction
nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs
Removes NameLength and changes PrepareForSend to build a null-terminated UTF-8 filename prefix followed by the provided payload bytes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ellerbach

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise, under 50 characters, and accurately summarizes the StorageOperation payload changes.
Description check ✅ Passed The description clearly matches the payload-format update and related PrepareForSend changes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs (1)

586-665: 🗄️ Data Integrity & Integration | 🔵 Trivial

Verify the firmware compatibility boundary.

Engine.AddStorageFile sends this payload unconditionally, while removing NameLength shifts subsequent fields for older firmware. Ensure deployment either gates this command to compatible firmware or clearly documents and enforces the required host/firmware pairing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs` around
lines 586 - 665, The storage-operation payload prepared by PrepareForSend and
sent through Engine.AddStorageFile must not be used with incompatible firmware.
Gate AddStorageFile or the related command path on the supported firmware
version, or enforce the required host/firmware pairing with clear validation and
documentation, while preserving the payload layout for compatible targets.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs`:
- Around line 659-665: Update the filename encoding logic near Data and FileName
so the allocated buffer size and null-terminator index use the UTF-8 byte count
returned for the encoded filename, not FileName.Length. Preserve the complete
UTF-8 byte sequence for multibyte characters and place the terminator
immediately after it.
- Around line 631-643: Restore the DataLength assignment in the
PrepareForSend(byte[] data, int length, int offset) override by setting it to
the requested length before resizing or constructing Data. Ensure chunks sent
through Engine.AddStorageFile expose the correct wire length, including nonzero
lengths.

---

Outside diff comments:
In `@nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs`:
- Around line 586-665: The storage-operation payload prepared by PrepareForSend
and sent through Engine.AddStorageFile must not be used with incompatible
firmware. Gate AddStorageFile or the related command path on the supported
firmware version, or enforce the required host/firmware pairing with clear
validation and documentation, while preserving the payload layout for compatible
targets.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: nanoframework/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f4bda1a2-a41a-4969-a0f2-5f17be552c7f

📥 Commits

Reviewing files that changed from the base of the PR and between 550f6b2 and eb583fb.

📒 Files selected for processing (1)
  • nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs

Comment thread nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs
Comment thread nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Commands.cs Outdated
@josesimoes
josesimoes force-pushed the improve-storage-cmd branch from eb583fb to 0f7f928 Compare July 24, 2026 13:23
- Dropping name lenght property.
- Replacing with null terminated string.
- Adjust PrepareForSend methods accordingly.
- Adjust parameter name to match declaration.

@Ellerbach Ellerbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That works fine!

@josesimoes
josesimoes merged commit 8b42c9c into nanoframework:main Jul 27, 2026
5 checks passed
@josesimoes
josesimoes deleted the improve-storage-cmd branch July 27, 2026 08:08
josesimoes added a commit that referenced this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants