Skip to content

Fix NetworkStream write core - #419

Merged
josesimoes merged 1 commit into
developfrom
fix-1854
Sep 24, 2026
Merged

josesimoes merged 1 commit into
developfrom
fix-1854

Conversation

@josesimoes

Copy link
Copy Markdown
Member

Description

  • Add back check for bytes sent.
  • Add unit tests to cover NetworkStream.

Motivation and Context

How Has This Been Tested?

  • New unit tests.

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.

- Add back check for bytes sent.
- Add unit tests to cover NetworkStream.
@nfbot nfbot added the Type: bug Something isn't working label Sep 24, 2026
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 4f64c2e0-7a2e-454e-9727-98594c49f315

📥 Commits

Reviewing files that changed from the base of the PR and between d8aa5d6 and 0fe9097.

📒 Files selected for processing (3)
  • Tests/SocketTests/NetworkStreamTests.cs
  • Tests/SocketTests/SocketTests.nfproj
  • nanoFramework.System.Net/Sockets/NetworkStream.cs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Network stream writes now report an error when the socket sends fewer bytes than requested.
  • Tests
    • Added loopback coverage for byte-array writes, offset writes, span writes, and zero-length writes.

Walkthrough

NetworkStream.WriteCore now throws IOException when the socket sends a byte count different from the requested count. New loopback tests cover array, offset/count, ReadOnlySpan<byte>, and zero-length writes. The SocketTests project includes the test file.

Changes

NetworkStream writes

Layer / File(s) Summary
Check completed write count
nanoFramework.System.Net/Sockets/NetworkStream.cs
WriteCore now compares the number of bytes sent with the requested count and throws IOException when they differ.
Add loopback write tests
Tests/SocketTests/NetworkStreamTests.cs, Tests/SocketTests/SocketTests.nfproj
Loopback tests cover array, offset/count, ReadOnlySpan<byte>, and zero-length writes. The project includes the new test file. The test setup skips these tests unless the skip call is removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: Type: Unit Tests

Merge Risk: ⚪ Minimal · up to 0fe90

The write fix is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change addresses #1854. NetworkStream.WriteCore now compares the socket-reported bytesSent value with the requested count. It throws only when the values differ, instead of treating every non-…
Out of Scope Changes check ✅ Passed The changes are limited to the WriteCore fix and related loopback tests. The project-file update only includes the new test source. These changes support #1854 and do not show unrelated behavior or …
Title check ✅ Passed The title is concise, descriptive, under 50 characters, and does not end with a full stop. It accurately identifies the NetworkStream write-core fix.
Description check ✅ Passed The description directly relates to the code changes. It describes the restored bytes-sent check, added NetworkStream tests, linked issue, and testing performed.

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.

@josesimoes

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@josesimoes

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@josesimoes
josesimoes merged commit df6a8b5 into develop Sep 24, 2026
8 checks passed
@josesimoes
josesimoes deleted the fix-1854 branch September 24, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants