diff --git a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs index 408b5baa4..17aab8105 100644 --- a/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs +++ b/src/Ryujinx.HLE/Exceptions/ServiceNotImplementedException.cs @@ -3,6 +3,7 @@ using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Services; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; @@ -53,12 +54,12 @@ namespace Ryujinx.HLE.Exceptions if (callingType != null && callingMethod != null) { // If the type is past 0xF, we are using TIPC - var ipcCommands = Request.Type > IpcMessageType.TipcCloseSession ? Service.TipcCommands : Service.CmifCommands; + IReadOnlyDictionary ipcCommands = Request.Type > IpcMessageType.TipcCloseSession ? Service.TipcCommands : Service.CmifCommands; // Find the handler for the method called - var ipcHandler = ipcCommands.FirstOrDefault(x => x.Value == callingMethod); - var ipcCommandId = ipcHandler.Key; - var ipcMethod = ipcHandler.Value; + KeyValuePair ipcHandler = ipcCommands.FirstOrDefault(x => x.Value == callingMethod); + int ipcCommandId = ipcHandler.Key; + MethodInfo ipcMethod = ipcHandler.Value; if (ipcMethod != null) { @@ -83,7 +84,7 @@ namespace Ryujinx.HLE.Exceptions { sb.AppendLine("\tPtrBuff:"); - foreach (var buff in Request.PtrBuff) + foreach (IpcPtrBuffDesc buff in Request.PtrBuff) { sb.AppendLine($"\t[{buff.Index}] Position: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}"); } @@ -93,7 +94,7 @@ namespace Ryujinx.HLE.Exceptions { sb.AppendLine("\tSendBuff:"); - foreach (var buff in Request.SendBuff) + foreach (IpcBuffDesc buff in Request.SendBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } @@ -103,7 +104,7 @@ namespace Ryujinx.HLE.Exceptions { sb.AppendLine("\tReceiveBuff:"); - foreach (var buff in Request.ReceiveBuff) + foreach (IpcBuffDesc buff in Request.ReceiveBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } @@ -113,7 +114,7 @@ namespace Ryujinx.HLE.Exceptions { sb.AppendLine("\tExchangeBuff:"); - foreach (var buff in Request.ExchangeBuff) + foreach (IpcBuffDesc buff in Request.ExchangeBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16} Flags: {buff.Flags}"); } @@ -123,7 +124,7 @@ namespace Ryujinx.HLE.Exceptions { sb.AppendLine("\tRecvListBuff:"); - foreach (var buff in Request.RecvListBuff) + foreach (IpcRecvListBuffDesc buff in Request.RecvListBuff) { sb.AppendLine($"\tPosition: 0x{buff.Position:x16} Size: 0x{buff.Size:x16}"); } @@ -147,8 +148,8 @@ namespace Ryujinx.HLE.Exceptions // Find the IIpcService method that threw this exception while ((frame = trace.GetFrame(i++)) != null) { - var method = frame.GetMethod(); - var declType = method.DeclaringType; + MethodBase method = frame.GetMethod(); + Type declType = method.DeclaringType; if (typeof(IpcService).IsAssignableFrom(declType)) { diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index a87453d00..bce896ea1 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -107,15 +107,15 @@ namespace Ryujinx.HLE.FileSystem foreach (StorageId storageId in Enum.GetValues()) { - if (!ContentPath.TryGetContentPath(storageId, out var contentPathString)) + if (!ContentPath.TryGetContentPath(storageId, out string contentPathString)) { continue; } - if (!ContentPath.TryGetRealPath(contentPathString, out var contentDirectory)) + if (!ContentPath.TryGetRealPath(contentPathString, out string contentDirectory)) { continue; } - var registeredDirectory = Path.Combine(contentDirectory, "registered"); + string registeredDirectory = Path.Combine(contentDirectory, "registered"); Directory.CreateDirectory(registeredDirectory); @@ -170,7 +170,7 @@ namespace Ryujinx.HLE.FileSystem } } - if (_locationEntries.TryGetValue(storageId, out var locationEntriesItem) && locationEntriesItem?.Count == 0) + if (_locationEntries.TryGetValue(storageId, out LinkedList locationEntriesItem) && locationEntriesItem?.Count == 0) { _locationEntries.Remove(storageId); } @@ -200,7 +200,7 @@ namespace Ryujinx.HLE.FileSystem if (!mergedToContainer) { - using var pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(containerPath, _virtualFileSystem); + using IFileSystem pfs = PartitionFileSystemUtils.OpenApplicationFileSystem(containerPath, _virtualFileSystem); } } } @@ -217,17 +217,17 @@ namespace Ryujinx.HLE.FileSystem if (AocData.TryGetValue(aocTitleId, out AocItem aoc)) { - var file = new FileStream(aoc.ContainerPath, FileMode.Open, FileAccess.Read); - using var ncaFile = new UniqueRef(); + FileStream file = new FileStream(aoc.ContainerPath, FileMode.Open, FileAccess.Read); + using UniqueRef ncaFile = new UniqueRef(); switch (Path.GetExtension(aoc.ContainerPath)) { case ".xci": - var xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure); + XciPartition xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage()).OpenPartition(XciPartitionType.Secure); xci.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); break; case ".nsp": - var pfs = new PartitionFileSystem(); + PartitionFileSystem pfs = new PartitionFileSystem(); pfs.Initialize(file.AsStorage()); pfs.OpenFile(ref ncaFile.Ref, aoc.NcaPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); break; @@ -278,7 +278,7 @@ namespace Ryujinx.HLE.FileSystem { if (_contentDictionary.ContainsValue(ncaId)) { - var content = _contentDictionary.FirstOrDefault(x => x.Value == ncaId); + KeyValuePair<(ulong titleId, NcaContentType type), string> content = _contentDictionary.FirstOrDefault(x => x.Value == ncaId); ulong titleId = content.Key.titleId; NcaContentType contentType = content.Key.type; @@ -295,7 +295,7 @@ namespace Ryujinx.HLE.FileSystem { lock (_lock) { - if (_contentDictionary.TryGetValue((titleId, contentType), out var contentDictionaryItem)) + if (_contentDictionary.TryGetValue((titleId, contentType), out string contentDictionaryItem)) { return UInt128Utils.FromHex(contentDictionaryItem); } @@ -430,8 +430,8 @@ namespace Ryujinx.HLE.FileSystem public void InstallFirmware(string firmwareSource) { - ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out var contentPathString); - ContentPath.TryGetRealPath(contentPathString, out var contentDirectory); + ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out string contentPathString); + ContentPath.TryGetRealPath(contentPathString, out string contentDirectory); string registeredDirectory = Path.Combine(contentDirectory, "registered"); string temporaryDirectory = Path.Combine(contentDirectory, "temp"); @@ -480,7 +480,7 @@ namespace Ryujinx.HLE.FileSystem { if (Directory.Exists(keysSource)) { - foreach (var filePath in Directory.EnumerateFiles(keysSource, "*.keys")) + foreach (string filePath in Directory.EnumerateFiles(keysSource, "*.keys")) { VerifyKeysFile(filePath); File.Copy(filePath, Path.Combine(installDirectory, Path.GetFileName(filePath)), true); @@ -523,7 +523,7 @@ namespace Ryujinx.HLE.FileSystem Directory.Delete(temporaryDirectory, true); } Directory.CreateDirectory(temporaryDirectory); - foreach (var entry in archive.Entries) + foreach (ZipArchiveEntry entry in archive.Entries) { if (Path.GetExtension(entry.FullName).Equals(".keys", StringComparison.OrdinalIgnoreCase)) { @@ -563,7 +563,7 @@ namespace Ryujinx.HLE.FileSystem private void InstallFromPartition(IFileSystem filesystem, string temporaryDirectory) { - foreach (var entry in filesystem.EnumerateEntries("/", "*.nca")) + foreach (DirectoryEntryEx entry in filesystem.EnumerateEntries("/", "*.nca")) { Nca nca = new(_virtualFileSystem.KeySet, OpenPossibleFragmentedFile(filesystem, entry.FullPath, OpenMode.Read).AsStorage()); @@ -587,7 +587,7 @@ namespace Ryujinx.HLE.FileSystem private static void InstallFromZip(ZipArchive archive, string temporaryDirectory) { - foreach (var entry in archive.Entries) + foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith(".nca") || entry.FullName.EndsWith(".nca/00")) { @@ -627,7 +627,7 @@ namespace Ryujinx.HLE.FileSystem private static IFile OpenPossibleFragmentedFile(IFileSystem filesystem, string path, OpenMode mode) { - using var file = new UniqueRef(); + using UniqueRef file = new UniqueRef(); if (filesystem.FileExists($"{path}/00")) { @@ -697,7 +697,7 @@ namespace Ryujinx.HLE.FileSystem { SystemVersion systemVersion = null; - foreach (var entry in archive.Entries) + foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith(".nca") || entry.FullName.EndsWith(".nca/00")) { @@ -706,7 +706,7 @@ namespace Ryujinx.HLE.FileSystem Nca nca = new(_virtualFileSystem.KeySet, storage); - if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem)) + if (updateNcas.TryGetValue(nca.Header.TitleId, out List<(NcaContentType type, string path)> updateNcasItem)) { updateNcasItem.Add((nca.Header.ContentType, entry.FullName)); } @@ -717,13 +717,13 @@ namespace Ryujinx.HLE.FileSystem } } - if (updateNcas.TryGetValue(SystemUpdateTitleId, out var ncaEntry)) + if (updateNcas.TryGetValue(SystemUpdateTitleId, out List<(NcaContentType type, string path)> ncaEntry)) { string metaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path; CnmtContentMetaEntry[] metaEntries = null; - var fileEntry = archive.GetEntry(metaPath); + ZipArchiveEntry fileEntry = archive.GetEntry(metaPath); using (Stream ncaStream = GetZipStream(fileEntry)) { @@ -733,11 +733,11 @@ namespace Ryujinx.HLE.FileSystem string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; - using var metaFile = new UniqueRef(); + using UniqueRef metaFile = new UniqueRef(); if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) { - var meta = new Cnmt(metaFile.Get.AsStream()); + Cnmt meta = new Cnmt(metaFile.Get.AsStream()); if (meta.Type == ContentMetaType.SystemUpdate) { @@ -753,16 +753,16 @@ namespace Ryujinx.HLE.FileSystem throw new FileNotFoundException("System update title was not found in the firmware package."); } - if (updateNcas.TryGetValue(SystemVersionTitleId, out var updateNcasItem)) + if (updateNcas.TryGetValue(SystemVersionTitleId, out List<(NcaContentType type, string path)> updateNcasItem)) { string versionEntry = updateNcasItem.FirstOrDefault(x => x.type != NcaContentType.Meta).path; using Stream ncaStream = GetZipStream(archive.GetEntry(versionEntry)); Nca nca = new(_virtualFileSystem.KeySet, ncaStream.AsStorage()); - var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); + IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); - using var systemVersionFile = new UniqueRef(); + using UniqueRef systemVersionFile = new UniqueRef(); if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) { @@ -798,11 +798,11 @@ namespace Ryujinx.HLE.FileSystem string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; - using var metaFile = new UniqueRef(); + using UniqueRef metaFile = new UniqueRef(); if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) { - var meta = new Cnmt(metaFile.Get.AsStream()); + Cnmt meta = new Cnmt(metaFile.Get.AsStream()); IStorage contentStorage = contentNcaStream.AsStorage(); if (contentStorage.GetSize(out long size).IsSuccess()) @@ -830,9 +830,9 @@ namespace Ryujinx.HLE.FileSystem { StringBuilder extraNcas = new(); - foreach (var entry in updateNcas) + foreach (KeyValuePair> entry in updateNcas) { - foreach (var (type, path) in entry.Value) + foreach ((NcaContentType type, string path) in entry.Value) { extraNcas.AppendLine(path); } @@ -855,7 +855,7 @@ namespace Ryujinx.HLE.FileSystem CnmtContentMetaEntry[] metaEntries = null; - foreach (var entry in filesystem.EnumerateEntries("/", "*.nca")) + foreach (DirectoryEntryEx entry in filesystem.EnumerateEntries("/", "*.nca")) { IStorage ncaStorage = OpenPossibleFragmentedFile(filesystem, entry.FullPath, OpenMode.Read).AsStorage(); @@ -867,11 +867,11 @@ namespace Ryujinx.HLE.FileSystem string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; - using var metaFile = new UniqueRef(); + using UniqueRef metaFile = new UniqueRef(); if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) { - var meta = new Cnmt(metaFile.Get.AsStream()); + Cnmt meta = new Cnmt(metaFile.Get.AsStream()); if (meta.Type == ContentMetaType.SystemUpdate) { @@ -883,9 +883,9 @@ namespace Ryujinx.HLE.FileSystem } else if (nca.Header.TitleId == SystemVersionTitleId && nca.Header.ContentType == NcaContentType.Data) { - var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); + IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); - using var systemVersionFile = new UniqueRef(); + using UniqueRef systemVersionFile = new UniqueRef(); if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) { @@ -893,7 +893,7 @@ namespace Ryujinx.HLE.FileSystem } } - if (updateNcas.TryGetValue(nca.Header.TitleId, out var updateNcasItem)) + if (updateNcas.TryGetValue(nca.Header.TitleId, out List<(NcaContentType type, string path)> updateNcasItem)) { updateNcasItem.Add((nca.Header.ContentType, entry.FullPath)); } @@ -912,7 +912,7 @@ namespace Ryujinx.HLE.FileSystem foreach (CnmtContentMetaEntry metaEntry in metaEntries) { - if (updateNcas.TryGetValue(metaEntry.TitleId, out var ncaEntry)) + if (updateNcas.TryGetValue(metaEntry.TitleId, out List<(NcaContentType type, string path)> ncaEntry)) { string metaNcaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path; string contentPath = ncaEntry.FirstOrDefault(x => x.type != NcaContentType.Meta).path; @@ -935,11 +935,11 @@ namespace Ryujinx.HLE.FileSystem string cnmtPath = fs.EnumerateEntries("/", "*.cnmt").Single().FullPath; - using var metaFile = new UniqueRef(); + using UniqueRef metaFile = new UniqueRef(); if (fs.OpenFile(ref metaFile.Ref, cnmtPath.ToU8Span(), OpenMode.Read).IsSuccess()) { - var meta = new Cnmt(metaFile.Get.AsStream()); + Cnmt meta = new Cnmt(metaFile.Get.AsStream()); if (contentStorage.GetSize(out long size).IsSuccess()) { @@ -966,9 +966,9 @@ namespace Ryujinx.HLE.FileSystem { StringBuilder extraNcas = new(); - foreach (var entry in updateNcas) + foreach (KeyValuePair> entry in updateNcas) { - foreach (var (type, path) in entry.Value) + foreach ((NcaContentType type, string path) in entry.Value) { extraNcas.AppendLine(path); } @@ -987,22 +987,22 @@ namespace Ryujinx.HLE.FileSystem lock (_lock) { - var locationEnties = _locationEntries[StorageId.BuiltInSystem]; + LinkedList locationEnties = _locationEntries[StorageId.BuiltInSystem]; - foreach (var entry in locationEnties) + foreach (LocationEntry entry in locationEnties) { if (entry.ContentType == NcaContentType.Data) { - var path = VirtualFileSystem.SwitchPathToSystemPath(entry.ContentPath); + string path = VirtualFileSystem.SwitchPathToSystemPath(entry.ContentPath); using FileStream fileStream = File.OpenRead(path); Nca nca = new(_virtualFileSystem.KeySet, fileStream.AsStorage()); if (nca.Header.TitleId == SystemVersionTitleId && nca.Header.ContentType == NcaContentType.Data) { - var romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); + IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.ErrorOnInvalid); - using var systemVersionFile = new UniqueRef(); + using UniqueRef systemVersionFile = new UniqueRef(); if (romfs.OpenFile(ref systemVersionFile.Ref, "/file".ToU8Span(), OpenMode.Read).IsSuccess()) { @@ -1073,7 +1073,7 @@ namespace Ryujinx.HLE.FileSystem public bool AreKeysAlredyPresent(string pathToCheck) { string[] fileNames = { "prod.keys", "title.keys", "console.keys", "dev.keys" }; - foreach (var file in fileNames) + foreach (string file in fileNames) { if (File.Exists(Path.Combine(pathToCheck, file))) { diff --git a/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs b/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs index 8cdb889be..a1f29bd13 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.FileSystem // TODO: Replace this with a check for IdOffset as soon as LibHac supports it: // && entry.IdOffset == programIndex - foreach (var entry in _cnmt.ContentEntries) + foreach (CnmtContentEntry entry in _cnmt.ContentEntries) { if (entry.Type != type) { diff --git a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index ef9c493a8..789caee4c 100644 --- a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -61,7 +61,7 @@ namespace Ryujinx.HLE.FileSystem public void LoadRomFs(ulong pid, string fileName) { - var romfsStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); + FileStream romfsStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); _romFsByPid.AddOrUpdate(pid, romfsStream, (pid, oldStream) => { @@ -140,8 +140,8 @@ namespace Ryujinx.HLE.FileSystem return $"{rawPath}:/"; } - var basePath = rawPath.AsSpan(0, firstSeparatorOffset); - var fileName = rawPath.AsSpan(firstSeparatorOffset + 1); + ReadOnlySpan basePath = rawPath.AsSpan(0, firstSeparatorOffset); + ReadOnlySpan fileName = rawPath.AsSpan(firstSeparatorOffset + 1); return $"{basePath}:/{fileName}"; } @@ -194,7 +194,7 @@ namespace Ryujinx.HLE.FileSystem } fsServerClient = horizon.CreatePrivilegedHorizonClient(); - var fsServer = new FileSystemServer(fsServerClient); + FileSystemServer fsServer = new FileSystemServer(fsServerClient); RandomDataGenerator randomGenerator = Random.Shared.NextBytes; @@ -208,7 +208,7 @@ namespace Ryujinx.HLE.FileSystem SdCard.SetSdCardInserted(true); - var fsServerConfig = new FileSystemServerConfig + FileSystemServerConfig fsServerConfig = new FileSystemServerConfig { ExternalKeySet = KeySet.ExternalKeySet, FsCreators = fsServerObjects.FsCreators, @@ -270,7 +270,7 @@ namespace Ryujinx.HLE.FileSystem { foreach (DirectoryEntryEx ticketEntry in fs.EnumerateEntries("/", "*.tik")) { - using var ticketFile = new UniqueRef(); + using UniqueRef ticketFile = new UniqueRef(); Result result = fs.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read); @@ -286,7 +286,7 @@ namespace Ryujinx.HLE.FileSystem continue; Ticket ticket = new(new MemoryStream(ticketData)); - var titleKey = ticket.GetTitleKey(KeySet); + byte[] titleKey = ticket.GetTitleKey(KeySet); if (titleKey != null) { @@ -334,7 +334,7 @@ namespace Ryujinx.HLE.FileSystem { Span info = stackalloc SaveDataInfo[8]; - using var iterator = new UniqueRef(); + using UniqueRef iterator = new UniqueRef(); Result rc = hos.Fs.OpenSaveDataIterator(ref iterator.Ref, spaceId); if (rc.IsFailure()) @@ -398,7 +398,7 @@ namespace Ryujinx.HLE.FileSystem } const string MountName = "SaveDir"; - var mountNameU8 = MountName.ToU8Span(); + U8Span mountNameU8 = MountName.ToU8Span(); BisPartitionId partitionId = info.SpaceId switch { @@ -415,7 +415,7 @@ namespace Ryujinx.HLE.FileSystem try { - var path = $"{MountName}:/save/{info.SaveDataId:x16}".ToU8Span(); + U8Span path = $"{MountName}:/save/{info.SaveDataId:x16}".ToU8Span(); rc = hos.Fs.GetEntryType(out _, path); @@ -437,7 +437,7 @@ namespace Ryujinx.HLE.FileSystem { list = null; - var mountName = "system".ToU8Span(); + U8Span mountName = "system".ToU8Span(); DirectoryHandle handle = default; List localList = new(); @@ -498,7 +498,7 @@ namespace Ryujinx.HLE.FileSystem // Only save data IDs added to SystemExtraDataFixInfo will be fixed. private static Result FixUnindexedSystemSaves(HorizonClient hos, List existingSaveIds) { - foreach (var fixInfo in _systemExtraDataFixInfo) + foreach (ExtraDataFixInfo fixInfo in _systemExtraDataFixInfo) { if (!existingSaveIds.Contains(fixInfo.StaticSaveDataId)) { @@ -665,7 +665,7 @@ namespace Ryujinx.HLE.FileSystem { if (disposing) { - foreach (var stream in _romFsByPid.Values) + foreach (Stream stream in _romFsByPid.Values) { stream.Close(); } diff --git a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs index 0e043cc45..a7917a157 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Error/ErrorApplet.cs @@ -122,7 +122,7 @@ namespace Ryujinx.HLE.HOS.Applets.Error if (romfs.FileExists(filePath)) { - using var binaryFile = new UniqueRef(); + using UniqueRef binaryFile = new UniqueRef(); romfs.OpenFile(ref binaryFile.Ref, filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); StreamReader reader = new(binaryFile.Get.AsStream(), Encoding.Unicode); diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 8fda00a7d..ea906659f 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -81,8 +81,8 @@ namespace Ryujinx.HLE.HOS.Applets _interactiveSession.DataAvailable += OnInteractiveData; - var launchParams = _normalSession.Pop(); - var keyboardConfig = _normalSession.Pop(); + byte[] launchParams = _normalSession.Pop(); + byte[] keyboardConfig = _normalSession.Pop(); _isBackground = keyboardConfig.Length == Unsafe.SizeOf(); @@ -205,7 +205,7 @@ namespace Ryujinx.HLE.HOS.Applets else { // Call the configured GUI handler to get user's input. - var args = new SoftwareKeyboardUIArgs + SoftwareKeyboardUIArgs args = new SoftwareKeyboardUIArgs { KeyboardMode = _keyboardForegroundConfig.Mode, HeaderText = StripUnicodeControlCodes(_keyboardForegroundConfig.HeaderText), @@ -265,7 +265,7 @@ namespace Ryujinx.HLE.HOS.Applets private void OnInteractiveData(object sender, EventArgs e) { // Obtain the validation status response. - var data = _interactiveSession.Pop(); + byte[] data = _interactiveSession.Pop(); if (_isBackground) { @@ -320,7 +320,7 @@ namespace Ryujinx.HLE.HOS.Applets using MemoryStream stream = new(data); using BinaryReader reader = new(stream); - var request = (InlineKeyboardRequest)reader.ReadUInt32(); + InlineKeyboardRequest request = (InlineKeyboardRequest)reader.ReadUInt32(); long remaining; @@ -400,14 +400,14 @@ namespace Ryujinx.HLE.HOS.Applets remaining = stream.Length - stream.Position; if (remaining == Marshal.SizeOf()) { - var keyboardCalcData = reader.ReadBytes((int)remaining); - var keyboardCalc = ReadStruct(keyboardCalcData); + byte[] keyboardCalcData = reader.ReadBytes((int)remaining); + SoftwareKeyboardCalc keyboardCalc = ReadStruct(keyboardCalcData); newCalc = keyboardCalc.ToExtended(); } else if (remaining == Marshal.SizeOf() || remaining == SoftwareKeyboardCalcEx.AlternativeSize) { - var keyboardCalcData = reader.ReadBytes((int)remaining); + byte[] keyboardCalcData = reader.ReadBytes((int)remaining); newCalc = ReadStruct(keyboardCalcData); } diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs index 239535ad5..f65d6a018 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRenderer.cs @@ -117,8 +117,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard _state.OverwriteMode = overwriteMode.GetValueOrDefault(_state.OverwriteMode); _state.TypingEnabled = typingEnabled.GetValueOrDefault(_state.TypingEnabled); - var begin = _state.CursorBegin; - var end = _state.CursorEnd; + int begin = _state.CursorBegin; + int end = _state.CursorEnd; _state.CursorBegin = Math.Min(begin, end); _state.CursorEnd = Math.Max(begin, end); diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs index e17b36911..9e861ad10 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs @@ -75,10 +75,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard _padCancelIcon = LoadResource(typeof(SoftwareKeyboardRendererBase).Assembly, padCancelIconPath, 0, 0); _keyModeIcon = LoadResource(typeof(SoftwareKeyboardRendererBase).Assembly, keyModeIconPath, 0, 0); - var panelColor = ToColor(uiTheme.DefaultBackgroundColor, 255); - var panelTransparentColor = ToColor(uiTheme.DefaultBackgroundColor, 150); - var borderColor = ToColor(uiTheme.DefaultBorderColor); - var selectionBackgroundColor = ToColor(uiTheme.SelectionBackgroundColor); + SKColor panelColor = ToColor(uiTheme.DefaultBackgroundColor, 255); + SKColor panelTransparentColor = ToColor(uiTheme.DefaultBackgroundColor, 150); + SKColor borderColor = ToColor(uiTheme.DefaultBorderColor); + SKColor selectionBackgroundColor = ToColor(uiTheme.SelectionBackgroundColor); _textNormalColor = ToColor(uiTheme.DefaultForegroundColor); _textSelectedColor = ToColor(uiTheme.SelectionForegroundColor); @@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { try { - using var typeface = SKTypeface.FromFamilyName(fontFamily, SKFontStyle.Normal); + using SKTypeface typeface = SKTypeface.FromFamilyName(fontFamily, SKFontStyle.Normal); _messageFont = new SKFont(typeface, 26); _inputTextFont = new SKFont(typeface, _inputTextFontSize); _labelsTextFont = new SKFont(typeface, 24); @@ -151,10 +151,10 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private static SKColor ToColor(ThemeColor color, byte? overrideAlpha = null, bool flipRgb = false) { - var a = (byte)(color.A * 255); - var r = (byte)(color.R * 255); - var g = (byte)(color.G * 255); - var b = (byte)(color.B * 255); + byte a = (byte)(color.A * 255); + byte r = (byte)(color.R * 255); + byte g = (byte)(color.G * 255); + byte b = (byte)(color.B * 255); if (flipRgb) { @@ -177,11 +177,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { Debug.Assert(resourceStream != null); - var bitmap = SKBitmap.Decode(resourceStream); + SKBitmap bitmap = SKBitmap.Decode(resourceStream); if (newHeight != 0 && newWidth != 0) { - var resized = bitmap.Resize(new SKImageInfo(newWidth, newHeight), SKFilterQuality.High); + SKBitmap resized = bitmap.Resize(new SKImageInfo(newWidth, newHeight), SKFilterQuality.High); if (resized != null) { bitmap.Dispose(); @@ -198,7 +198,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { return; } - var canvas = _surface.Canvas; + SKCanvas canvas = _surface.Canvas; canvas.Clear(SKColors.Transparent); canvas.DrawRect(_panelRectangle, _panelBrush); @@ -219,18 +219,18 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard return; } - using var paint = new SKPaint(_messageFont) + using SKPaint paint = new SKPaint(_messageFont) { Color = _textNormalColor, IsAntialias = true }; - var canvas = _surface.Canvas; - var messageRectangle = MeasureString(MessageText, paint); + SKCanvas canvas = _surface.Canvas; + SKRect messageRectangle = MeasureString(MessageText, paint); float messagePositionX = (_panelRectangle.Width - messageRectangle.Width) / 2 - messageRectangle.Left; float messagePositionY = _messagePositionY - messageRectangle.Top; - var messagePosition = new SKPoint(messagePositionX, messagePositionY); - var messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height); + SKPoint messagePosition = new SKPoint(messagePositionX, messagePositionY); + SKRect messageBoundRectangle = SKRect.Create(messagePositionX, messagePositionY, messageRectangle.Width, messageRectangle.Height); canvas.DrawRect(messageBoundRectangle, _panelBrush); @@ -336,12 +336,12 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private void DrawTextBox(SKCanvas canvas, SoftwareKeyboardUIState state) { - using var textPaint = new SKPaint(_labelsTextFont) + using SKPaint textPaint = new SKPaint(_labelsTextFont) { IsAntialias = true, Color = _textNormalColor }; - var inputTextRectangle = MeasureString(state.InputText, textPaint); + SKRect inputTextRectangle = MeasureString(state.InputText, textPaint); float boxWidth = (int)(Math.Max(300, inputTextRectangle.Width + inputTextRectangle.Left + 8)); float boxHeight = 32; @@ -360,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard float inputTextX = (_panelRectangle.Width - inputTextRectangle.Width) / 2 - inputTextRectangle.Left; float inputTextY = boxY + 5; - var inputTextPosition = new SKPoint(inputTextX, inputTextY); + SKPoint inputTextPosition = new SKPoint(inputTextX, inputTextY); canvas.DrawText(state.InputText, inputTextPosition.X, inputTextPosition.Y + (_labelsTextFont.Metrics.XHeight + _labelsTextFont.Metrics.Descent), textPaint); // Draw the cursor on top of the text and redraw the text with a different color if necessary. @@ -387,8 +387,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard ReadOnlySpan textUntilBegin = state.InputText.AsSpan(0, state.CursorBegin); ReadOnlySpan textUntilEnd = state.InputText.AsSpan(0, state.CursorEnd); - var selectionBeginRectangle = MeasureString(textUntilBegin, textPaint); - var selectionEndRectangle = MeasureString(textUntilEnd, textPaint); + SKRect selectionBeginRectangle = MeasureString(textUntilBegin, textPaint); + SKRect selectionEndRectangle = MeasureString(textUntilEnd, textPaint); cursorVisible = true; cursorPositionXLeft = inputTextX + selectionBeginRectangle.Width + selectionBeginRectangle.Left; @@ -406,7 +406,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard int cursorBegin = Math.Min(state.InputText.Length, state.CursorBegin); ReadOnlySpan textUntilCursor = state.InputText.AsSpan(0, cursorBegin); - var cursorTextRectangle = MeasureString(textUntilCursor, textPaint); + SKRect cursorTextRectangle = MeasureString(textUntilCursor, textPaint); cursorVisible = true; cursorPositionXLeft = inputTextX + cursorTextRectangle.Width + cursorTextRectangle.Left; @@ -452,16 +452,16 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard } else { - var cursorRectangle = SKRect.Create(cursorPositionXLeft, cursorPositionYTop, cursorWidth, cursorHeight); + SKRect cursorRectangle = SKRect.Create(cursorPositionXLeft, cursorPositionYTop, cursorWidth, cursorHeight); canvas.DrawRect(cursorRectangle, cursorPen); canvas.DrawRect(cursorRectangle, cursorBrush); - using var textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888)); - var textOverCanvas = textOverCursor.Canvas; - var textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top); + using SKSurface textOverCursor = SKSurface.Create(new SKImageInfo((int)cursorRectangle.Width, (int)cursorRectangle.Height, SKColorType.Rgba8888)); + SKCanvas textOverCanvas = textOverCursor.Canvas; + SKPoint textRelativePosition = new SKPoint(inputTextPosition.X - cursorRectangle.Left, inputTextPosition.Y - cursorRectangle.Top); - using var cursorPaint = new SKPaint(_inputTextFont) + using SKPaint cursorPaint = new SKPaint(_inputTextFont) { Color = cursorTextColor, IsAntialias = true @@ -469,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard textOverCanvas.DrawText(state.InputText, textRelativePosition.X, textRelativePosition.Y + _inputTextFont.Metrics.XHeight + _inputTextFont.Metrics.Descent, cursorPaint); - var cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top); + SKPoint cursorPosition = new SKPoint((int)cursorRectangle.Left, (int)cursorRectangle.Top); textOverCursor.Flush(); canvas.DrawSurface(textOverCursor, cursorPosition); } @@ -492,13 +492,13 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard float iconWidth = icon.Width; float iconHeight = icon.Height; - using var paint = new SKPaint(_labelsTextFont) + using SKPaint paint = new SKPaint(_labelsTextFont) { Color = _textNormalColor, IsAntialias = true }; - var labelRectangle = MeasureString(label, paint); + SKRect labelRectangle = MeasureString(label, paint); float labelPositionX = iconWidth + 8 - labelRectangle.Left; float labelPositionY = 3; @@ -514,13 +514,13 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard iconX += originX; iconY += originY; - var iconPosition = new SKPoint((int)iconX, (int)iconY); - var labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); + SKPoint iconPosition = new SKPoint((int)iconX, (int)iconY); + SKPoint labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); - var selectedRectangle = SKRect.Create(originX - 2 * _padPressedPenWidth, originY - 2 * _padPressedPenWidth, + SKRect selectedRectangle = SKRect.Create(originX - 2 * _padPressedPenWidth, originY - 2 * _padPressedPenWidth, fullWidth + 4 * _padPressedPenWidth, fullHeight + 4 * _padPressedPenWidth); - var boundRectangle = SKRect.Create(originX, originY, fullWidth, fullHeight); + SKRect boundRectangle = SKRect.Create(originX, originY, fullWidth, fullHeight); boundRectangle.Inflate(4 * _padPressedPenWidth, 4 * _padPressedPenWidth); canvas.DrawRect(boundRectangle, _panelBrush); @@ -545,12 +545,12 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private void DrawControllerToggle(SKCanvas canvas, SKPoint point) { - using var paint = new SKPaint(_labelsTextFont) + using SKPaint paint = new SKPaint(_labelsTextFont) { IsAntialias = true, Color = _textNormalColor }; - var labelRectangle = MeasureString(ControllerToggleText, paint); + SKRect labelRectangle = MeasureString(ControllerToggleText, paint); // Use relative positions so we can center the entire drawing later. @@ -574,8 +574,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard keyX += originX; keyY += originY; - var labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); - var overlayPosition = new SKPoint((int)keyX, (int)keyY); + SKPoint labelPosition = new SKPoint(labelPositionX + originX, labelPositionY + originY); + SKPoint overlayPosition = new SKPoint((int)keyX, (int)keyY); canvas.DrawBitmap(_keyModeIcon, overlayPosition); canvas.DrawText(ControllerToggleText, labelPosition.X, labelPosition.Y + _labelsTextFont.Metrics.XHeight, paint); @@ -593,7 +593,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard // Convert the pixel format used in the image to the one used in the Switch surface. _surface.Flush(); - var buffer = new byte[_imageInfo.BytesSize]; + byte[] buffer = new byte[_imageInfo.BytesSize]; fixed (byte* bufferPtr = buffer) { if (!_surface.ReadPixels(_imageInfo, (nint)bufferPtr, _imageInfo.RowBytes, 0, 0)) diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs index a8b137df2..e98dadb77 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs @@ -79,11 +79,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard public void Reset(Action action, int totalMilliseconds, int sleepMilliseconds) { // Create a dedicated cancel token for each task. - var cancelled = new TRef(false); + TRef cancelled = new TRef(false); Reset(new Thread(() => { - var substepData = new SleepSubstepData(sleepMilliseconds); + SleepSubstepData substepData = new SleepSubstepData(sleepMilliseconds); int totalCount = totalMilliseconds / sleepMilliseconds; int totalRemainder = totalMilliseconds - totalCount * sleepMilliseconds; @@ -126,11 +126,11 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard public void Reset(Action action, int sleepMilliseconds) { // Create a dedicated cancel token for each task. - var cancelled = new TRef(false); + TRef cancelled = new TRef(false); Reset(new Thread(() => { - var substepData = new SleepSubstepData(sleepMilliseconds); + SleepSubstepData substepData = new SleepSubstepData(sleepMilliseconds); while (!Volatile.Read(ref cancelled.Value)) { @@ -147,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard public void Reset(Action action) { // Create a dedicated cancel token for each task. - var cancelled = new TRef(false); + TRef cancelled = new TRef(false); Reset(new Thread(() => { diff --git a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs index 14775fb1d..621a081fd 100644 --- a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs +++ b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs @@ -51,8 +51,8 @@ namespace Ryujinx.HLE.HOS if (OperatingSystem.IsMacOS() && isArm64Host && for64Bit && context.Device.Configuration.UseHypervisor) { - var cpuEngine = new HvEngine(_tickSource); - var memoryManager = new HvMemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); + HvEngine cpuEngine = new HvEngine(_tickSource); + HvMemoryManager memoryManager = new HvMemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); processContext = new ArmProcessContext(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit); } else @@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS switch (mode) { case MemoryManagerMode.SoftwarePageTable: - var memoryManager = new MemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); + MemoryManager memoryManager = new MemoryManager(context.Memory, addressSpaceSize, invalidAccessHandler); processContext = new ArmProcessContext(pid, cpuEngine, _gpu, memoryManager, addressSpaceSize, for64Bit); break; @@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS case MemoryManagerMode.HostMappedUnsafe: if (addressSpace == null) { - var memoryManagerHostTracked = new MemoryManagerHostTracked(context.Memory, addressSpaceSize, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler); + MemoryManagerHostTracked memoryManagerHostTracked = new MemoryManagerHostTracked(context.Memory, addressSpaceSize, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler); processContext = new ArmProcessContext(pid, cpuEngine, _gpu, memoryManagerHostTracked, addressSpaceSize, for64Bit); } else @@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS Logger.Warning?.Print(LogClass.Emulation, $"Allocated address space (0x{addressSpace.AddressSpaceSize:X}) is smaller than guest application requirements (0x{addressSpaceSize:X})"); } - var memoryManagerHostMapped = new MemoryManagerHostMapped(addressSpace, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler); + MemoryManagerHostMapped memoryManagerHostMapped = new MemoryManagerHostMapped(addressSpace, mode == MemoryManagerMode.HostMappedUnsafe, invalidAccessHandler); processContext = new ArmProcessContext(pid, cpuEngine, _gpu, memoryManagerHostMapped, addressSpace.AddressSpaceSize, for64Bit); } break; diff --git a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs index 2e7b8ee76..59ce69b73 100644 --- a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs +++ b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs @@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler private bool ConsumeIf(string toConsume) { - var mangledPart = Mangled.AsSpan(_position); + ReadOnlySpan mangledPart = Mangled.AsSpan(_position); if (mangledPart.StartsWith(toConsume.AsSpan())) { diff --git a/src/Ryujinx.HLE/HOS/Horizon.cs b/src/Ryujinx.HLE/HOS/Horizon.cs index 627b649df..e0dd0f1c9 100644 --- a/src/Ryujinx.HLE/HOS/Horizon.cs +++ b/src/Ryujinx.HLE/HOS/Horizon.cs @@ -154,11 +154,11 @@ namespace Ryujinx.HLE.HOS timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize); appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize); - var hidStorage = new SharedMemoryStorage(KernelContext, hidPageList); - var fontStorage = new SharedMemoryStorage(KernelContext, fontPageList); - var iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList); - var timeStorage = new SharedMemoryStorage(KernelContext, timePageList); - var appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList); + SharedMemoryStorage hidStorage = new SharedMemoryStorage(KernelContext, hidPageList); + SharedMemoryStorage fontStorage = new SharedMemoryStorage(KernelContext, fontPageList); + SharedMemoryStorage iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList); + SharedMemoryStorage timeStorage = new SharedMemoryStorage(KernelContext, timePageList); + SharedMemoryStorage appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList); HidStorage = hidStorage; @@ -265,7 +265,7 @@ namespace Ryujinx.HLE.HOS HorizonFsClient fsClient = new(this); ServiceTable = new ServiceTable(); - var services = ServiceTable.GetServices(new HorizonOptions + IEnumerable services = ServiceTable.GetServices(new HorizonOptions (Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient, fsClient, @@ -273,7 +273,7 @@ namespace Ryujinx.HLE.HOS Device.AudioDeviceDriver, TickSource)); - foreach (var service in services) + foreach (ServiceEntry service in services) { const ProcessCreationFlags Flags = ProcessCreationFlags.EnableAslr | @@ -304,7 +304,7 @@ namespace Ryujinx.HLE.HOS public bool LoadKip(string kipPath) { - using var kipFile = new SharedRef(new LocalStorage(kipPath, FileAccess.Read)); + using SharedRef kipFile = new SharedRef(new LocalStorage(kipPath, FileAccess.Read)); return ProcessLoaderHelper.LoadKip(KernelContext, new KipExecutable(in kipFile)); } diff --git a/src/Ryujinx.HLE/HOS/HorizonFsClient.cs b/src/Ryujinx.HLE/HOS/HorizonFsClient.cs index 3dbafa88b..67b3d9b14 100644 --- a/src/Ryujinx.HLE/HOS/HorizonFsClient.cs +++ b/src/Ryujinx.HLE/HOS/HorizonFsClient.cs @@ -55,8 +55,8 @@ namespace Ryujinx.HLE.HOS Nca nca = new(_system.KeySet, ncaStorage); - using var ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel); - using var ncaFsRef = new UniqueRef(ncaFileSystem); + using IFileSystem ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel); + using UniqueRef ncaFsRef = new UniqueRef(ncaFileSystem); Result result = _fsClient.Register(mountName.ToU8Span(), ref ncaFsRef.Ref).ToHorizonResult(); if (result.IsFailure) @@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS public Result OpenFile(out FileHandle handle, string path, OpenMode openMode) { - var result = _fsClient.OpenFile(out var libhacHandle, path.ToU8Span(), (LibHac.Fs.OpenMode)openMode); + LibHac.Result result = _fsClient.OpenFile(out LibHac.Fs.FileHandle libhacHandle, path.ToU8Span(), (LibHac.Fs.OpenMode)openMode); handle = new(libhacHandle); return result.ToHorizonResult(); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs index e56304d9d..a27bb0074 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryManager.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { for (int i = 0; i < MemoryRegions.Length; i++) { - var region = MemoryRegions[i]; + KMemoryRegionManager region = MemoryRegions[i]; if (address >= region.Address && address < region.EndAddr) { @@ -41,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { while (pagesCount != 0) { - var region = GetMemoryRegion(address); + KMemoryRegionManager region = GetMemoryRegion(address); ulong countToProcess = Math.Min(pagesCount, region.GetPageOffsetFromEnd(address)); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryRegionManager.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryRegionManager.cs index 2eff616c4..270c4ff32 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryRegionManager.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KMemoryRegionManager.cs @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory if (result == Result.Success) { - foreach (var node in pageList) + foreach (KPageNode node in pageList) { IncrementPagesReferenceCount(node.Address, node.PagesCount); } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageBitmap.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageBitmap.cs index 947983d61..a044ba8b3 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageBitmap.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageBitmap.cs @@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory public bool ClearRange(ulong offset, int count) { int depth = HighestDepthIndex; - var bits = _bitStorages[depth]; + ArraySegment bits = _bitStorages[depth]; int bitInd = (int)(offset / UInt64BitSize); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageHeap.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageHeap.cs index ee5d6e2b6..3c3c83bb9 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageHeap.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageHeap.cs @@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory _blocksCount = blockShifts.Length; _blocks = new Block[_memoryBlockPageShifts.Length]; - var currBitmapStorage = new ArraySegment(new ulong[CalculateManagementOverheadSize(size, blockShifts)]); + ArraySegment currBitmapStorage = new ArraySegment(new ulong[CalculateManagementOverheadSize(size, blockShifts)]); for (int i = 0; i < blockShifts.Length; i++) { diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageList.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageList.cs index 60514824a..38e2b6f95 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageList.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageList.cs @@ -70,7 +70,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory public void IncrementPagesReferenceCount(KMemoryManager manager) { - foreach (var node in this) + foreach (KPageNode node in this) { manager.IncrementPagesReferenceCount(node.Address, node.PagesCount); } @@ -78,7 +78,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory public void DecrementPagesReferenceCount(KMemoryManager manager) { - foreach (var node in this) + foreach (KPageNode node in this) { manager.DecrementPagesReferenceCount(node.Address, node.PagesCount); } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs index 4ffa447dd..8258c16c8 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTable.cs @@ -28,8 +28,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory /// protected override void GetPhysicalRegions(ulong va, ulong size, KPageList pageList) { - var ranges = _cpuMemory.GetPhysicalRegions(va, size); - foreach (var range in ranges) + IEnumerable ranges = _cpuMemory.GetPhysicalRegions(va, size); + foreach (MemoryRange range in ranges) { pageList.AddRange(range.Address + DramMemoryMap.DramBase, range.Size / PageSize); } @@ -143,11 +143,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory bool shouldFillPages, byte fillValue) { - using var scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); + using KScopedPageList scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); ulong currentVa = address; - foreach (var pageNode in pageList) + foreach (KPageNode pageNode in pageList) { ulong addr = pageNode.Address - DramMemoryMap.DramBase; ulong size = pageNode.PagesCount * PageSize; @@ -188,16 +188,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory } } - using var scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); + using KScopedPageList scopedPageList = new KScopedPageList(Context.MemoryManager, pageList); - foreach (var pageNode in pageList) + foreach (KPageNode pageNode in pageList) { Context.CommitMemory(pageNode.Address - DramMemoryMap.DramBase, pageNode.PagesCount * PageSize); } ulong offset = 0; - foreach (var region in regions) + foreach (HostMemoryRange region in regions) { _cpuMemory.MapForeign(va + offset, region.Address, region.Size); @@ -214,9 +214,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { KPageList pagesToClose = new(); - var regions = _cpuMemory.GetPhysicalRegions(address, pagesCount * PageSize); + IEnumerable regions = _cpuMemory.GetPhysicalRegions(address, pagesCount * PageSize); - foreach (var region in regions) + foreach (MemoryRange region in regions) { ulong pa = region.Address + DramMemoryMap.DramBase; if (DramMemoryMap.IsHeapPhysicalAddress(pa)) diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs index bf2bbb97b..1b7cd7cad 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KPageTableBase.cs @@ -617,7 +617,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory return result; } - using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); + using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); return MapPages(address, pageList, permission, MemoryMapFlags.Private); } @@ -769,7 +769,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory Result result = region.AllocatePages(out KPageList pageList, pagesCount); - using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); + using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); void CleanUpForError() { @@ -1341,7 +1341,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory Result result = region.AllocatePages(out KPageList pageList, remainingPages); - using var _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); + using OnScopeExit _ = new OnScopeExit(() => pageList.DecrementPagesReferenceCount(Context.MemoryManager)); void CleanUpForError() { @@ -1867,7 +1867,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory ulong dstLastPagePa = 0; ulong currentVa = va; - using var _ = new OnScopeExit(() => + using OnScopeExit _ = new OnScopeExit(() => { if (dstFirstPagePa != 0) { @@ -1928,7 +1928,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory Context.Memory.Fill(GetDramAddressFromPa(dstFirstPagePa), unusedSizeBefore, (byte)_ipcFillValue); ulong copySize = addressRounded <= endAddr ? addressRounded - address : size; - var data = srcPageTable.GetReadOnlySequence(addressTruncated + unusedSizeBefore, (int)copySize); + ReadOnlySequence data = srcPageTable.GetReadOnlySequence(addressTruncated + unusedSizeBefore, (int)copySize); ((IWritableBlock)Context.Memory).Write(GetDramAddressFromPa(dstFirstPagePa + unusedSizeBefore), data); @@ -1994,7 +1994,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory if (send) { ulong copySize = endAddr - endAddrTruncated; - var data = srcPageTable.GetReadOnlySequence(endAddrTruncated, (int)copySize); + ReadOnlySequence data = srcPageTable.GetReadOnlySequence(endAddrTruncated, (int)copySize); ((IWritableBlock)Context.Memory).Write(GetDramAddressFromPa(dstLastPagePa), data); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs index ff3de4a17..a9f87f2ca 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs @@ -1,3 +1,4 @@ +using Ryujinx.Cpu; using Ryujinx.HLE.HOS.Diagnostics.Demangler; using Ryujinx.HLE.HOS.Kernel.Memory; using Ryujinx.HLE.HOS.Kernel.Threading; @@ -47,7 +48,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { EnsureLoaded(); - var context = thread.Context; + IExecutionContext context = thread.Context; StringBuilder trace = new(); @@ -109,13 +110,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { EnsureLoaded(); - var context = thread.Context; + IExecutionContext context = thread.Context; StringBuilder sb = new(); string GetReg(int x) { - var v = x == 32 ? context.Pc : context.GetX(x); + ulong v = x == 32 ? context.Pc : context.GetX(x); if (!AnalyzePointer(out PointerInfo info, v, thread)) { return $"0x{v:x16}"; @@ -251,7 +252,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process info = default; ulong sp = thread.Context.GetX(31); - var memoryInfo = _owner.MemoryManager.QueryMemory(address); + KMemoryInfo memoryInfo = _owner.MemoryManager.QueryMemory(address); MemoryState memoryState = memoryInfo.State; if (!memoryState.HasFlag(MemoryState.Stack)) // Is this pointer within the stack? diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index 1b6433af6..c439a8fff 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -105,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall KProcess process = new(_context); - using var _ = new OnScopeExit(process.DecrementReferenceCount); + using OnScopeExit _ = new OnScopeExit(process.DecrementReferenceCount); KResourceLimit resourceLimit; @@ -1425,7 +1425,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall KCodeMemory codeMemory = new(_context); - using var _ = new OnScopeExit(codeMemory.DecrementReferenceCount); + using OnScopeExit _ = new OnScopeExit(codeMemory.DecrementReferenceCount); KProcess currentProcess = KernelStatic.GetCurrentProcess(); @@ -2854,7 +2854,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall KThread currentThread = KernelStatic.GetCurrentThread(); - var syncObjs = new Span(currentThread.WaitSyncObjects)[..handles.Length]; + Span syncObjs = new Span(currentThread.WaitSyncObjects)[..handles.Length]; if (handles.Length != 0) { diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs index 0c63c7e0e..ca4aedb7a 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs @@ -562,8 +562,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading Action removeCallback, Func predicate) { - var candidates = threads.Where(predicate).OrderBy(x => x.DynamicPriority); - var toSignal = (count > 0 ? candidates.Take(count) : candidates).ToArray(); + IOrderedEnumerable candidates = threads.Where(predicate).OrderBy(x => x.DynamicPriority); + KThread[] toSignal = (count > 0 ? candidates.Take(count) : candidates).ToArray(); foreach (KThread thread in toSignal) { diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KPriorityQueue.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KPriorityQueue.cs index 1608db095..7951fab5b 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KPriorityQueue.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KPriorityQueue.cs @@ -127,7 +127,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading public KThread ScheduledThreadsElementAtOrDefault(int core, int index) { int currentIndex = 0; - foreach (var scheduledThread in ScheduledThreads(core)) + foreach (KThread scheduledThread in ScheduledThreads(core)) { if (currentIndex == index) { @@ -144,7 +144,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading public KThread ScheduledThreadsWithDynamicPriorityFirstOrDefault(int core, int dynamicPriority) { - foreach (var scheduledThread in ScheduledThreads(core)) + foreach (KThread scheduledThread in ScheduledThreads(core)) { if (scheduledThread.DynamicPriority == dynamicPriority) { diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs index 35ff74cb3..ce0810990 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs @@ -1232,7 +1232,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading { if (_schedulerWaitEvent == null) { - var schedulerWaitEvent = new ManualResetEvent(false); + ManualResetEvent schedulerWaitEvent = new ManualResetEvent(false); if (Interlocked.Exchange(ref _schedulerWaitEvent, schedulerWaitEvent) == null) { diff --git a/src/Ryujinx.HLE/HOS/LibHacHorizonManager.cs b/src/Ryujinx.HLE/HOS/LibHacHorizonManager.cs index e8ef15dce..46c27da40 100644 --- a/src/Ryujinx.HLE/HOS/LibHacHorizonManager.cs +++ b/src/Ryujinx.HLE/HOS/LibHacHorizonManager.cs @@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS public void InitializeFsServer(VirtualFileSystem virtualFileSystem) { - virtualFileSystem.InitializeFsServer(Server, out var fsClient); + virtualFileSystem.InitializeFsServer(Server, out HorizonClient fsClient); FsClient = fsClient; } diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index 4bd695ae5..76edcc322 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -3,6 +3,7 @@ using LibHac.Fs; using LibHac.Fs.Fsa; using LibHac.FsSystem; using LibHac.Loader; +using LibHac.Tools.Fs; using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem.RomFs; using Ryujinx.Common.Configuration; @@ -143,7 +144,7 @@ namespace Ryujinx.HLE.HOS private static string EnsureBaseDirStructure(string modsBasePath) { - var modsDir = new DirectoryInfo(modsBasePath); + DirectoryInfo modsDir = new DirectoryInfo(modsBasePath); modsDir.CreateSubdirectory(AmsContentsDir); modsDir.CreateSubdirectory(AmsNsoPatchDir); @@ -161,23 +162,23 @@ namespace Ryujinx.HLE.HOS { System.Text.StringBuilder types = new(); - foreach (var modDir in dir.EnumerateDirectories()) + foreach (DirectoryInfo modDir in dir.EnumerateDirectories()) { types.Clear(); Mod mod = new(string.Empty, null, true); if (StrEquals(RomfsDir, modDir.Name)) { - var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); - var enabled = modData?.Enabled ?? true; + Mod modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); + bool enabled = modData?.Enabled ?? true; mods.RomfsDirs.Add(mod = new Mod(dir.Name, modDir, enabled)); types.Append('R'); } else if (StrEquals(ExefsDir, modDir.Name)) { - var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); - var enabled = modData?.Enabled ?? true; + Mod modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); + bool enabled = modData?.Enabled ?? true; mods.ExefsDirs.Add(mod = new Mod(dir.Name, modDir, enabled)); types.Append('E'); @@ -200,8 +201,8 @@ namespace Ryujinx.HLE.HOS public static string GetApplicationDir(string modsBasePath, string applicationId) { - var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir)); - var applicationModsPath = FindApplicationDir(contentsDir, applicationId); + DirectoryInfo contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir)); + DirectoryInfo applicationModsPath = FindApplicationDir(contentsDir, applicationId); if (applicationModsPath == null) { @@ -243,7 +244,7 @@ namespace Ryujinx.HLE.HOS return; } - foreach (var modDir in patchDir.EnumerateDirectories()) + foreach (DirectoryInfo modDir in patchDir.EnumerateDirectories()) { patches.Add(new Mod(modDir.Name, modDir, true)); Logger.Info?.Print(LogClass.ModLoader, $"Found {type} patch '{modDir.Name}'"); @@ -272,11 +273,11 @@ namespace Ryujinx.HLE.HOS } } - var fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer)); + FileInfo fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer)); if (fsFile.Exists) { - var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); - var enabled = modData == null || modData.Enabled; + Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); + bool enabled = modData == null || modData.Enabled; mods.RomfsContainers.Add(new Mod($"<{applicationDir.Name} RomFs>", fsFile, enabled)); } @@ -284,8 +285,8 @@ namespace Ryujinx.HLE.HOS fsFile = new FileInfo(Path.Combine(applicationDir.FullName, ExefsContainer)); if (fsFile.Exists) { - var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); - var enabled = modData == null || modData.Enabled; + Mod modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); + bool enabled = modData == null || modData.Enabled; mods.ExefsContainers.Add(new Mod($"<{applicationDir.Name} ExeFs>", fsFile, enabled)); } @@ -302,7 +303,7 @@ namespace Ryujinx.HLE.HOS Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((applicationId & 0x1000) != 0 ? "DLC" : "Application")} {applicationId:X16} in \"{contentsDir.FullName}\""); - var applicationDir = FindApplicationDir(contentsDir, $"{applicationId:x16}"); + DirectoryInfo applicationDir = FindApplicationDir(contentsDir, $"{applicationId:x16}"); if (applicationDir != null) { @@ -429,9 +430,9 @@ namespace Ryujinx.HLE.HOS return false; } - foreach (var path in searchDirPaths) + foreach (string path in searchDirPaths) { - var searchDir = new DirectoryInfo(path); + DirectoryInfo searchDir = new DirectoryInfo(path); if (!searchDir.Exists) { Logger.Warning?.Print(LogClass.ModLoader, $"Mod Search Dir '{searchDir.FullName}' doesn't exist"); @@ -440,7 +441,7 @@ namespace Ryujinx.HLE.HOS if (!TryQuery(searchDir, patches, modCaches)) { - foreach (var subdir in searchDir.EnumerateDirectories()) + foreach (DirectoryInfo subdir in searchDir.EnumerateDirectories()) { TryQuery(subdir, patches, modCaches); } @@ -469,14 +470,14 @@ namespace Ryujinx.HLE.HOS return baseStorage; } - var fileSet = new HashSet(); - var builder = new RomFsBuilder(); + HashSet fileSet = new HashSet(); + RomFsBuilder builder = new RomFsBuilder(); int count = 0; Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Application {applicationId:X16}"); // Prioritize loose files first - foreach (var mod in mods.RomfsDirs) + foreach (Mod mod in mods.RomfsDirs) { if (!mod.Enabled) { @@ -491,7 +492,7 @@ namespace Ryujinx.HLE.HOS } // Then files inside images - foreach (var mod in mods.RomfsContainers) + foreach (Mod mod in mods.RomfsContainers) { if (!mod.Enabled) { @@ -516,12 +517,12 @@ namespace Ryujinx.HLE.HOS Logger.Info?.Print(LogClass.ModLoader, $"Replaced {fileSet.Count} file(s) over {count} mod(s). Processing base storage..."); // And finally, the base romfs - var baseRom = new RomFsFileSystem(baseStorage); - foreach (var entry in baseRom.EnumerateEntries() + RomFsFileSystem baseRom = new RomFsFileSystem(baseStorage); + foreach (DirectoryEntryEx entry in baseRom.EnumerateEntries() .Where(f => f.Type == DirectoryEntryType.File && !fileSet.Contains(f.FullPath)) .OrderBy(f => f.FullPath, StringComparer.Ordinal)) { - using var file = new UniqueRef(); + using UniqueRef file = new UniqueRef(); baseRom.OpenFile(ref file.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); builder.AddFile(entry.FullPath, file.Release()); @@ -536,12 +537,12 @@ namespace Ryujinx.HLE.HOS private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet fileSet, RomFsBuilder builder) { - foreach (var entry in fs.EnumerateEntries() + foreach (DirectoryEntryEx entry in fs.EnumerateEntries() .AsParallel() .Where(f => f.Type == DirectoryEntryType.File) .OrderBy(f => f.FullPath, StringComparer.Ordinal)) { - var file = new LazyFile(entry.FullPath, rootPath, fs); + LazyFile file = new LazyFile(entry.FullPath, rootPath, fs); if (fileSet.Add(entry.FullPath)) { @@ -568,7 +569,7 @@ namespace Ryujinx.HLE.HOS Logger.Info?.Print(LogClass.ModLoader, "Using replacement ExeFS partition"); - var pfs = new PartitionFileSystem(); + PartitionFileSystem pfs = new PartitionFileSystem(); pfs.Initialize(mods.ExefsContainers[0].Path.OpenRead().AsStorage()).ThrowIfFailure(); exefs = pfs; @@ -602,9 +603,9 @@ namespace Ryujinx.HLE.HOS throw new ArgumentOutOfRangeException(nameof(nsos), nsos.Length, "NSO Count is incorrect"); } - var exeMods = mods.ExefsDirs; + List> exeMods = mods.ExefsDirs; - foreach (var mod in exeMods) + foreach (Mod mod in exeMods) { if (!mod.Enabled) { @@ -613,7 +614,7 @@ namespace Ryujinx.HLE.HOS for (int i = 0; i < ProcessConst.ExeFsPrefixes.Length; ++i) { - var nsoName = ProcessConst.ExeFsPrefixes[i]; + string nsoName = ProcessConst.ExeFsPrefixes[i]; FileInfo nsoFile = new(Path.Combine(mod.Path.FullName, nsoName)); if (nsoFile.Exists) @@ -665,7 +666,7 @@ namespace Ryujinx.HLE.HOS internal void ApplyNroPatches(NroExecutable nro) { - var nroPatches = _patches.NroPatches; + List> nroPatches = _patches.NroPatches; if (nroPatches.Count == 0) { @@ -707,11 +708,11 @@ namespace Ryujinx.HLE.HOS return; } - var cheats = mods.Cheats; - var processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v }) + List cheats = mods.Cheats; + Dictionary processExes = tamperInfo.BuildIds.Zip(tamperInfo.CodeAddresses, (k, v) => new { k, v }) .ToDictionary(x => x.k[..Math.Min(Cheat.CheatIdSize, x.k.Length)], x => x.v); - foreach (var cheat in cheats) + foreach (Cheat cheat in cheats) { string cheatId = Path.GetFileNameWithoutExtension(cheat.Path.Name).ToUpper(); @@ -732,7 +733,7 @@ namespace Ryujinx.HLE.HOS internal static void EnableCheats(ulong applicationId, TamperMachine tamperMachine) { - var contentDirectory = FindApplicationDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{applicationId:x16}"); + DirectoryInfo contentDirectory = FindApplicationDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{applicationId:x16}"); string enabledCheatsPath = Path.Combine(contentDirectory.FullName, CheatDir, "enabled.txt"); if (File.Exists(enabledCheatsPath)) @@ -752,11 +753,11 @@ namespace Ryujinx.HLE.HOS patches[i] = new MemPatch(); } - var buildIds = new List(programs.Length); + List buildIds = new List(programs.Length); foreach (IExecutable p in programs) { - var buildId = p switch + string buildId = p switch { NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), @@ -768,15 +769,15 @@ namespace Ryujinx.HLE.HOS int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small // Collect patches - foreach (var mod in mods) + foreach (Mod mod in mods) { if (!mod.Enabled) { continue; } - var patchDir = mod.Path; - foreach (var patchFile in patchDir.EnumerateFiles()) + DirectoryInfo patchDir = mod.Path; + foreach (FileInfo patchFile in patchDir.EnumerateFiles()) { if (StrEquals(".ips", patchFile.Extension)) // IPS|IPS32 { @@ -791,18 +792,18 @@ namespace Ryujinx.HLE.HOS Logger.Info?.Print(LogClass.ModLoader, $"Matching IPS patch '{patchFile.Name}' in '{mod.Name}' bid={buildId}"); - using var fs = patchFile.OpenRead(); - using var reader = new BinaryReader(fs); + using FileStream fs = patchFile.OpenRead(); + using BinaryReader reader = new BinaryReader(fs); - var patcher = new IpsPatcher(reader); + IpsPatcher patcher = new IpsPatcher(reader); patcher.AddPatches(patches[index]); } else if (StrEquals(".pchtxt", patchFile.Extension)) // IPSwitch { - using var fs = patchFile.OpenRead(); - using var reader = new StreamReader(fs); + using FileStream fs = patchFile.OpenRead(); + using StreamReader reader = new StreamReader(fs); - var patcher = new IPSwitchPatcher(reader); + IPSwitchPatcher patcher = new IPSwitchPatcher(reader); int index = GetIndex(patcher.BuildId); if (index == -1) diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs index d2da9e248..279e696be 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountManager.cs @@ -191,10 +191,10 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc private void DeleteSaveData(UserId userId) { - var saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default, + SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: default, new LibHac.Fs.UserId((ulong)userId.High, (ulong)userId.Low), saveDataId: default, index: default); - using var saveDataIterator = new UniqueRef(); + using UniqueRef saveDataIterator = new UniqueRef(); _horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs index 6fdfe1398..aa6fa57c4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs @@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc { ProfilesJson profilesJson = JsonHelper.DeserializeFromFile(_profilesJsonPath, _serializerContext.ProfilesJson); - foreach (var profile in profilesJson.Profiles) + foreach (UserProfileJson profile in profilesJson.Profiles) { UserProfile addedProfile = new(new UserId(profile.UserId), profile.Name, profile.Image, profile.LastModifiedTimestamp); @@ -69,7 +69,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc LastOpened = LastOpened.ToString(), }; - foreach (var profile in profiles) + foreach (KeyValuePair profile in profiles) { profilesJson.Profiles.Add(new UserProfileJson() { diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs index 75bad0e3f..7f98b0044 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountService/ManagerServer.cs @@ -51,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService byte[] deviceAccountId = new byte[0x10]; RandomNumberGenerator.Fill(deviceId); - var descriptor = new SecurityTokenDescriptor + SecurityTokenDescriptor descriptor = new SecurityTokenDescriptor { Subject = new GenericIdentity(Convert.ToHexString(rawUserId).ToLower()), SigningCredentials = credentials, diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs index 602fc2c4d..f58e5b891 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ICommonStateGetter.cs @@ -214,7 +214,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys _vrModeEnabled = vrModeEnabled; - using var lblApi = new LblApi(); + using LblApi lblApi = new LblApi(); if (vrModeEnabled) { diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs b/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs index bf0c7e9dc..67cbb81ac 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/CaptureManager.cs @@ -118,10 +118,10 @@ namespace Ryujinx.HLE.HOS.Services.Caps } // NOTE: The saved JPEG file doesn't have the limitation in the extra EXIF data. - using var bitmap = new SKBitmap(new SKImageInfo(1280, 720, SKColorType.Rgba8888)); + using SKBitmap bitmap = new SKBitmap(new SKImageInfo(1280, 720, SKColorType.Rgba8888)); Marshal.Copy(screenshotData, 0, bitmap.GetPixels(), screenshotData.Length); - using var data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80); - using var file = File.OpenWrite(filePath); + using SKData data = bitmap.Encode(SKEncodedImageFormat.Jpeg, 80); + using FileStream file = File.OpenWrite(filePath); data.SaveTo(file); return ResultCode.Success; diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs index 20ffb996d..796ece16c 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/FileSystemProxyHelper.cs @@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy try { LocalStorage storage = new(pfsPath, FileAccess.Read, FileMode.Open); - var pfs = new PartitionFileSystem(); + PartitionFileSystem pfs = new PartitionFileSystem(); using SharedRef nsp = new(pfs); pfs.Initialize(storage).ThrowIfFailure(); @@ -58,7 +58,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy } LibHac.Fs.Fsa.IFileSystem fileSystem = nca.OpenFileSystem(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); - using var sharedFs = new SharedRef(fileSystem); + using SharedRef sharedFs = new SharedRef(fileSystem); using SharedRef adapter = FileSystemInterfaceAdapter.CreateShared(ref sharedFs.Ref, true); @@ -99,7 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy string filename = fullPath.Replace(archivePath.FullName, string.Empty).TrimStart('\\'); - using var ncaFile = new UniqueRef(); + using UniqueRef ncaFile = new UniqueRef(); Result result = nsp.OpenFile(ref ncaFile.Ref, filename.ToU8Span(), OpenMode.Read); if (result.IsFailure()) @@ -122,14 +122,14 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { foreach (DirectoryEntryEx ticketEntry in nsp.EnumerateEntries("/", "*.tik")) { - using var ticketFile = new UniqueRef(); + using UniqueRef ticketFile = new UniqueRef(); Result result = nsp.OpenFile(ref ticketFile.Ref, ticketEntry.FullPath.ToU8Span(), OpenMode.Read); if (result.IsSuccess()) { Ticket ticket = new(ticketFile.Get.AsStream()); - var titleKey = ticket.GetTitleKey(keySet); + byte[] titleKey = ticket.GetTitleKey(keySet); if (titleKey != null) { diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs index 70d3a6bd8..0fe7bcdd6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IDirectory.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Common; using LibHac.Sf; +using Ryujinx.Memory; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { @@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); Result result = _baseDirectory.Get.Read(out long entriesRead, new OutBuffer(region.Memory.Span)); context.ResponseData.Write(entriesRead); diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs index dcc34a754..0ea57f5a4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFile.cs @@ -3,6 +3,7 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Sf; using Ryujinx.Common; +using Ryujinx.Memory; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy { @@ -28,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy long offset = context.RequestData.ReadInt64(); long size = context.RequestData.ReadInt64(); - using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); Result result = _baseFile.Get.Read(out long bytesRead, offset, new OutBuffer(region.Memory.Span), size, readOption); context.ResponseData.Write(bytesRead); diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs index e19d17912..ff0cb7aed 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IFileSystem.cs @@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy uint mode = context.RequestData.ReadUInt32(); ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context); - using var file = new SharedRef(); + using SharedRef file = new SharedRef(); Result result = _fileSystem.Get.OpenFile(ref file.Ref, in name, mode); @@ -132,7 +132,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy uint mode = context.RequestData.ReadUInt32(); ref readonly Path name = ref FileSystemProxyHelper.GetSfPath(context); - using var dir = new SharedRef(); + using SharedRef dir = new SharedRef(); Result result = _fileSystem.Get.OpenDirectory(ref dir.Ref, name, mode); diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs index ad4cccc44..04dc6c688 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/IStorage.cs @@ -3,6 +3,7 @@ using LibHac.Common; using LibHac.Sf; using Ryujinx.Common; using Ryujinx.Common.Configuration; +using Ryujinx.Memory; using System.Threading; namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy @@ -38,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy size = bufferLen; } - using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); Result result = _baseStorage.Get.Read((long)offset, new OutBuffer(region.Memory.Span), (long)size); if (context.Device.DirtyHacks.IsEnabled(DirtyHack.Xc2MenuSoftlockFix) && IsXc2) diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs index 24dd1e9be..4ccc7cc92 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs @@ -3,6 +3,7 @@ using LibHac.Common; using LibHac.Fs; using LibHac.Fs.Shim; using LibHac.FsSrv.Impl; +using LibHac.FsSrv.Sf; using LibHac.FsSystem; using LibHac.Ncm; using LibHac.Sf; @@ -12,10 +13,12 @@ using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy; +using Ryujinx.Memory; using System; using System.IO; using static Ryujinx.HLE.Utilities.StringUtils; using GameCardHandle = System.UInt32; +using IFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.IFile; using IFileSystem = LibHac.FsSrv.Sf.IFileSystem; using IStorage = LibHac.FsSrv.Sf.IStorage; @@ -29,7 +32,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public IFileSystemProxy(ServiceCtx context) : base(context.Device.System.FsServer) { - var applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient; + HorizonClient applicationClient = context.Device.System.LibHacHorizonManager.ApplicationClient; _baseFileSystemProxy = applicationClient.Fs.Impl.GetFileSystemProxyServiceObject(); } @@ -106,8 +109,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs { BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32(); - ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); - using var fileSystem = new SharedRef(); + ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenBisFileSystem(ref fileSystem.Ref, in path, bisPartitionId); if (result.IsFailure()) @@ -125,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenBisStorage(ServiceCtx context) { BisPartitionId bisPartitionId = (BisPartitionId)context.RequestData.ReadInt32(); - using var storage = new SharedRef(); + using SharedRef storage = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenBisStorage(ref storage.Ref, bisPartitionId); if (result.IsFailure()) @@ -149,7 +152,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenSdCardFileSystem() -> object public ResultCode OpenSdCardFileSystem(ServiceCtx context) { - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSdCardFileSystem(ref fileSystem.Ref); if (result.IsFailure()) @@ -257,7 +260,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { GameCardHandle handle = context.RequestData.ReadUInt32(); GameCardPartitionRaw partitionId = (GameCardPartitionRaw)context.RequestData.ReadInt32(); - using var storage = new SharedRef(); + using SharedRef storage = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenGameCardStorage(ref storage.Ref, handle, partitionId); if (result.IsFailure()) @@ -276,7 +279,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { GameCardHandle handle = context.RequestData.ReadUInt32(); GameCardPartition partitionId = (GameCardPartition)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenGameCardFileSystem(ref fileSystem.Ref, handle, partitionId); if (result.IsFailure()) @@ -357,7 +360,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); if (result.IsFailure()) @@ -376,7 +379,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataFileSystemBySystemSaveDataId(ref fileSystem.Ref, spaceId, in attribute); if (result.IsFailure()) @@ -395,7 +398,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenReadOnlySaveDataFileSystem(ref fileSystem.Ref, spaceId, in attribute); if (result.IsFailure()) @@ -466,7 +469,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenSaveDataInfoReader() -> object public ResultCode OpenSaveDataInfoReader(ServiceCtx context) { - using var infoReader = new SharedRef(); + using SharedRef infoReader = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReader(ref infoReader.Ref); if (result.IsFailure()) @@ -484,7 +487,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenSaveDataInfoReaderBySaveDataSpaceId(ServiceCtx context) { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadByte(); - using var infoReader = new SharedRef(); + using SharedRef infoReader = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderBySaveDataSpaceId(ref infoReader.Ref, spaceId); if (result.IsFailure()) @@ -501,7 +504,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenSaveDataInfoReaderOnlyCacheStorage() -> object public ResultCode OpenSaveDataInfoReaderOnlyCacheStorage(ServiceCtx context) { - using var infoReader = new SharedRef(); + using SharedRef infoReader = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderOnlyCacheStorage(ref infoReader.Ref); if (result.IsFailure()) @@ -520,7 +523,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); ulong saveDataId = context.RequestData.ReadUInt64(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInternalStorageFileSystem(ref fileSystem.Ref, spaceId, saveDataId); if (result.IsFailure()) @@ -567,7 +570,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); Result result = _baseFileSystemProxy.Get.FindSaveDataWithFilter(out long count, new OutBuffer(region.Memory.Span), spaceId, in filter); if (result.IsFailure()) { @@ -584,7 +587,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs { SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataFilter filter = context.RequestData.ReadStruct(); - using var infoReader = new SharedRef(); + using SharedRef infoReader = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataInfoReaderWithFilter(ref infoReader.Ref, spaceId, in filter); if (result.IsFailure()) @@ -661,7 +664,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt32(); SaveDataMetaType metaType = (SaveDataMetaType)context.RequestData.ReadInt32(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); - using var file = new SharedRef(); + using SharedRef file = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenSaveDataMetaFile(ref file.Ref, spaceId, in attribute, metaType); if (result.IsFailure()) @@ -699,7 +702,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenImageDirectoryFileSystem(ServiceCtx context) { ImageDirectoryId directoryId = (ImageDirectoryId)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenImageDirectoryFileSystem(ref fileSystem.Ref, directoryId); if (result.IsFailure()) @@ -716,7 +719,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenBaseFileSystem(ServiceCtx context) { BaseFileSystemId fileSystemId = (BaseFileSystemId)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenBaseFileSystem(ref fileSystem.Ref, fileSystemId); if (result.IsFailure()) @@ -733,7 +736,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenContentStorageFileSystem(ServiceCtx context) { ContentStorageId contentStorageId = (ContentStorageId)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenContentStorageFileSystem(ref fileSystem.Ref, contentStorageId); if (result.IsFailure()) @@ -750,7 +753,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenCloudBackupWorkStorageFileSystem(ServiceCtx context) { CloudBackupWorkStorageId storageId = (CloudBackupWorkStorageId)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenCloudBackupWorkStorageFileSystem(ref fileSystem.Ref, storageId); if (result.IsFailure()) @@ -767,7 +770,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode OpenCustomStorageFileSystem(ServiceCtx context) { CustomStorageId customStorageId = (CustomStorageId)context.RequestData.ReadInt32(); - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenCustomStorageFileSystem(ref fileSystem.Ref, customStorageId); if (result.IsFailure()) @@ -784,9 +787,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenDataStorageByCurrentProcess() -> object dataStorage public ResultCode OpenDataStorageByCurrentProcess(ServiceCtx context) { - var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); - using var sharedStorage = new SharedRef(storage); - using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); + LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); + using SharedRef sharedStorage = new SharedRef(storage); + using SharedRef sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); @@ -809,9 +812,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs { Logger.Info?.Print(LogClass.Loader, $"Opened AddOnContent Data TitleID={titleId:X16}"); - var storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage); - using var sharedStorage = new SharedRef(storage); - using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); + LibHac.Fs.IStorage storage = context.Device.FileSystem.ModLoader.ApplyRomFsMods(titleId, aocStorage); + using SharedRef sharedStorage = new SharedRef(storage); + using SharedRef sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); @@ -845,8 +848,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs LibHac.Fs.IStorage ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open); Nca nca = new(context.Device.System.KeySet, ncaStorage); LibHac.Fs.IStorage romfsStorage = nca.OpenStorage(NcaSectionType.Data, context.Device.System.FsIntegrityCheckLevel); - using var sharedStorage = new SharedRef(romfsStorage); - using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); + using SharedRef sharedStorage = new SharedRef(romfsStorage); + using SharedRef sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); } @@ -875,9 +878,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenPatchDataStorageByCurrentProcess() -> object public ResultCode OpenPatchDataStorageByCurrentProcess(ServiceCtx context) { - var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); - using var sharedStorage = new SharedRef(storage); - using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); + LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); + using SharedRef sharedStorage = new SharedRef(storage); + using SharedRef sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); @@ -895,9 +898,9 @@ namespace Ryujinx.HLE.HOS.Services.Fs throw new NotImplementedException($"Accessing storage from other programs is not supported (program index = {programIndex})."); } - var storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); - using var sharedStorage = new SharedRef(storage); - using var sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); + LibHac.Fs.IStorage storage = context.Device.FileSystem.GetRomFs(_pid).AsStorage(true); + using SharedRef sharedStorage = new SharedRef(storage); + using SharedRef sfStorage = new SharedRef(new StorageInterfaceAdapter(ref sharedStorage.Ref)); MakeObject(context, new FileSystemProxy.IStorage(ref sfStorage.Ref)); @@ -908,7 +911,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenDataStorageByCurrentProcess() -> object dataStorage public ResultCode OpenDeviceOperator(ServiceCtx context) { - using var deviceOperator = new SharedRef(); + using SharedRef deviceOperator = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenDeviceOperator(ref deviceOperator.Ref); if (result.IsFailure()) @@ -1023,7 +1026,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [CommandCmif(609)] public ResultCode GetRightsIdByPath(ServiceCtx context) { - ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); + ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); Result result = _baseFileSystemProxy.Get.GetRightsIdByPath(out RightsId rightsId, in path); if (result.IsFailure()) @@ -1039,7 +1042,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [CommandCmif(610)] public ResultCode GetRightsIdAndKeyGenerationByPath(ServiceCtx context) { - ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); + ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); Result result = _baseFileSystemProxy.Get.GetRightsIdAndKeyGenerationByPath(out RightsId rightsId, out byte keyGeneration, in path); if (result.IsFailure()) @@ -1236,7 +1239,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs public ResultCode SetBisRootForHost(ServiceCtx context) { BisPartitionId partitionId = (BisPartitionId)context.RequestData.ReadInt32(); - ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); + ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); return (ResultCode)_baseFileSystemProxy.Get.SetBisRootForHost(partitionId, in path).Value; } @@ -1253,7 +1256,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [CommandCmif(1002)] public ResultCode SetSaveDataRootPath(ServiceCtx context) { - ref readonly var path = ref FileSystemProxyHelper.GetFspPath(context); + ref readonly FspPath path = ref FileSystemProxyHelper.GetFspPath(context); return (ResultCode)_baseFileSystemProxy.Get.SetSaveDataRootPath(in path).Value; } @@ -1307,7 +1310,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs [CommandCmif(1008)] public ResultCode OpenRegisteredUpdatePartition(ServiceCtx context) { - using var fileSystem = new SharedRef(); + using SharedRef fileSystem = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenRegisteredUpdatePartition(ref fileSystem.Ref); if (result.IsFailure()) @@ -1417,7 +1420,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs // OpenMultiCommitManager() -> object public ResultCode OpenMultiCommitManager(ServiceCtx context) { - using var commitManager = new SharedRef(); + using SharedRef commitManager = new SharedRef(); Result result = _baseFileSystemProxy.Get.OpenMultiCommitManager(ref commitManager.Ref); if (result.IsFailure()) diff --git a/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs b/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs index 7ed6dadc2..b86eb1fa1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Fs/ISaveDataInfoReader.cs @@ -1,6 +1,7 @@ using LibHac; using LibHac.Common; using LibHac.Sf; +using Ryujinx.Memory; namespace Ryujinx.HLE.HOS.Services.Fs { @@ -20,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Fs ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); + using WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true); Result result = _baseReader.Get.Read(out long readCount, new OutBuffer(region.Memory.Span)); context.ResponseData.Write(readCount); diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs index a13e77e72..28caf4459 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs @@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs { IrCameraHandle irCameraHandle = context.RequestData.ReadStruct(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedMomentProcessorConfig = context.RequestData.ReadStruct(); + PackedMomentProcessorConfig packedMomentProcessorConfig = context.RequestData.ReadStruct(); CheckCameraHandle(irCameraHandle); @@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs { IrCameraHandle irCameraHandle = context.RequestData.ReadStruct(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedClusteringProcessorConfig = context.RequestData.ReadStruct(); + PackedClusteringProcessorConfig packedClusteringProcessorConfig = context.RequestData.ReadStruct(); CheckCameraHandle(irCameraHandle); @@ -111,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs { IrCameraHandle irCameraHandle = context.RequestData.ReadStruct(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedImageTransferProcessorConfig = context.RequestData.ReadStruct(); + PackedImageTransferProcessorConfig packedImageTransferProcessorConfig = context.RequestData.ReadStruct(); CheckCameraHandle(irCameraHandle); @@ -157,7 +157,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs { IrCameraHandle irCameraHandle = context.RequestData.ReadStruct(); ulong appletResourceUserId = context.RequestData.ReadUInt64(); - var packedTeraPluginProcessorConfig = context.RequestData.ReadStruct(); + PackedTeraPluginProcessorConfig packedTeraPluginProcessorConfig = context.RequestData.ReadStruct(); CheckCameraHandle(irCameraHandle); diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs index b8b3014f1..438f532ee 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator // TODO: Call nn::arp::GetApplicationControlProperty here when implemented. ApplicationControlProperty controlProperty = context.Device.Processes.ActiveApplication.ApplicationControlProperties; - foreach (var localCommunicationId in controlProperty.LocalCommunicationId.ItemsRo) + foreach (ulong localCommunicationId in controlProperty.LocalCommunicationId.ItemsRo) { if (localCommunicationId == localCommunicationIdChecked) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs index 8b7af42a0..e6b8ab1ec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs @@ -244,7 +244,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm byte[] ip = address.GetAddressBytes(); - var macAddress = new Array6(); + Array6 macAddress = new Array6(); new byte[] { 0x02, 0x00, ip[0], ip[1], ip[2], ip[3] }.CopyTo(macAddress.AsSpan()); return macAddress; diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs index 536ae476d..b1040e646 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs @@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy lock (_scanLock) { - var newResults = _scanResultsLast; + Dictionary newResults = _scanResultsLast; newResults.Clear(); _scanResultsLast = _scanResults; @@ -138,7 +138,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy lock (_scanLock) { - var results = new Dictionary(); + Dictionary results = new Dictionary(); foreach (KeyValuePair last in _scanResultsLast) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs index 4c7814b8e..a21fb190a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs @@ -490,7 +490,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu SendAsync(_protocol.Encode(PacketId.CreateAccessPoint, request, advertiseData)); // Send a network change event with dummy data immediately. Necessary to avoid crashes in some games - var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() + NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() { Common = new CommonNetworkInfo() { @@ -610,7 +610,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu SendAsync(_protocol.Encode(PacketId.Connect, request)); - var networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() + NetworkChangeEventArgs networkChangeEvent = new NetworkChangeEventArgs(new NetworkInfo() { Common = request.NetworkInfo.Common, Ldn = request.NetworkInfo.Ldn diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxySocket.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxySocket.cs index ed7a9c751..705e67ecd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxySocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxySocket.cs @@ -256,7 +256,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy { _proxy.ReturnEphemeralPort(ProtocolType, (ushort)((IPEndPoint)LocalEndPoint).Port); } - var asIPEndpoint = (IPEndPoint)localEP; + IPEndPoint asIPEndpoint = (IPEndPoint)localEP; if (asIPEndpoint.Port == 0) { asIPEndpoint.Port = (ushort)_proxy.GetEphemeralPort(ProtocolType); diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs index aaeb8aa10..bbef717ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/Types/CoreData.cs @@ -440,18 +440,18 @@ namespace Ryujinx.HLE.HOS.Services.Mii.Types int indexFor4 = 3 * (int)age + 9 * (int)gender + (int)race; - var facelineTypeInfo = RandomMiiFacelineArray[indexFor4]; - var facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race]; - var facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4]; - var facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4]; - var hairTypeInfo = RandomMiiHairTypeArray[indexFor4]; - var hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age]; - var eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4]; - var eyeColorInfo = RandomMiiEyeColorArray[(int)race]; - var eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4]; - var noseTypeInfo = RandomMiiNoseTypeArray[indexFor4]; - var mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4]; - var glassTypeInfo = RandomMiiGlassTypeArray[(int)age]; + RandomMiiData4 facelineTypeInfo = RandomMiiFacelineArray[indexFor4]; + RandomMiiData3 facelineColorInfo = RandomMiiFacelineColorArray[3 * (int)gender + (int)race]; + RandomMiiData4 facelineWrinkleInfo = RandomMiiFacelineWrinkleArray[indexFor4]; + RandomMiiData4 facelineMakeInfo = RandomMiiFacelineMakeArray[indexFor4]; + RandomMiiData4 hairTypeInfo = RandomMiiHairTypeArray[indexFor4]; + RandomMiiData3 hairColorInfo = RandomMiiHairColorArray[3 * (int)race + (int)age]; + RandomMiiData4 eyeTypeInfo = RandomMiiEyeTypeArray[indexFor4]; + RandomMiiData2 eyeColorInfo = RandomMiiEyeColorArray[(int)race]; + RandomMiiData4 eyebrowTypeInfo = RandomMiiEyebrowTypeArray[indexFor4]; + RandomMiiData4 noseTypeInfo = RandomMiiNoseTypeArray[indexFor4]; + RandomMiiData4 mouthTypeInfo = RandomMiiMouthTypeArray[indexFor4]; + RandomMiiData2 glassTypeInfo = RandomMiiGlassTypeArray[(int)age]; // Faceline coreData.FacelineType = (FacelineType)facelineTypeInfo.Values[utilImpl.GetRandom(facelineTypeInfo.ValuesCount)]; diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDecryptor.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDecryptor.cs index cc6d02ea2..245c37742 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDecryptor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDecryptor.cs @@ -9,8 +9,8 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption public AmiiboDecryptor(string keyRetailBinPath) { - var combinedKeys = File.ReadAllBytes(keyRetailBinPath); - var keys = AmiiboMasterKey.FromCombinedBin(combinedKeys); + byte[] combinedKeys = File.ReadAllBytes(keyRetailBinPath); + (AmiiboMasterKey DataKey, AmiiboMasterKey TagKey) keys = AmiiboMasterKey.FromCombinedBin(combinedKeys); DataKey = keys.DataKey; TagKey = keys.TagKey; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDump.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDump.cs index 37d587dac..c5788a4b9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDump.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboDump.cs @@ -85,13 +85,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption if (deriveAes) { // Derive AES Key and IV - var dataForAes = new byte[2 + seedBytes.Length]; + byte[] dataForAes = new byte[2 + seedBytes.Length]; dataForAes[0] = 0x00; dataForAes[1] = 0x00; // Counter (0) Array.Copy(seedBytes, 0, dataForAes, 2, seedBytes.Length); byte[] derivedBytes; - using (var hmac = new HMACSHA256(key.HmacKey)) + using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) { derivedBytes = hmac.ComputeHash(dataForAes); } @@ -100,12 +100,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption derivedAesIv = derivedBytes.Skip(16).Take(16).ToArray(); // Derive HMAC Key - var dataForHmacKey = new byte[2 + seedBytes.Length]; + byte[] dataForHmacKey = new byte[2 + seedBytes.Length]; dataForHmacKey[0] = 0x00; dataForHmacKey[1] = 0x01; // Counter (1) Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length); - using (var hmac = new HMACSHA256(key.HmacKey)) + using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) { derivedBytes = hmac.ComputeHash(dataForHmacKey); } @@ -115,13 +115,13 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption else { // Derive HMAC Key only - var dataForHmacKey = new byte[2 + seedBytes.Length]; + byte[] dataForHmacKey = new byte[2 + seedBytes.Length]; dataForHmacKey[0] = 0x00; dataForHmacKey[1] = 0x01; // Counter (1) Array.Copy(seedBytes, 0, dataForHmacKey, 2, seedBytes.Length); byte[] derivedBytes; - using (var hmac = new HMACSHA256(key.HmacKey)) + using (HMACSHA256 hmac = new HMACSHA256(key.HmacKey)) { derivedBytes = hmac.ComputeHash(dataForHmacKey); } @@ -229,7 +229,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption Array.Copy(data, 0x054, tagHmacData, 8, 44); byte[] tagHmac; - using (var hmac = new HMACSHA256(hmacTagKey)) + using (HMACSHA256 hmac = new HMACSHA256(hmacTagKey)) { tagHmac = hmac.ComputeHash(tagHmacData); } @@ -258,7 +258,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption Array.Copy(data, 0x054, dataHmacData, offset, len5); byte[] dataHmac; - using (var hmac = new HMACSHA256(hmacDataKey)) + using (HMACSHA256 hmac = new HMACSHA256(hmacDataKey)) { dataHmac = hmac.ComputeHash(dataHmacData); } @@ -278,7 +278,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption Array.Copy(data, 0x054, tagHmacData, 8, 44); byte[] calculatedTagHmac; - using (var hmac = new HMACSHA256(hmacTagKey)) + using (HMACSHA256 hmac = new HMACSHA256(hmacTagKey)) { calculatedTagHmac = hmac.ComputeHash(tagHmacData); } @@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption Array.Copy(data, 0x054, dataHmacData, offset, len5); byte[] calculatedDataHmac; - using (var hmac = new HMACSHA256(hmacDataKey)) + using (HMACSHA256 hmac = new HMACSHA256(hmacDataKey)) { calculatedDataHmac = hmac.ComputeHash(dataHmacData); } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs index 7c7ebf22d..57b31e662 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/Host1xContext.cs @@ -18,8 +18,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv MemoryAllocator = new NvMemoryAllocator(); Host1x = new Host1xDevice(gpu.Synchronization); Smmu = gpu.CreateDeviceMemoryManager(pid); - var nvdec = new NvdecDevice(Smmu); - var vic = new VicDevice(Smmu); + NvdecDevice nvdec = new NvdecDevice(Smmu); + VicDevice vic = new VicDevice(Smmu); Host1x.RegisterDevice(ClassId.Nvdec, nvdec); Host1x.RegisterDevice(ClassId.Vic, vic); } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs index 0f5d7547c..3422343fd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs @@ -104,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu private NvInternalResult BindChannel(ref BindChannelArguments arguments) { - var channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData(arguments.Fd); + NvHostChannelDeviceFile channelDeviceFile = INvDrvServices.DeviceFileIdRegistry.GetData(arguments.Fd); if (channelDeviceFile == null) { // TODO: Return invalid Fd error. @@ -336,9 +336,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu for (uint i = 0; i < writeEntries; i++) { - ref var region = ref arguments.Regions[(int)i]; + ref VaRegion region = ref arguments.Regions[(int)i]; - var vmRegion = _vmRegions[i]; + VmRegion vmRegion = _vmRegions[i]; uint pageSize = _pageSizes[i]; region.PageSize = pageSize; diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs index bc70b05cf..f81c2edef 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs @@ -169,7 +169,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel { NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBuffer.Mem); - var data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4); + ReadOnlySpan data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4); _host1xContext.Host1x.Submit(MemoryMarshal.Cast(data), _contextId); } diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs index 56d389cd2..25666c2fd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pdm/QueryService/QueryPlayStatisticsManager.cs @@ -55,7 +55,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pdm.QueryService MemoryHelper.FillWithZeros(context.Memory, outputPosition, (int)outputSize); // Return ResultCode.ServiceUnavailable if data is locked by another process. - var filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable(); + IEnumerable> filteredApplicationPlayStatistics = _applicationPlayStatistics.AsEnumerable(); if (queryCapability == PlayLogQueryCapability.None) { diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs index 0e02220a0..3cc43a551 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs @@ -76,7 +76,7 @@ namespace Ryujinx.HLE.HOS.Services.Sdb.Pl Nca nca = new(_device.System.KeySet, ncaFileStream); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel); - using var fontFile = new UniqueRef(); + using UniqueRef fontFile = new UniqueRef(); romfs.OpenFile(ref fontFile.Ref, ("/" + fontFilename).ToU8Span(), OpenMode.Read).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index 40329aa36..0fd5ab670 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; @@ -235,7 +236,7 @@ namespace Ryujinx.HLE.HOS.Services } } - var rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1); + Result rc = _context.Syscall.ReplyAndReceive(out int signaledIndex, handles.AsSpan(0, handleCount), replyTargetHandle, -1); _selfThread.HandlePostSyscall(); @@ -307,7 +308,7 @@ namespace Ryujinx.HLE.HOS.Services { _context.Syscall.CloseHandle(serverSessionHandle); - if (RemoveSessionObj(serverSessionHandle, out var session)) + if (RemoveSessionObj(serverSessionHandle, out IpcService session)) { (session as IDisposable)?.Dispose(); } @@ -453,7 +454,7 @@ namespace Ryujinx.HLE.HOS.Services response.RawData = _responseDataStream.ToArray(); - using var responseStream = response.GetStreamTipc(); + using RecyclableMemoryStream responseStream = response.GetStreamTipc(); _selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence()); } else @@ -463,7 +464,7 @@ namespace Ryujinx.HLE.HOS.Services if (!isTipcCommunication) { - using var responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48)); + using RecyclableMemoryStream responseStream = response.GetStream((long)_selfThread.TlsAddress, recvListAddr | ((ulong)PointerBufferSize << 48)); _selfProcess.CpuMemory.Write(_selfThread.TlsAddress, responseStream.GetReadOnlySequence()); } diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs index 846c4dc4f..df2f76563 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs @@ -326,7 +326,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel); - using var firmwareFile = new UniqueRef(); + using UniqueRef firmwareFile = new UniqueRef(); Result result = firmwareRomFs.OpenFile(ref firmwareFile.Ref, "/file".ToU8Span(), OpenMode.Read); if (result.IsFailure()) diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 3a40a4ac5..273f6c5ca 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -315,9 +315,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd } } - using var readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); - using var writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize); - using var errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize); + using WritableRegion readFdsOut = context.Memory.GetWritableRegion(readFdsOutBufferPosition, (int)readFdsOutBufferSize); + using WritableRegion writeFdsOut = context.Memory.GetWritableRegion(writeFdsOutBufferPosition, (int)writeFdsOutBufferSize); + using WritableRegion errorFdsOut = context.Memory.GetWritableRegion(errorFdsOutBufferPosition, (int)errorFdsOutBufferSize); _context.BuildMask(readFds, readFdsOut.Memory.Span); _context.BuildMask(writeFds, writeFdsOut.Memory.Span); diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs index e2ef75f80..3db2712f3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/WinSockHelper.cs @@ -303,7 +303,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl public static bool TryConvertSocketOption(BsdSocketOption option, SocketOptionLevel level, out SocketOptionName name) { - var table = level switch + Dictionary table = level switch { SocketOptionLevel.Socket => _soSocketOptionMap, SocketOptionLevel.IP => _ipSocketOptionMap, @@ -322,7 +322,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl public static LinuxError ValidateSocketOption(BsdSocketOption option, SocketOptionLevel level, bool write) { - var table = level switch + Dictionary table = level switch { SocketOptionLevel.Socket => _validSoSocketOptionMap, SocketOptionLevel.IP => _validIpSocketOptionMap, diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs index 485a7f86b..9f206176d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs @@ -12,9 +12,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy public static void Select(List readEvents, List writeEvents, List errorEvents, int timeout) { - var readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); - var writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); - var errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); + List readDefault = readEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); + List writeDefault = writeEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); + List errorDefault = errorEvents.Select(x => (x as DefaultSocket)?.BaseSocket).Where(x => x != null).ToList(); if (readDefault.Count != 0 || writeDefault.Count != 0 || errorDefault.Count != 0) { diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs index d17a999dc..b0e282031 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Sfdnsres/Proxy/DnsMitmResolver.cs @@ -82,7 +82,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy public IPHostEntry ResolveAddress(string host) { - foreach (var hostEntry in _mitmHostEntries) + foreach (KeyValuePair hostEntry in _mitmHostEntries) { // Check for AMS hosts file extension: "*" // NOTE: MatchesSimpleExpression also allows "?" as a wildcard diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs index 622b62c16..adde15b32 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs @@ -129,7 +129,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - using var trustedCertsFileRef = new UniqueRef(); + using UniqueRef trustedCertsFileRef = new UniqueRef(); Result result = romfs.OpenFile(ref trustedCertsFileRef.Ref, "/ssl_TrustedCerts.bdf".ToU8Span(), OpenMode.Read); diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs index b5c608d3d..92e73f9f1 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs @@ -145,7 +145,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService ulong bufferAddress = context.Request.ReceiveBuff[0].Position; ulong bufferLen = context.Request.ReceiveBuff[0].Size; - using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) + using (WritableRegion region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true)) { Encoding.ASCII.GetBytes(_hostName, region.Memory.Span); } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs index 222698a7f..82d33578e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs @@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - using var binaryListFile = new UniqueRef(); + using UniqueRef binaryListFile = new UniqueRef(); romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); @@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public IEnumerable<(int Offset, string Location, string Abbr)> ParseTzOffsets() { - var tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath(); + string tzBinaryContentPath = GetTimeZoneBinaryTitleContentPath(); if (string.IsNullOrEmpty(tzBinaryContentPath)) { @@ -128,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone } List<(int Offset, string Location, string Abbr)> outList = new(); - var now = DateTimeOffset.Now.ToUnixTimeSeconds(); + long now = DateTimeOffset.Now.ToUnixTimeSeconds(); using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open)) using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel)) { @@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone continue; } - using var tzif = new UniqueRef(); + using UniqueRef tzif = new UniqueRef(); if (romfs.OpenFile(ref tzif.Ref, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure()) { @@ -176,7 +176,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone continue; } - var abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..]; + Span abbrStart = tzRule.Chars[ttInfo.AbbreviationListIndex..]; int abbrEnd = abbrStart.IndexOf((byte)0); outList.Add((ttInfo.GmtOffset, locName, Encoding.UTF8.GetString(abbrStart[..abbrEnd]))); @@ -269,7 +269,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone Nca nca = new(_virtualFileSystem.KeySet, ncaFile); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - using var timeZoneBinaryFile = new UniqueRef(); + using UniqueRef timeZoneBinaryFile = new UniqueRef(); Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read); diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs index fc7edd62b..5eaed6530 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/EndConditionalBlock.cs @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters } // Use the conditional begin instruction stored in the stack. - var upperInstruction = context.CurrentBlock.BaseInstruction; + byte[] upperInstruction = context.CurrentBlock.BaseInstruction; CodeType codeType = InstructionHelper.GetCodeType(upperInstruction); // Pop the current block of operations from the stack so control instructions diff --git a/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs b/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs index 759ba5f90..46e4fd9f7 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs @@ -96,7 +96,7 @@ namespace Ryujinx.HLE.HOS.Tamper // Instructions are multi-word, with 32bit words. Split the raw instruction // and parse each word into individual nybbles of bits. - var words = rawInstruction.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); + string[] words = rawInstruction.Split((char[])null, StringSplitOptions.RemoveEmptyEntries); byte[] instruction = new byte[WordSize * words.Length]; diff --git a/src/Ryujinx.HLE/HOS/TamperMachine.cs b/src/Ryujinx.HLE/HOS/TamperMachine.cs index 609221535..d9f4fb157 100644 --- a/src/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/src/Ryujinx.HLE/HOS/TamperMachine.cs @@ -70,14 +70,14 @@ namespace Ryujinx.HLE.HOS public void EnableCheats(string[] enabledCheats) { - foreach (var program in _programDictionary.Values) + foreach (ITamperProgram program in _programDictionary.Values) { program.IsEnabled = false; } - foreach (var cheat in enabledCheats) + foreach (string cheat in enabledCheats) { - if (_programDictionary.TryGetValue(cheat, out var program)) + if (_programDictionary.TryGetValue(cheat, out ITamperProgram program)) { program.IsEnabled = true; } diff --git a/src/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs b/src/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs index 83380ff45..293e5f846 100644 --- a/src/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs +++ b/src/Ryujinx.HLE/Loaders/Executables/KipExecutable.cs @@ -76,7 +76,7 @@ namespace Ryujinx.HLE.Loaders.Executables { reader.GetSegmentSize(segmentType, out int uncompressedSize).ThrowIfFailure(); - var span = program.AsSpan((int)offset, uncompressedSize); + Span span = program.AsSpan((int)offset, uncompressedSize); reader.ReadSegment(segmentType, span).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs b/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs index 1caedb51e..5217612b9 100644 --- a/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs +++ b/src/Ryujinx.HLE/Loaders/Executables/NsoExecutable.cs @@ -65,7 +65,7 @@ namespace Ryujinx.HLE.Loaders.Executables { reader.GetSegmentSize(segmentType, out uint uncompressedSize).ThrowIfFailure(); - var span = Program.AsSpan((int)offset, (int)uncompressedSize); + Span span = Program.AsSpan((int)offset, (int)uncompressedSize); reader.ReadSegment(segmentType, span).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs b/src/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs index cf316b565..d457682cf 100644 --- a/src/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs +++ b/src/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs @@ -25,7 +25,7 @@ namespace Ryujinx.HLE.Loaders.Mods ReadOnlySpan ips32TailMagic = "EEOF"u8; MemPatch patches = new(); - var header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan(); + Span header = reader.ReadBytes(ipsHeaderMagic.Length).AsSpan(); if (header.Length != ipsHeaderMagic.Length) { @@ -94,7 +94,7 @@ namespace Ryujinx.HLE.Loaders.Mods } else // Copy mode { - var patch = reader.ReadBytes(patchSize); + byte[] patch = reader.ReadBytes(patchSize); if (patch.Length != patchSize) { diff --git a/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs b/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs index 693e03888..b6b2c9759 100644 --- a/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs +++ b/src/Ryujinx.HLE/Loaders/Mods/IPSwitchPatcher.cs @@ -200,7 +200,7 @@ namespace Ryujinx.HLE.Loaders.Mods } else if (line.StartsWith("@flag")) { - var tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); + string[] tokens = line.Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length < 2) { @@ -234,7 +234,7 @@ namespace Ryujinx.HLE.Loaders.Mods continue; } - var tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries); + string[] tokens = line.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length < 2) { @@ -259,12 +259,12 @@ namespace Ryujinx.HLE.Loaders.Mods if (tokens[1][0] == '"') { - var patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0"); + byte[] patch = Encoding.ASCII.GetBytes(tokens[1].Trim('"') + "\0"); patches.Add((uint)offset, patch); } else { - var patch = Hex2ByteArrayBE(tokens[1]); + byte[] patch = Hex2ByteArrayBE(tokens[1]); patches.Add((uint)offset, patch); } } diff --git a/src/Ryujinx.HLE/Loaders/Mods/MemPatch.cs b/src/Ryujinx.HLE/Loaders/Mods/MemPatch.cs index 0a1f12b18..9a1931433 100644 --- a/src/Ryujinx.HLE/Loaders/Mods/MemPatch.cs +++ b/src/Ryujinx.HLE/Loaders/Mods/MemPatch.cs @@ -46,7 +46,7 @@ namespace Ryujinx.HLE.Loaders.Mods return; } - foreach (var (patchOffset, patch) in patches._patches) + foreach ((uint patchOffset, byte[] patch) in patches._patches) { _patches[patchOffset] = patch; } @@ -66,7 +66,7 @@ namespace Ryujinx.HLE.Loaders.Mods public int Patch(Span memory, int protectedOffset = 0) { int count = 0; - foreach (var (offset, patch) in _patches.OrderBy(item => item.Key)) + foreach ((uint offset, byte[] patch) in _patches.OrderBy(item => item.Key)) { int patchOffset = (int)offset; int patchSize = patch.Length; diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs index d1d13b00f..d68b1e200 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs @@ -62,7 +62,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions Logger.Info?.Print(LogClass.Loader, $"Loading {name}..."); - using var nsoFile = new UniqueRef(); + using UniqueRef nsoFile = new UniqueRef(); exeFs.OpenFile(ref nsoFile.Ref, $"/{name}".ToU8Span(), OpenMode.Read).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/LocalFileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/LocalFileSystemExtensions.cs index e3ae9bf5f..a5c22177f 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/LocalFileSystemExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/LocalFileSystemExtensions.cs @@ -12,7 +12,7 @@ namespace Ryujinx.HLE.Loaders.Processes public static ProcessResult Load(this LocalFileSystem exeFs, Switch device, string romFsPath = "") { MetaLoader metaLoader = exeFs.GetNpdm(); - var nacpData = new BlitStruct(1); + BlitStruct nacpData = new BlitStruct(1); ulong programId = metaLoader.GetProgramId(); device.Configuration.VirtualFileSystem.ModLoader.CollectMods([programId]); diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/MetaLoaderExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/MetaLoaderExtensions.cs index 92e71cb5a..eed7a1be5 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/MetaLoaderExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/MetaLoaderExtensions.cs @@ -12,21 +12,21 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions { public static ulong GetProgramId(this MetaLoader metaLoader) { - metaLoader.GetNpdm(out var npdm).ThrowIfFailure(); + metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure(); return npdm.Aci.ProgramId.Value; } public static string GetProgramName(this MetaLoader metaLoader) { - metaLoader.GetNpdm(out var npdm).ThrowIfFailure(); + metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure(); return StringUtils.Utf8ZToString(npdm.Meta.ProgramName); } public static bool IsProgram64Bit(this MetaLoader metaLoader) { - metaLoader.GetNpdm(out var npdm).ThrowIfFailure(); + metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm).ThrowIfFailure(); return (npdm.Meta.Flags & 1) != 0; } @@ -45,7 +45,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions path = ProcessConst.MainNpdmPath; } - using var npdmFile = new UniqueRef(); + using UniqueRef npdmFile = new UniqueRef(); fileSystem.OpenFile(ref npdmFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/NcaExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/NcaExtensions.cs index 361a9159e..c4d47d5bd 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/NcaExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/NcaExtensions.cs @@ -49,7 +49,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions ModLoader.GetSdModsBasePath()); // Load Nacp file. - var nacpData = new BlitStruct(1); + BlitStruct nacpData = new BlitStruct(1); if (controlNca != null) { @@ -214,9 +214,9 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions public static BlitStruct GetNacp(this Nca controlNca, Switch device) { - var nacpData = new BlitStruct(1); + BlitStruct nacpData = new BlitStruct(1); - using var controlFile = new UniqueRef(); + using UniqueRef controlFile = new UniqueRef(); Result result = controlNca.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel) .OpenFile(ref controlFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read); @@ -236,7 +236,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions public static Cnmt GetCnmt(this Nca cnmtNca, IntegrityCheckLevel checkLevel, ContentMetaType metaType) { string path = $"/{metaType}_{cnmtNca.Header.TitleId:x16}.cnmt"; - using var cnmtFile = new UniqueRef(); + using UniqueRef cnmtFile = new UniqueRef(); try { diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs index b3590d9bd..4a9eafea1 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/PartitionFileSystemExtensions.cs @@ -28,7 +28,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions { fileSystem.ImportTickets(partitionFileSystem); - var programs = new Dictionary(); + Dictionary programs = new Dictionary(); foreach (DirectoryEntryEx fileEntry in partitionFileSystem.EnumerateEntries("/", "*.cnmt.nca")) { @@ -152,7 +152,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions public static Nca GetNca(this IFileSystem fileSystem, KeySet keySet, string path) { - using var ncaFile = new UniqueRef(); + using UniqueRef ncaFile = new UniqueRef(); fileSystem.OpenFile(ref ncaFile.Ref, path.ToU8Span(), OpenMode.Read).ThrowIfFailure(); diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs index 6279ec3b4..b9746da16 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs @@ -161,7 +161,7 @@ namespace Ryujinx.HLE.Loaders.Processes public bool LoadNxo(string path) { - var nacpData = new BlitStruct(1); + BlitStruct nacpData = new BlitStruct(1); IFileSystem dummyExeFs = null; Stream romfsStream = null; diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs index e4286ae90..32266d5ca 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs @@ -180,7 +180,7 @@ namespace Ryujinx.HLE.Loaders.Processes KProcess process = new(context); - var processContextFactory = new ArmProcessContextFactory( + ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory( context.Device.System.TickSource, context.Device.Gpu, string.Empty, @@ -235,7 +235,7 @@ namespace Ryujinx.HLE.Loaders.Processes { context.Device.System.ServiceTable.WaitServicesReady(); - LibHac.Result resultCode = metaLoader.GetNpdm(out var npdm); + LibHac.Result resultCode = metaLoader.GetNpdm(out LibHac.Loader.Npdm npdm); if (resultCode.IsFailure()) { @@ -244,14 +244,14 @@ namespace Ryujinx.HLE.Loaders.Processes return ProcessResult.Failed; } - ref readonly var meta = ref npdm.Meta; + ref readonly Meta meta = ref npdm.Meta; ulong argsStart = 0; uint argsSize = 0; ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset; uint codeSize = 0; - var buildIds = new string[executables.Length]; + string[] buildIds = new string[executables.Length]; for (int i = 0; i < executables.Length; i++) { @@ -373,7 +373,7 @@ namespace Ryujinx.HLE.Loaders.Processes displayVersion = device.System.ContentManager.GetCurrentFirmwareVersion()?.VersionString ?? string.Empty; } - var processContextFactory = new ArmProcessContextFactory( + ArmProcessContextFactory processContextFactory = new ArmProcessContextFactory( context.Device.System.TickSource, context.Device.Gpu, $"{programId:x16}", diff --git a/src/Ryujinx.HLE/StructHelpers.cs b/src/Ryujinx.HLE/StructHelpers.cs index 6e6af8cea..f573f0eb6 100644 --- a/src/Ryujinx.HLE/StructHelpers.cs +++ b/src/Ryujinx.HLE/StructHelpers.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE const int OffsetOfApplicationPublisherStrings = 0x200; - var nacpData = new BlitStruct(1); + BlitStruct nacpData = new BlitStruct(1); // name and publisher buffer // repeat once for each locale (the ApplicationControlProperty has 16 locales) diff --git a/src/Ryujinx.HLE/UI/Input/NpadReader.cs b/src/Ryujinx.HLE/UI/Input/NpadReader.cs index 8276d6160..8b4888a26 100644 --- a/src/Ryujinx.HLE/UI/Input/NpadReader.cs +++ b/src/Ryujinx.HLE/UI/Input/NpadReader.cs @@ -1,5 +1,7 @@ +using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common; using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad; +using System; namespace Ryujinx.HLE.UI.Input { @@ -29,7 +31,7 @@ namespace Ryujinx.HLE.UI.Input { NpadButton buttons = 0; - foreach (var state in _lastStates) + foreach (NpadCommonState state in _lastStates) { buttons |= state.Buttons; } @@ -60,7 +62,7 @@ namespace Ryujinx.HLE.UI.Input public void Update(bool supressEvents = false) { - ref var npads = ref _device.Hid.SharedMemory.Npads; + ref Array10 npads = ref _device.Hid.SharedMemory.Npads; // Process each input individually. for (int npadIndex = 0; npadIndex < npads.Length; npadIndex++) @@ -73,10 +75,10 @@ namespace Ryujinx.HLE.UI.Input { const int MaxEntries = 1024; - ref var npadState = ref _device.Hid.SharedMemory.Npads[npadIndex]; - ref var lastEntry = ref _lastStates[npadIndex]; + ref NpadState npadState = ref _device.Hid.SharedMemory.Npads[npadIndex]; + ref NpadCommonState lastEntry = ref _lastStates[npadIndex]; - var fullKeyEntries = GetCommonStateLifo(ref npadState.InternalState).ReadEntries(MaxEntries); + ReadOnlySpan> fullKeyEntries = GetCommonStateLifo(ref npadState.InternalState).ReadEntries(MaxEntries); int firstEntryNum; @@ -94,7 +96,7 @@ namespace Ryujinx.HLE.UI.Input for (; firstEntryNum >= 0; firstEntryNum--) { - var entry = fullKeyEntries[firstEntryNum]; + AtomicStorage entry = fullKeyEntries[firstEntryNum]; // The interval of valid entries should be contiguous. if (entry.SamplingNumber < lastEntry.SamplingNumber) diff --git a/src/Ryujinx.HLE/Utilities/PartitionFileSystemUtils.cs b/src/Ryujinx.HLE/Utilities/PartitionFileSystemUtils.cs index 3c4ce0850..1bd6e0ff7 100644 --- a/src/Ryujinx.HLE/Utilities/PartitionFileSystemUtils.cs +++ b/src/Ryujinx.HLE/Utilities/PartitionFileSystemUtils.cs @@ -22,7 +22,7 @@ namespace Ryujinx.HLE.Utilities } else { - var pfsTemp = new PartitionFileSystem(); + PartitionFileSystem pfsTemp = new PartitionFileSystem(); Result initResult = pfsTemp.Initialize(file.AsStorage()); if (throwOnFailure)