-
Notifications
You must be signed in to change notification settings - Fork 256
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
MockFile.ReadAllLines does not deal with BOM correctly #464
Comments
@fgreinacher could you please answer these questions?
|
Sure, that would be fine.
TBH, I have no idea. Maybe @tathamoddie remembers? |
I think drop Maybe include this also for V6? |
Sorry for the long delay. Upon further investigation I found that the default encoding in I have a unit test for the reported issue here: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I see that this is marked as stale, but it looks like a real problem. |
No worries, issues that get comments won’t be closed, that’s what this workflow is for 😊 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This mitigates issues when the file has a BOM. Fixes #464 Co-authored-by: Florian Greinacher <fgreinacher@users.noreply.github.com>
Or, to be more precise, not at all. To deal with file data, a
StreamReader
must be used. This is also what .NET internally does.Consider the following example:
chars[0]
is now65279
, which is the BOM. That’s because the encoding is used directly:https://github.com/System-IO-Abstractions/System.IO.Abstractions/blob/452e3312776c14843806b14224ba82ae5d5ec137/System.IO.Abstractions.TestingHelpers/MockFile.cs#L496-L498
I’ll create a pull request later, if that’s okay.
Also, while I’m at it, might I ask why this library even bothers with trying to deal with text as a special case? This introduces unnecessary complexity and potential for differences in behavior with actual System.IO.
The text was updated successfully, but these errors were encountered: