From 942f02ffbc053efeb46f2f2f46e3933212555578 Mon Sep 17 00:00:00 2001 From: yell0wsuit <5692900+yell0wsuit@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:18:45 +0700 Subject: [PATCH] Shush, IDE0057 Since Memory 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. --- .../Modules/Updater/Utils/DoUpdateWithMultipleThreads.cs | 2 ++ src/Ryujinx/Modules/Updater/Utils/DoUpdateWithSingleThread.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithMultipleThreads.cs b/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithMultipleThreads.cs index 054d775cd5..9df2f54d1e 100644 --- a/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithMultipleThreads.cs +++ b/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithMultipleThreads.cs @@ -108,7 +108,9 @@ namespace Ryujinx.Modules 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); +#pragma warning restore IDE0057 totalRead += bytesRead; int progress = (int)((totalRead * 100) / (end - start + 1)); progressPercentage[index] = progress; diff --git a/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithSingleThread.cs b/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithSingleThread.cs index 5c54e16d70..2deff25f97 100644 --- a/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithSingleThread.cs +++ b/src/Ryujinx/Modules/Updater/Utils/DoUpdateWithSingleThread.cs @@ -42,7 +42,9 @@ namespace Ryujinx.Modules 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); +#pragma warning restore IDE0057 byteWritten += readSize; int progress = GetPercentage(byteWritten, totalBytes);