From 231fb01dc1e1d6e7081e93ac25bb236e39e57c5c Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Sun, 7 Apr 2024 15:58:41 -0300 Subject: [PATCH] Replacing Abstract Types with Concrete Types --- .../CodeGen/Arm64/CodeGenContext.cs | 3 +- .../Instructions/InstEmitAluHelper.cs | 2 +- .../Instructions/InstEmitMemoryHelper.cs | 2 +- .../Translation/PTC/PtcProfiler.cs | 3 +- .../Logging/Targets/ConsoleLogTarget.cs | 2 +- .../Logging/Targets/FileLogTarget.cs | 2 +- .../SystemInterop/StdErrAdapter.cs | 8 ++-- src/Ryujinx.Common/Utilities/StreamUtils.cs | 3 +- src/Ryujinx.Cpu/LightningJit/Translator.cs | 2 +- .../Shader/DiskCache/DiskCacheGuestStorage.cs | 4 +- .../Shader/DiskCache/DiskCacheHostStorage.cs | 2 +- .../DiskCache/ShaderBinarySerializer.cs | 3 +- src/Ryujinx.Graphics.OpenGL/Window.cs | 2 +- .../Instructions/AttributeMap.cs | 6 +-- src/Ryujinx.Graphics.Vulkan/HelperShader.cs | 44 +++++++++---------- src/Ryujinx.Graphics.Vulkan/Window.cs | 2 +- src/Ryujinx.Gtk3/Modules/Updater/Updater.cs | 2 +- src/Ryujinx.Gtk3/UI/Windows/AvatarWindow.cs | 7 +-- .../UI/Windows/ControllerWindow.cs | 2 +- .../UI/Windows/UserProfilesManagerWindow.cs | 3 +- src/Ryujinx.HLE/FileSystem/ContentManager.cs | 2 +- .../HOS/Applets/Browser/BrowserApplet.cs | 5 ++- .../Applets/Controller/ControllerApplet.cs | 5 ++- .../PlayerSelect/PlayerSelectApplet.cs | 3 +- .../HOS/Diagnostics/Demangler/Demangler.cs | 30 ++++++------- src/Ryujinx.HLE/HOS/ModLoader.cs | 2 +- .../Am/AppletAE/Storage/StorageHelper.cs | 3 +- .../HOS/Services/Sdb/Pl/SharedFontManager.cs | 3 +- src/Ryujinx.HLE/HOS/Services/ServerBase.cs | 5 ++- .../HOS/Services/Sockets/Bsd/IClient.cs | 2 +- .../Sockets/Bsd/Impl/ManagedSocket.cs | 2 +- .../Services/Ssl/SslService/ISslConnection.cs | 2 +- .../HOS/Tamper/AtmosphereCompiler.cs | 2 +- src/Ryujinx.Horizon.Common/ResultNames.cs | 2 +- src/Ryujinx.Input/Motion/CemuHook/Client.cs | 5 ++- src/Ryujinx/Modules/Updater/Updater.cs | 2 +- src/Ryujinx/UI/Helpers/ContentDialogHelper.cs | 2 +- src/Ryujinx/UI/Renderer/EmbeddedWindow.cs | 6 +-- .../UserFirmwareAvatarSelectorViewModel.cs | 2 +- .../UI/ViewModels/UserSaveManagerViewModel.cs | 2 +- .../Settings/SettingsHotkeysView.axaml.cs | 2 +- 41 files changed, 103 insertions(+), 90 deletions(-) diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs index 89b1e9e6b..22d9c0e00 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs @@ -5,6 +5,7 @@ using Ryujinx.Common.Memory; using System; using System.Collections.Generic; using System.IO; +using Microsoft.IO; namespace ARMeilleure.CodeGen.Arm64 { @@ -14,7 +15,7 @@ namespace ARMeilleure.CodeGen.Arm64 private const int CbnzInstLength = 4; private const int LdrLitInstLength = 4; - private readonly Stream _stream; + private readonly RecyclableMemoryStream _stream; public int StreamOffset => (int)_stream.Length; diff --git a/src/ARMeilleure/Instructions/InstEmitAluHelper.cs b/src/ARMeilleure/Instructions/InstEmitAluHelper.cs index 4d4a31f7b..4d1db30a5 100644 --- a/src/ARMeilleure/Instructions/InstEmitAluHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitAluHelper.cs @@ -266,7 +266,7 @@ namespace ARMeilleure.Instructions } } - private static Exception InvalidOpCodeType(OpCode opCode) + private static InvalidOperationException InvalidOpCodeType(OpCode opCode) { return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\"."); } diff --git a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs index ace6fe1ce..bca739983 100644 --- a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs @@ -717,7 +717,7 @@ namespace ARMeilleure.Instructions }; } - private static Exception InvalidOpCodeType(OpCode opCode) + private static InvalidOperationException InvalidOpCodeType(OpCode opCode) { return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\"."); } diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index 0fe78edab..0b7a92108 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -14,6 +14,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; using System.Timers; +using Microsoft.IO; using static ARMeilleure.Translation.PTC.PtcFormatter; using Timer = System.Timers.Timer; @@ -189,7 +190,7 @@ namespace ARMeilleure.Translation.PTC return false; } - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); Debug.Assert(stream.Seek(0L, SeekOrigin.Begin) == 0L && stream.Length == 0L); try diff --git a/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs b/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs index 42ba00cd5..391cc5131 100644 --- a/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs +++ b/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Common.Logging.Targets { public class ConsoleLogTarget : ILogTarget { - private readonly ILogFormatter _formatter; + private readonly DefaultLogFormatter _formatter; private readonly string _name; diff --git a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs index 8d4ede96c..41edddb03 100644 --- a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs +++ b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Common.Logging.Targets public class FileLogTarget : ILogTarget { private readonly StreamWriter _logWriter; - private readonly ILogFormatter _formatter; + private readonly DefaultLogFormatter _formatter; private readonly string _name; string ILogTarget.Name { get => _name; } diff --git a/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs b/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs index a04c404d8..d7e227417 100644 --- a/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs +++ b/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs @@ -12,8 +12,8 @@ namespace Ryujinx.Common.SystemInterop public partial class StdErrAdapter : IDisposable { private bool _disposable; - private Stream _pipeReader; - private Stream _pipeWriter; + private FileStream _pipeReader; + private FileStream _pipeWriter; private CancellationTokenSource _cancellationTokenSource; private Task _worker; @@ -46,7 +46,7 @@ namespace Ryujinx.Common.SystemInterop [SupportedOSPlatform("macos")] private async Task EventWorkerAsync(CancellationToken cancellationToken) { - using TextReader reader = new StreamReader(_pipeReader, leaveOpen: true); + using StreamReader reader = new(_pipeReader, leaveOpen: true); string line; while (cancellationToken.IsCancellationRequested == false && (line = await reader.ReadLineAsync(cancellationToken)) != null) { @@ -92,7 +92,7 @@ namespace Ryujinx.Common.SystemInterop [SupportedOSPlatform("linux")] [SupportedOSPlatform("macos")] - private static Stream CreateFileDescriptorStream(int fd) + private static FileStream CreateFileDescriptorStream(int fd) { return new FileStream( new SafeFileHandle(fd, ownsHandle: true), diff --git a/src/Ryujinx.Common/Utilities/StreamUtils.cs b/src/Ryujinx.Common/Utilities/StreamUtils.cs index aeb6e0d52..46f309873 100644 --- a/src/Ryujinx.Common/Utilities/StreamUtils.cs +++ b/src/Ryujinx.Common/Utilities/StreamUtils.cs @@ -3,6 +3,7 @@ using Ryujinx.Common.Memory; using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.IO; namespace Ryujinx.Common.Utilities { @@ -58,7 +59,7 @@ namespace Ryujinx.Common.Utilities public static async Task StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); await input.CopyToAsync(stream, cancellationToken); diff --git a/src/Ryujinx.Cpu/LightningJit/Translator.cs b/src/Ryujinx.Cpu/LightningJit/Translator.cs index d62410253..3e1447c8a 100644 --- a/src/Ryujinx.Cpu/LightningJit/Translator.cs +++ b/src/Ryujinx.Cpu/LightningJit/Translator.cs @@ -74,7 +74,7 @@ namespace Ryujinx.Cpu.LightningJit } } - private static IStackWalker CreateStackWalker() + private static StackWalker CreateStackWalker() { if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) { diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs index 08cd3bb02..629edaffe 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs @@ -379,8 +379,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// Code and constant buffer data hash /// Entry index private int WriteNewEntry( - Stream tocFileStream, - Stream dataFileStream, + FileStream tocFileStream, + FileStream dataFileStream, ref TocHeader header, ReadOnlySpan data, ReadOnlySpan cb1Data, diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index c1f592011..3a45bbe85 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs @@ -737,7 +737,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// Magic value to be written /// Shader codegen version, only valid for the host file /// File creation timestamp - private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp) + private static void CreateToc(FileStream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp) { BinarySerializer writer = new(tocFileStream); diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs index a18b5780e..6e23f0500 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs @@ -5,6 +5,7 @@ using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader.Translation; using System.Collections.Generic; using System.IO; +using Microsoft.IO; namespace Ryujinx.Graphics.Gpu.Shader.DiskCache { @@ -12,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache { public static byte[] Pack(ShaderSource[] sources) { - using MemoryStream output = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream output = MemoryStreamManager.Shared.GetStream(); output.Write(sources.Length); diff --git a/src/Ryujinx.Graphics.OpenGL/Window.cs b/src/Ryujinx.Graphics.OpenGL/Window.cs index 6bcfefa4e..a65b0accf 100644 --- a/src/Ryujinx.Graphics.OpenGL/Window.cs +++ b/src/Ryujinx.Graphics.OpenGL/Window.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.OpenGL private bool _updateSize; private int _copyFramebufferHandle; private IPostProcessingEffect _antiAliasing; - private IScalingFilter _scalingFilter; + private FsrScalingFilter _scalingFilter; private bool _isLinear; private AntiAliasing _currentAntiAliasing; private bool _updateEffect; diff --git a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs index 54705acaf..01229fbb8 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs @@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } } - private static readonly IReadOnlyDictionary _attributes; + private static readonly Dictionary _attributes; private static readonly IReadOnlyDictionary _attributesPerPatch; static AttributeMap() @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Shader.Instructions _attributesPerPatch = CreatePerPatchMap(); } - private static IReadOnlyDictionary CreateMap() + private static Dictionary CreateMap() { var map = new Dictionary(); @@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return map; } - private static IReadOnlyDictionary CreatePerPatchMap() + private static Dictionary CreatePerPatchMap() { var map = new Dictionary(); diff --git a/src/Ryujinx.Graphics.Vulkan/HelperShader.cs b/src/Ryujinx.Graphics.Vulkan/HelperShader.cs index 73aa95c74..418854c9a 100644 --- a/src/Ryujinx.Graphics.Vulkan/HelperShader.cs +++ b/src/Ryujinx.Graphics.Vulkan/HelperShader.cs @@ -32,29 +32,29 @@ namespace Ryujinx.Graphics.Vulkan private readonly PipelineHelperShader _pipeline; private readonly ISampler _samplerLinear; private readonly ISampler _samplerNearest; - private readonly IProgram _programColorBlit; - private readonly IProgram _programColorBlitMs; - private readonly IProgram _programColorBlitClearAlpha; - private readonly IProgram _programColorClearF; - private readonly IProgram _programColorClearSI; - private readonly IProgram _programColorClearUI; - private readonly IProgram _programDepthStencilClear; - private readonly IProgram _programStrideChange; + private readonly ShaderCollection _programColorBlit; + private readonly ShaderCollection _programColorBlitMs; + private readonly ShaderCollection _programColorBlitClearAlpha; + private readonly ShaderCollection _programColorClearF; + private readonly ShaderCollection _programColorClearSI; + private readonly ShaderCollection _programColorClearUI; + private readonly ShaderCollection _programDepthStencilClear; + private readonly ShaderCollection _programStrideChange; private readonly IProgram _programConvertD32S8ToD24S8; - private readonly IProgram _programConvertIndexBuffer; - private readonly IProgram _programConvertIndirectData; - private readonly IProgram _programColorCopyShortening; - private readonly IProgram _programColorCopyToNonMs; - private readonly IProgram _programColorCopyWidening; - private readonly IProgram _programColorDrawToMs; - private readonly IProgram _programDepthBlit; - private readonly IProgram _programDepthBlitMs; - private readonly IProgram _programDepthDrawToMs; - private readonly IProgram _programDepthDrawToNonMs; - private readonly IProgram _programStencilBlit; - private readonly IProgram _programStencilBlitMs; - private readonly IProgram _programStencilDrawToMs; - private readonly IProgram _programStencilDrawToNonMs; + private readonly ShaderCollection _programConvertIndexBuffer; + private readonly ShaderCollection _programConvertIndirectData; + private readonly ShaderCollection _programColorCopyShortening; + private readonly ShaderCollection _programColorCopyToNonMs; + private readonly ShaderCollection _programColorCopyWidening; + private readonly ShaderCollection _programColorDrawToMs; + private readonly ShaderCollection _programDepthBlit; + private readonly ShaderCollection _programDepthBlitMs; + private readonly ShaderCollection _programDepthDrawToMs; + private readonly ShaderCollection _programDepthDrawToNonMs; + private readonly ShaderCollection _programStencilBlit; + private readonly ShaderCollection _programStencilBlitMs; + private readonly ShaderCollection _programStencilDrawToMs; + private readonly ShaderCollection _programStencilDrawToNonMs; public HelperShader(VulkanRenderer gd, Device device) { diff --git a/src/Ryujinx.Graphics.Vulkan/Window.cs b/src/Ryujinx.Graphics.Vulkan/Window.cs index efb0b31f9..ce6504de2 100644 --- a/src/Ryujinx.Graphics.Vulkan/Window.cs +++ b/src/Ryujinx.Graphics.Vulkan/Window.cs @@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Vulkan private AntiAliasing _currentAntiAliasing; private bool _updateEffect; private IPostProcessingEffect _effect; - private IScalingFilter _scalingFilter; + private FsrScalingFilter _scalingFilter; private bool _isLinear; private float _scalingFilterLevel; private bool _updateScalingFilter; diff --git a/src/Ryujinx.Gtk3/Modules/Updater/Updater.cs b/src/Ryujinx.Gtk3/Modules/Updater/Updater.cs index 8b006f63f..cb97ae97e 100644 --- a/src/Ryujinx.Gtk3/Modules/Updater/Updater.cs +++ b/src/Ryujinx.Gtk3/Modules/Updater/Updater.cs @@ -345,7 +345,7 @@ namespace Ryujinx.Modules using HttpResponseMessage response = client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).Result; using Stream remoteFileStream = response.Content.ReadAsStreamAsync().Result; - using Stream updateFileStream = File.Open(updateFile, FileMode.Create); + using FileStream updateFileStream = File.Open(updateFile, FileMode.Create); long totalBytes = response.Content.Headers.ContentLength.Value; long byteWritten = 0; diff --git a/src/Ryujinx.Gtk3/UI/Windows/AvatarWindow.cs b/src/Ryujinx.Gtk3/UI/Windows/AvatarWindow.cs index d9ecd47b7..dc2beafba 100644 --- a/src/Ryujinx.Gtk3/UI/Windows/AvatarWindow.cs +++ b/src/Ryujinx.Gtk3/UI/Windows/AvatarWindow.cs @@ -18,6 +18,7 @@ using System.Buffers.Binary; using System.Collections.Generic; using System.IO; using System.Reflection; +using Microsoft.IO; using Image = SixLabors.ImageSharp.Image; namespace Ryujinx.UI.Windows @@ -139,7 +140,7 @@ namespace Ryujinx.UI.Windows romfs.OpenFile(ref file.Ref, ("/" + item.FullPath).ToU8Span(), OpenMode.Read).ThrowIfFailure(); using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); - using MemoryStream streamPng = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream streamPng = MemoryStreamManager.Shared.GetStream(); file.Get.AsStream().CopyTo(stream); stream.Position = 0; @@ -168,7 +169,7 @@ namespace Ryujinx.UI.Windows private byte[] ProcessImage(byte[] data) { - using MemoryStream streamJpg = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream streamJpg = MemoryStreamManager.Shared.GetStream(); Image avatarImage = Image.Load(data, new PngDecoder()); @@ -222,7 +223,7 @@ namespace Ryujinx.UI.Windows Close(); } - private static byte[] DecompressYaz0(Stream stream) + private static byte[] DecompressYaz0(MemoryStream stream) { using BinaryReader reader = new(stream); diff --git a/src/Ryujinx.Gtk3/UI/Windows/ControllerWindow.cs b/src/Ryujinx.Gtk3/UI/Windows/ControllerWindow.cs index d0b8266f4..405d40c14 100644 --- a/src/Ryujinx.Gtk3/UI/Windows/ControllerWindow.cs +++ b/src/Ryujinx.Gtk3/UI/Windows/ControllerWindow.cs @@ -112,7 +112,7 @@ namespace Ryujinx.UI.Windows #pragma warning restore CS0649, IDE0044 private readonly MainWindow _mainWindow; - private readonly IGamepadDriver _gtk3KeyboardDriver; + private readonly GTK3KeyboardDriver _gtk3KeyboardDriver; private IGamepad _selectedGamepad; private bool _mousePressed; private bool _middleMousePressed; diff --git a/src/Ryujinx.Gtk3/UI/Windows/UserProfilesManagerWindow.cs b/src/Ryujinx.Gtk3/UI/Windows/UserProfilesManagerWindow.cs index d1e5fa9fc..2e302080a 100644 --- a/src/Ryujinx.Gtk3/UI/Windows/UserProfilesManagerWindow.cs +++ b/src/Ryujinx.Gtk3/UI/Windows/UserProfilesManagerWindow.cs @@ -12,6 +12,7 @@ using System.IO; using System.Reflection; using System.Threading; using System.Threading.Tasks; +using Microsoft.IO; using Image = SixLabors.ImageSharp.Image; namespace Ryujinx.UI.Windows @@ -181,7 +182,7 @@ namespace Ryujinx.UI.Windows image.Mutate(x => x.Resize(256, 256)); - using MemoryStream streamJpg = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream streamJpg = MemoryStreamManager.Shared.GetStream(); image.SaveAsJpeg(streamJpg); diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index e6c0fce08..11287fd22 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -571,7 +571,7 @@ namespace Ryujinx.HLE.FileSystem return file.Release(); } - private static Stream GetZipStream(ZipArchiveEntry entry) + private static MemoryStream GetZipStream(ZipArchiveEntry entry) { MemoryStream dest = MemoryStreamManager.Shared.GetStream(); diff --git a/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs index 6afbe4a72..cbc87d96c 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs @@ -5,6 +5,7 @@ using Ryujinx.HLE.HOS.Services.Am.AppletAE; using System; using System.Collections.Generic; using System.IO; +using Microsoft.IO; namespace Ryujinx.HLE.HOS.Applets.Browser { @@ -70,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser private static byte[] BuildResponseOld(WebCommonReturnValue result) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(result); @@ -78,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Applets.Browser } private byte[] BuildResponseNew(List outputArguments) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(new WebArgHeader { diff --git a/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs index 5ec9d4b08..efba3ee01 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs @@ -7,6 +7,7 @@ using System; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using Microsoft.IO; using static Ryujinx.HLE.HOS.Services.Hid.HidServer.HidUtils; namespace Ryujinx.HLE.HOS.Applets @@ -124,7 +125,7 @@ namespace Ryujinx.HLE.HOS.Applets private static byte[] BuildResponse(ControllerSupportResultInfo result) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref result, Unsafe.SizeOf()))); @@ -134,7 +135,7 @@ namespace Ryujinx.HLE.HOS.Applets private static byte[] BuildResponse() { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write((ulong)ResultCode.Success); diff --git a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs index ccc761ba1..f0ffd8ff7 100644 --- a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs @@ -3,6 +3,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.Services.Am.AppletAE; using System; using System.IO; +using Microsoft.IO; namespace Ryujinx.HLE.HOS.Applets { @@ -46,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Applets { UserProfile currentUser = _system.AccountManager.LastOpenedUser; - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write((ulong)PlayerSelectResult.Success); diff --git a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs index 171a083f3..6a9356255 100644 --- a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs +++ b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs @@ -252,7 +252,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= Do # non-throwing exception-specification (e.g., noexcept, throw()) // ::= DO E # computed (instantiation-dependent) noexcept // ::= Dw + E # dynamic exception specification with instantiation-dependent types - private BaseNode ParseFunctionType() + private FunctionType ParseFunctionType() { Cv cvQualifiers = ParseCvQualifiers(); @@ -347,7 +347,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= A _ // ::= A [] _ - private BaseNode ParseArrayType() + private ArrayType ParseArrayType() { if (!ConsumeIf("A")) { @@ -945,7 +945,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler } // ::= - private BaseNode ParseSourceName() + private NameType ParseSourceName() { int length = ParsePositiveNumber(); if (Count() < length || length <= 0) @@ -1320,7 +1320,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= D0 # deleting destructor // ::= D1 # complete object destructor // ::= D2 # base object destructor - private BaseNode ParseCtorDtorName(NameParserContext context, BaseNode prev) + private CtorDtorNameType ParseCtorDtorName(NameParserContext context, BaseNode prev) { if (prev.Type == NodeType.SpecialSubstitution && prev is SpecialSubstitution substitution) { @@ -1377,7 +1377,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= fp _ # L == 0, second and later parameters // ::= fL p _ # L > 0, first parameter // ::= fL p _ # L > 0, second and later parameters - private BaseNode ParseFunctionParameter() + private FunctionParameter ParseFunctionParameter() { if (ConsumeIf("fp")) { @@ -1422,7 +1422,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= fR // ::= fl // ::= fr - private BaseNode ParseFoldExpression() + private FoldExpression ParseFoldExpression() { if (!ConsumeIf("f")) { @@ -1571,7 +1571,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= cv # type (expression), conversion with one argument // ::= cv _ * E # type (expr-list), conversion with other than one argument - private BaseNode ParseConversionExpression() + private ConversionExpression ParseConversionExpression() { if (!ConsumeIf("cv")) { @@ -1616,7 +1616,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return new ConversionExpression(type, new NodeArray(expressions)); } - private BaseNode ParseBinaryExpression(string name) + private BinaryExpression ParseBinaryExpression(string name) { BaseNode leftPart = ParseExpression(); if (leftPart == null) @@ -1633,7 +1633,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return new BinaryExpression(leftPart, name, rightPart); } - private BaseNode ParsePrefixExpression(string name) + private PrefixExpression ParsePrefixExpression(string name) { BaseNode expression = ParseExpression(); if (expression == null) @@ -1720,7 +1720,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= [gs] na * _ # new[] (expr-list) type (init) // // ::= pi * E # parenthesized initialization - private BaseNode ParseNewExpression() + private NewExpression ParseNewExpression() { bool isGlobal = ConsumeIf("gs"); bool isArray = Peek(1) == 'a'; @@ -2404,7 +2404,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler return null; } - private BaseNode ParseIntegerLiteral(string literalName) + private IntegerLiteral ParseIntegerLiteral(string literalName) { string number = ParseNumber(true); if (number == null || number.Length == 0 || !ConsumeIf("E")) @@ -2521,7 +2521,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= Dt E # decltype of an id-expression or class member access (C++0x) // ::= DT E # decltype of an expression (C++0x) - private BaseNode ParseDecltype() + private EnclosedExpression ParseDecltype() { if (!ConsumeIf("D") || (!ConsumeIf("t") && !ConsumeIf("T"))) { @@ -2588,7 +2588,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler } // ::= I + E - private BaseNode ParseTemplateArguments(bool hasContext = false) + private TemplateArguments ParseTemplateArguments(bool hasContext = false) { if (!ConsumeIf("I")) { @@ -2740,7 +2740,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= # e.g., ~T or ~decltype(f()) // ::= # e.g., ~A<2*N> - private BaseNode ParseDestructorName() + private DtorName ParseDestructorName() { BaseNode node; if (char.IsDigit(Peek())) @@ -3134,7 +3134,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler // ::= Z E [] // ::= Z E s [] // ::= Z Ed [ ] _ - private BaseNode ParseLocalName(NameParserContext context) + private LocalName ParseLocalName(NameParserContext context) { if (!ConsumeIf("Z")) { diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index ee179c929..5c6ca066a 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -542,7 +542,7 @@ namespace Ryujinx.HLE.HOS return newStorage; } - private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet fileSet, RomFsBuilder builder) + private static void AddFiles(IFileSystem fs, string modName, string rootPath, HashSet fileSet, RomFsBuilder builder) { foreach (var entry in fs.EnumerateEntries() .AsParallel() diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs index 6c23720ee..0ab1f4c3d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs @@ -1,6 +1,7 @@ using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Account.Acc; using System.IO; +using Microsoft.IO; namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage { @@ -11,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.Storage public static byte[] MakeLaunchParams(UserProfile userProfile) { // Size needs to be at least 0x88 bytes otherwise application errors. - using MemoryStream ms = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream ms = MemoryStreamManager.Shared.GetStream(); BinaryWriter writer = new(ms); ms.SetLength(0x88); diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs index 641795890..966b9d94e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs @@ -14,6 +14,7 @@ using System; using System.Buffers.Binary; using System.Collections.Generic; using System.IO; +using Microsoft.IO; namespace Ryujinx.HLE.HOS.Services.Sdb.Pl { @@ -161,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl static uint KXor(uint data) => data ^ FontKey; using BinaryReader reader = new(bfttfStream); - using MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream ttfStream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter output = new(ttfStream); if (KXor(reader.ReadUInt32()) != BFTTFMagic) diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index f67699b90..5581506cd 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -14,6 +14,7 @@ using System.Buffers.Binary; using System.Collections.Generic; using System.IO; using System.Threading; +using Microsoft.IO; namespace Ryujinx.HLE.HOS.Services { @@ -46,10 +47,10 @@ namespace Ryujinx.HLE.HOS.Services private readonly Dictionary _sessions = new(); private readonly Dictionary> _ports = new(); - private readonly MemoryStream _requestDataStream; + private readonly RecyclableMemoryStream _requestDataStream; private readonly BinaryReader _requestDataReader; - private readonly MemoryStream _responseDataStream; + private readonly RecyclableMemoryStream _responseDataStream; private readonly BinaryWriter _responseDataWriter; private int _isDisposed = 0; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 21d48288e..449a7d9dd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -95,7 +95,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol) + ManagedSocket newBsdSocket = new(netDomain, (SocketType)type, protocol) { Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), }; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index c42b7201b..442fa247d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -400,7 +400,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl return true; } - private static IList> ConvertMessagesToBuffer(BsdMMsgHdr message) + private static ArraySegment[] ConvertMessagesToBuffer(BsdMMsgHdr message) { int segmentCount = 0; int index = 0; diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs index b5c608d3d..ea2f2188c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs @@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService private SessionCacheMode _sessionCacheMode; private string _hostName; - private ISslConnectionBase _connection; + private SslManagedSocketConnection _connection; private BsdContext _bsdContext; private readonly ulong _processId; diff --git a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs index e25ba7a55..a63a96c02 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs @@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Tamper return null; } - private ITamperProgram CompileImpl(string name, IEnumerable rawInstructions) + private AtmosphereProgram CompileImpl(string name, IEnumerable rawInstructions) { CompilationContext context = new(_exeAddress, _heapAddress, _aliasAddress, _aslrAddress, _process); context.BlockStack.Push(new OperationBlock(null)); diff --git a/src/Ryujinx.Horizon.Common/ResultNames.cs b/src/Ryujinx.Horizon.Common/ResultNames.cs index 55a33d680..3756dc6f8 100644 --- a/src/Ryujinx.Horizon.Common/ResultNames.cs +++ b/src/Ryujinx.Horizon.Common/ResultNames.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Horizon.Common static class ResultNames { // Reference: https://github.com/Thealexbarney/LibHac/blob/master/build/CodeGen/results.csv - private static readonly IReadOnlyDictionary _names = new Dictionary() + private static readonly Dictionary _names = new Dictionary() { { 0x0, "Success" }, { 0xE01, "OutOfSessions" }, diff --git a/src/Ryujinx.Input/Motion/CemuHook/Client.cs b/src/Ryujinx.Input/Motion/CemuHook/Client.cs index e19f3d847..ffa55efde 100644 --- a/src/Ryujinx.Input/Motion/CemuHook/Client.cs +++ b/src/Ryujinx.Input/Motion/CemuHook/Client.cs @@ -14,6 +14,7 @@ using System.Net; using System.Net.Sockets; using System.Numerics; using System.Threading.Tasks; +using Microsoft.IO; namespace Ryujinx.Input.Motion.CemuHook { @@ -380,7 +381,7 @@ namespace Ryujinx.Input.Motion.CemuHook Header header = GenerateHeader(clientId); - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(header); @@ -419,7 +420,7 @@ namespace Ryujinx.Input.Motion.CemuHook Header header = GenerateHeader(clientId); - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(header); diff --git a/src/Ryujinx/Modules/Updater/Updater.cs b/src/Ryujinx/Modules/Updater/Updater.cs index 9f186f2b3..c0b1e8583 100644 --- a/src/Ryujinx/Modules/Updater/Updater.cs +++ b/src/Ryujinx/Modules/Updater/Updater.cs @@ -463,7 +463,7 @@ namespace Ryujinx.Modules using HttpResponseMessage response = client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).Result; using Stream remoteFileStream = response.Content.ReadAsStreamAsync().Result; - using Stream updateFileStream = File.Open(updateFile, FileMode.Create); + using FileStream updateFileStream = File.Open(updateFile, FileMode.Create); long totalBytes = response.Content.Headers.ContentLength.Value; long byteWritten = 0; diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index 15b7ddd14..54cd56d47 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -406,7 +406,7 @@ namespace Ryujinx.Ava.UI.Helpers return dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow); } - private static Window GetMainWindow() + private static MainWindow GetMainWindow() { if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime al) { diff --git a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs index 0930e7795..78735eb18 100644 --- a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs +++ b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs @@ -116,7 +116,7 @@ namespace Ryujinx.Ava.UI.Renderer } [SupportedOSPlatform("linux")] - private IPlatformHandle CreateLinux(IPlatformHandle control) + private PlatformHandle CreateLinux(IPlatformHandle control) { if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan) { @@ -135,7 +135,7 @@ namespace Ryujinx.Ava.UI.Renderer } [SupportedOSPlatform("windows")] - IPlatformHandle CreateWin32(IPlatformHandle control) + PlatformHandle CreateWin32(IPlatformHandle control) { _className = "NativeWindow-" + Guid.NewGuid(); @@ -172,7 +172,7 @@ namespace Ryujinx.Ava.UI.Renderer } [SupportedOSPlatform("macos")] - IPlatformHandle CreateMacOS() + PlatformHandle CreateMacOS() { // Create a new CAMetalLayer. ObjectiveC.Object layerObject = new("CAMetalLayer"); diff --git a/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs b/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs index b07bf78b9..5de85a7c2 100644 --- a/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs @@ -143,7 +143,7 @@ namespace Ryujinx.Ava.UI.ViewModels } } - private static byte[] DecompressYaz0(Stream stream) + private static byte[] DecompressYaz0(MemoryStream stream) { using BinaryReader reader = new(stream); diff --git a/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs index 85adef005..bea7fdc76 100644 --- a/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs @@ -100,7 +100,7 @@ namespace Ryujinx.Ava.UI.ViewModels return false; } - private IComparer GetComparer() + private SortExpressionComparer GetComparer() { return SortIndex switch { diff --git a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs index fb0fe2bb1..ee605b181 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Ava.UI.Views.Settings public partial class SettingsHotkeysView : UserControl { private ButtonKeyAssigner _currentAssigner; - private readonly IGamepadDriver _avaloniaKeyboardDriver; + private readonly AvaloniaKeyboardDriver _avaloniaKeyboardDriver; public SettingsHotkeysView() {