Open jazzman55 opened 1 month ago
The test file loremipsum.txt
The unit tests must not be covering this either because the content isn't large enough or the code there is missing this operation... 🤔
Anyway, not surprising that it had a different behavior before, as the Stream has been introduced only recently.
Subject: Request to Work on Good First Issue
Hi @jazzman55 ,
I noticed the issue with StreamReader and FileStream and believe it would be a great first issue for me to work on. I'm eager to contribute and would love the opportunity to tackle this.
May I take it on?
Thank you, Akshit
Hey @Akshit018! That's great that you're willing to tackle this one. 🥳 I'm assigning it to you now.
Please take a look at the contribution guide here. This will typically require a PR to the Sys.IO.FileSystem repo. We 💜 PRs so feel free to start one as early as you want so you can have early feedback.
If you have questions or want to discuss anything, suggest you head over to our Discord server and engage a conversation there.
Library/API/IoT binding
System.IO.FileSystem, System.IO.Streams
Visual Studio version
VS2022
.NET nanoFramework extension version
No response
Target name(s)
ESP32_REV3
Firmware version
1.12.0.32
Device capabilities
No response
Description
Reading text file with StreamReader, the underlying FileStream resets its position to 0 every time StreamReader's buffer is filled up. This causes endless jumps to beginning of the file and thus the file can't be read to end.
How to reproduce
Expected behaviour
File is correctly read line-by-line from start to end. When end of file is reached ReadLine() returns null.
Screenshots
Sample project or code
Flash to ESP32 with:
Aditional information
Workaround: Track stream's position in a separate variable and set the stream position before each read: https://github.com/CShark-Hub/Mako-IoT.Device.Services.FileStorage/blob/main/src/MakoIoT.Device.Services.FileStorage/MakoStreamReader.cs#L525
Note: This was working OK with one of the previous versions of System.IO.FileSystem