Shush, IDE0057

Since Memory<byte> is initialized with a fixed size, `.Slice(0, readSize)` and `.Slice(0, bytesRead)` are necessary to ensure that only the part of the buffer that contains data is written to the file stream. So IDE0057 is not appropriate in this context.
This commit is contained in:
yell0wsuit 2024-04-17 17:18:45 +07:00
parent 3a1c722947
commit 942f02ffbc
No known key found for this signature in database
GPG key ID: 5B4F198A9800F6F4
2 changed files with 4 additions and 0 deletions

View file

@ -108,7 +108,9 @@ namespace Ryujinx.Modules
while ((bytesRead = await stream.ReadAsync(buffer, CancellationToken.None)) > 0) while ((bytesRead = await stream.ReadAsync(buffer, CancellationToken.None)) > 0)
{ {
#pragma warning disable IDE0057 // Disable the warning for unnecessary slicing
memoryStream.Write(buffer.Slice(0, bytesRead).ToArray(), 0, bytesRead); memoryStream.Write(buffer.Slice(0, bytesRead).ToArray(), 0, bytesRead);
#pragma warning restore IDE0057
totalRead += bytesRead; totalRead += bytesRead;
int progress = (int)((totalRead * 100) / (end - start + 1)); int progress = (int)((totalRead * 100) / (end - start + 1));
progressPercentage[index] = progress; progressPercentage[index] = progress;

View file

@ -42,7 +42,9 @@ namespace Ryujinx.Modules
while ((readSize = await remoteFileStream.ReadAsync(buffer, CancellationToken.None)) > 0) while ((readSize = await remoteFileStream.ReadAsync(buffer, CancellationToken.None)) > 0)
{ {
#pragma warning disable IDE0057 // Disable the warning for unnecessary slicing
updateFileStream.Write(buffer.Slice(0, readSize).ToArray(), 0, readSize); updateFileStream.Write(buffer.Slice(0, readSize).ToArray(), 0, readSize);
#pragma warning restore IDE0057
byteWritten += readSize; byteWritten += readSize;
int progress = GetPercentage(byteWritten, totalBytes); int progress = GetPercentage(byteWritten, totalBytes);