ReadLineAsync returns Null
thopdev opened this issue · comments
THop commented
Describe the bug
All lines read from files are null when build with --configuration Release
Code:
using var stream = await _fileReference.OpenReadAsync();
using var reader = new StreamReader(stream, Encoding.UTF8, true, 10000);
string line;
while ((line = await reader.ReadLineAsync()) != null)
{
yield return line;
}
line is always null when build with Release.
When building with Debug no problems occur.
THop commented
Sorry problem was at my end,
while ((line = await reader.ReadLineAsync()) != null)
this didn't work on release
i replaced it with
var line = await reader.ReadLineAsync();
while (line != null)
{
var returnLine = line;
line = await reader.ReadLineAsync();
yield return returnLine;
}
This did work