-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix: use UTF8 encoding without preamble as default #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
when no encoding is specified in File write or append methods
There was a problem hiding this 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 fixes the default encoding behavior in file write and append methods to use UTF-8 without BOM (byte order mark) instead of the system default encoding when no encoding is explicitly specified. This addresses issue #843 and improves cross-platform compatibility.
Key Changes:
- Modified file write/append methods to use UTF-8 encoding without preamble as default
- Consolidated encoding logic into a single
WriteTexthelper method - Added comprehensive tests to verify UTF-8 encoding behavior across all affected methods
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
Source/Testably.Abstractions.Testing/FileSystem/FileMock.cs |
Refactored file write/append methods to use UTF-8 as default and consolidated logic into WriteText helper |
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs |
Added tests verifying UTF-8 encoding and improved code formatting |
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextAsyncTests.cs |
Added tests for async text writing with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesTests.cs |
Added tests for line writing methods with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs |
Added tests for async line writing with UTF-8 encoding and improved formatting |
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs |
Added tests for text appending with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs |
Added tests for async text appending with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs |
Added tests for line appending with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs |
Added tests for async line appending with UTF-8 encoding verification |
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs
Show resolved
Hide resolved
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs
Show resolved
Hide resolved
|
Test Results 37 files ± 0 37 suites ±0 20m 45s ⏱️ -14s Results for commit dddacdf. ± Comparison against base commit 78b0421. This pull request removes 35765 and adds 36136 tests. Note that renamed tests count towards both.This pull request removes 1784 skipped tests and adds 1784 skipped tests. Note that renamed tests count towards both. |
|
This is addressed in release v4.3.3. |



This PR fixes the default encoding behavior in file write and append methods to use UTF-8 without BOM (byte order mark) instead of the system default encoding when no encoding is explicitly specified. This improves cross-platform compatibility.
Key Changes:
WriteTexthelper method