diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs index 8b135afab..7fe683e64 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs @@ -146,9 +146,9 @@ namespace ARMeilleure.CodeGen.RegisterAllocators } } - private Queue _fillQueue = null; - private Queue _spillQueue = null; - private ParallelCopy _parallelCopy = null; + private Queue _fillQueue; + private Queue _spillQueue; + private ParallelCopy _parallelCopy; public bool HasCopy { get; private set; } diff --git a/src/ARMeilleure/Instructions/MathHelper.cs b/src/ARMeilleure/Instructions/MathHelper.cs index acf9a5028..a11ce9d2e 100644 --- a/src/ARMeilleure/Instructions/MathHelper.cs +++ b/src/ARMeilleure/Instructions/MathHelper.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace ARMeilleure.Instructions { diff --git a/src/ARMeilleure/Optimizations.cs b/src/ARMeilleure/Optimizations.cs index 0536302e8..ac6510143 100644 --- a/src/ARMeilleure/Optimizations.cs +++ b/src/ARMeilleure/Optimizations.cs @@ -1,7 +1,7 @@ namespace ARMeilleure { - using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities; - using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities; + using Arm64HardwareCapabilities = CodeGen.Arm64.HardwareCapabilities; + using X86HardwareCapabilities = CodeGen.X86.HardwareCapabilities; public static class Optimizations { diff --git a/src/ARMeilleure/State/NativeContext.cs b/src/ARMeilleure/State/NativeContext.cs index f84cb5080..08c2248a6 100644 --- a/src/ARMeilleure/State/NativeContext.cs +++ b/src/ARMeilleure/State/NativeContext.cs @@ -24,7 +24,7 @@ namespace ARMeilleure.State public long Tpidr2El0; } - private static NativeCtxStorage _dummyStorage = new(); + private static NativeCtxStorage _dummyStorage; private readonly IJitMemoryBlock _block; diff --git a/src/ARMeilleure/Translation/ArmEmitterContext.cs b/src/ARMeilleure/Translation/ArmEmitterContext.cs index 41a2cf995..813fc2745 100644 --- a/src/ARMeilleure/Translation/ArmEmitterContext.cs +++ b/src/ARMeilleure/Translation/ArmEmitterContext.cs @@ -54,7 +54,7 @@ namespace ARMeilleure.Translation public bool HasPtc { get; } public Aarch32Mode Mode { get; } - private int _ifThenBlockStateIndex = 0; + private int _ifThenBlockStateIndex; private Condition[] _ifThenBlockState = []; public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length; public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex]; diff --git a/src/ARMeilleure/Translation/Cache/CacheEntry.cs b/src/ARMeilleure/Translation/Cache/CacheEntry.cs index 25b06f781..5b1a27355 100644 --- a/src/ARMeilleure/Translation/Cache/CacheEntry.cs +++ b/src/ARMeilleure/Translation/Cache/CacheEntry.cs @@ -18,7 +18,7 @@ namespace ARMeilleure.Translation.Cache UnwindInfo = unwindInfo; } - public int CompareTo([AllowNull] CacheEntry other) + public int CompareTo(CacheEntry other) { return Offset.CompareTo(other.Offset); } diff --git a/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs b/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs index 9c5ca29df..c72a0f398 100644 --- a/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs +++ b/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs @@ -17,7 +17,7 @@ namespace ARMeilleure.Translation.Cache Size = size; } - public int CompareTo([AllowNull] MemoryBlock other) + public int CompareTo(MemoryBlock other) { return Offset.CompareTo(other.Offset); } diff --git a/src/ARMeilleure/Translation/Cache/JitCache.cs b/src/ARMeilleure/Translation/Cache/JitCache.cs index faccdabbe..49bce5bbe 100644 --- a/src/ARMeilleure/Translation/Cache/JitCache.cs +++ b/src/ARMeilleure/Translation/Cache/JitCache.cs @@ -32,7 +32,7 @@ namespace ARMeilleure.Translation.Cache private static bool _initialized; private static readonly List _jitRegions = []; - private static int _activeRegionIndex = 0; + private static int _activeRegionIndex; [SupportedOSPlatform("windows")] [LibraryImport("kernel32.dll", SetLastError = true)] diff --git a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs index ef54b32f8..3aee406cc 100644 --- a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs +++ b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs @@ -79,7 +79,7 @@ namespace ARMeilleure.Translation.Cache _unwindInfo = (UnwindInfo*)(workBufferPtr + _sizeOfRuntimeFunction); - _getRuntimeFunctionCallback = new GetRuntimeFunctionCallback(FunctionTableHandler); + _getRuntimeFunctionCallback = FunctionTableHandler; result = RtlInstallFunctionTableCallback( codeCachePtr | 3, @@ -102,10 +102,7 @@ namespace ARMeilleure.Translation.Cache bool result; - unsafe - { - result = RtlDeleteFunctionTable(codeCachePtr | 3); - } + result = RtlDeleteFunctionTable(codeCachePtr | 3); if (!result) { diff --git a/src/ARMeilleure/Translation/Delegates.cs b/src/ARMeilleure/Translation/Delegates.cs index 9877c57b1..5d2c39e04 100644 --- a/src/ARMeilleure/Translation/Delegates.cs +++ b/src/ARMeilleure/Translation/Delegates.cs @@ -63,7 +63,7 @@ namespace ARMeilleure.Translation private static readonly SortedList _delegates; - unsafe static Delegates() + static Delegates() { _delegates = new SortedList(); diff --git a/src/ARMeilleure/Translation/IntervalTree.cs b/src/ARMeilleure/Translation/IntervalTree.cs index 2fa431a8b..ad2c44e88 100644 --- a/src/ARMeilleure/Translation/IntervalTree.cs +++ b/src/ARMeilleure/Translation/IntervalTree.cs @@ -14,8 +14,8 @@ namespace ARMeilleure.Translation private const bool Black = true; private const bool Red = false; - private IntervalTreeNode _root = null; - private int _count = 0; + private IntervalTreeNode _root; + private int _count; public int Count => _count; @@ -709,9 +709,9 @@ namespace ARMeilleure.Translation class IntervalTreeNode { public bool Color = true; - public IntervalTreeNode Left = null; - public IntervalTreeNode Right = null; - public IntervalTreeNode Parent = null; + public IntervalTreeNode Left; + public IntervalTreeNode Right; + public IntervalTreeNode Parent; /// /// The start of the range. diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs index 4148ea0dd..2ac085e77 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs +++ b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native public class SoundIoOutStreamContext : IDisposable { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private unsafe delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax); + private delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax); private IntPtr _context; private IntPtr _nameStored; diff --git a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs index 1a46d41fd..dcdf32de2 100644 --- a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs +++ b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs @@ -127,24 +127,21 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter { get { - unsafe + if (Unsafe.IsNullRef(ref _v2)) { - if (Unsafe.IsNullRef(ref _v2)) + if (Unsafe.IsNullRef(ref _v1)) { - if (Unsafe.IsNullRef(ref _v1)) - { - return new SplitterDestination(); - } - else - { - return new SplitterDestination(ref _v1.Next); - } + return new SplitterDestination(); } else { - return new SplitterDestination(ref _v2.Next); + return new SplitterDestination(ref _v1.Next); } } + else + { + return new SplitterDestination(ref _v2.Next); + } } } diff --git a/src/Ryujinx.Common/Memory/ArrayPtr.cs b/src/Ryujinx.Common/Memory/ArrayPtr.cs index 7487a1ff5..3608dac59 100644 --- a/src/Ryujinx.Common/Memory/ArrayPtr.cs +++ b/src/Ryujinx.Common/Memory/ArrayPtr.cs @@ -100,7 +100,7 @@ namespace Ryujinx.Common.Memory return obj is ArrayPtr other && Equals(other); } - public readonly bool Equals([AllowNull] ArrayPtr other) + public readonly bool Equals(ArrayPtr other) { return _ptr == other._ptr && Length == other.Length; } diff --git a/src/Ryujinx.Common/Memory/Ptr.cs b/src/Ryujinx.Common/Memory/Ptr.cs index d01748c16..5315eaae2 100644 --- a/src/Ryujinx.Common/Memory/Ptr.cs +++ b/src/Ryujinx.Common/Memory/Ptr.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Common.Memory return obj is Ptr other && Equals(other); } - public readonly bool Equals([AllowNull] Ptr other) + public readonly bool Equals(Ptr other) { return _ptr == other._ptr; } diff --git a/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs b/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs index 4399ea39d..d774f4851 100644 --- a/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs +++ b/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs @@ -90,8 +90,8 @@ namespace Ryujinx.Common.Utilities private BinaryReader _binaryReader; private long _offsetB, _dataSizeB, _cartSizeB, _fileSizeB; private bool _fileOK = true; - private bool _freeSpaceChecked = false; - private bool _freeSpaceValid = false; + private bool _freeSpaceChecked; + private bool _freeSpaceValid; public enum OperationOutcome { @@ -191,7 +191,7 @@ namespace Ryujinx.Common.Utilities if (timedSw.Elapsed.TotalSeconds > 0) { - Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); + Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); } if (freeSpaceValid) @@ -219,7 +219,7 @@ namespace Ryujinx.Common.Utilities private bool CheckPadding(long readSizeB, CancellationToken? cancelToken = null) { - long maxReads = readSizeB / XCIFileTrimmer.BufferSize; + long maxReads = readSizeB / BufferSize; long read = 0; var buffer = new byte[BufferSize]; @@ -230,12 +230,12 @@ namespace Ryujinx.Common.Utilities return false; } - int bytes = _fileStream.Read(buffer, 0, XCIFileTrimmer.BufferSize); + int bytes = _fileStream.Read(buffer, 0, BufferSize); if (bytes == 0) break; Log?.Progress(read, maxReads, "Verifying file can be trimmed", false); - if (buffer.Take(bytes).AsParallel().Any(b => b != XCIFileTrimmer.PaddingByte)) + if (buffer.Take(bytes).AsParallel().Any(b => b != PaddingByte)) { Log?.Write(LogType.Warn, "Free space is NOT valid"); return false; @@ -380,7 +380,7 @@ namespace Ryujinx.Common.Utilities if (timedSw.Elapsed.TotalSeconds > 0) { - Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); + Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); } if (cancelToken.HasValue && cancelToken.Value.IsCancellationRequested) @@ -408,13 +408,13 @@ namespace Ryujinx.Common.Utilities private void WritePadding(FileStream outfileStream, long bytesToWriteB, CancellationToken? cancelToken = null) { long bytesLeftToWriteB = bytesToWriteB; - long writes = bytesLeftToWriteB / XCIFileTrimmer.BufferSize; + long writes = bytesLeftToWriteB / BufferSize; int write = 0; try { var buffer = new byte[BufferSize]; - Array.Fill(buffer, XCIFileTrimmer.PaddingByte); + Array.Fill(buffer, PaddingByte); while (bytesLeftToWriteB > 0) { @@ -423,7 +423,7 @@ namespace Ryujinx.Common.Utilities return; } - long bytesToWrite = Math.Min(XCIFileTrimmer.BufferSize, bytesLeftToWriteB); + long bytesToWrite = Math.Min(BufferSize, bytesLeftToWriteB); #if !XCI_TRIMMER_READ_ONLY_MODE outfileStream.Write(buffer, 0, (int)bytesToWrite); @@ -504,12 +504,12 @@ namespace Ryujinx.Common.Utilities } // Setup offset - _offsetB = (long)(assumeKeyArea ? XCIFileTrimmer.CartKeyAreaSize : 0); + _offsetB = (long)(assumeKeyArea ? CartKeyAreaSize : 0); // Check header - Pos = _offsetB + XCIFileTrimmer.HeaderFilePos; + Pos = _offsetB + HeaderFilePos; string head = System.Text.Encoding.ASCII.GetString(_binaryReader.ReadBytes(4)); - if (head != XCIFileTrimmer.HeaderMagicValue) + if (head != HeaderMagicValue) { if (!assumeKeyArea) { @@ -524,17 +524,17 @@ namespace Ryujinx.Common.Utilities } // Read Cart Size - Pos = _offsetB + XCIFileTrimmer.CartSizeFilePos; + Pos = _offsetB + CartSizeFilePos; byte cartSizeId = _binaryReader.ReadByte(); if (!_cartSizesGB.TryGetValue(cartSizeId, out long cartSizeNGB)) { Log?.Write(LogType.Error, $"The source file doesn't look like an XCI file as the Cartridge Size is incorrect (0x{cartSizeId:X2})"); return false; } - _cartSizeB = cartSizeNGB * XCIFileTrimmer.CartSizeMBinFormattedGB * XCIFileTrimmer.BytesInAMegabyte; + _cartSizeB = cartSizeNGB * CartSizeMBinFormattedGB * BytesInAMegabyte; // Read data size - Pos = _offsetB + XCIFileTrimmer.DataSizeFilePos; + Pos = _offsetB + DataSizeFilePos; long records = (long)BitConverter.ToUInt32(_binaryReader.ReadBytes(4), 0); _dataSizeB = RecordsToByte(records); diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs index 86936c592..65b79c39c 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs @@ -4,7 +4,8 @@ using System.Runtime.Versioning; namespace Ryujinx.Cpu.AppleHv { [SupportedOSPlatform("macos")] - class HvMemoryBlockAllocator : PrivateMemoryAllocatorImpl + class HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) + : PrivateMemoryAllocatorImpl(blockAlignment, MemoryAllocationFlags.None) { public class Block : PrivateMemoryAllocator.Block { @@ -36,13 +37,6 @@ namespace Ryujinx.Cpu.AppleHv } } - private readonly HvIpaAllocator _ipaAllocator; - - public HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) : base(blockAlignment, MemoryAllocationFlags.None) - { - _ipaAllocator = ipaAllocator; - } - public HvMemoryBlockAllocation Allocate(ulong size, ulong alignment) { var allocation = Allocate(size, alignment, CreateBlock); @@ -52,7 +46,7 @@ namespace Ryujinx.Cpu.AppleHv private Block CreateBlock(MemoryBlock memory, ulong size) { - return new Block(_ipaAllocator, memory, size); + return new Block(ipaAllocator, memory, size); } } } diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs index aae21ae5d..c58e87d44 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs @@ -5,7 +5,6 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.Versioning; diff --git a/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs b/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs index ee91c478b..1b7b96b0f 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.AppleHv { private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms - private static ulong _interruptTimeDeltaTicks = 0; + private static ulong _interruptTimeDeltaTicks; public readonly ulong Handle; public readonly HvVcpuExit* ExitInfo; diff --git a/src/Ryujinx.Cpu/Jit/MemoryManager.cs b/src/Ryujinx.Cpu/Jit/MemoryManager.cs index fdfb18683..8d41be736 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManager.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManager.cs @@ -5,7 +5,6 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; diff --git a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs index 95200a7dc..2849a03d8 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs @@ -8,7 +8,6 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; namespace Ryujinx.Cpu.Jit diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs b/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs index 0249e24b8..7264190da 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo([AllowNull] CacheEntry other) + public int CompareTo(CacheEntry other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs b/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs index 05c889922..b43093cb5 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo([AllowNull] MemoryBlock other) + public int CompareTo(MemoryBlock other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs index 26bb50bef..653035e50 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache private static readonly Lock _lock = new(); private static bool _initialized; private static readonly List _jitRegions = []; - private static int _activeRegionIndex = 0; + private static int _activeRegionIndex; [SupportedOSPlatform("windows")] [LibraryImport("kernel32.dll", SetLastError = true)] @@ -75,12 +75,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64) { - unsafe + fixed (byte* codePtr = code) { - fixed (byte* codePtr = code) - { - JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length); - } + JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length); } } else diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs b/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs index dd53dcbf7..8012fa915 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo([AllowNull] Range other) + public int CompareTo(Range other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs b/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs index fdb8793de..968684177 100644 --- a/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs +++ b/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Cpu.LightningJit.State public int Running; } - private static NativeCtxStorage _dummyStorage = new(); + private static NativeCtxStorage _dummyStorage; private readonly IJitMemoryBlock _block; @@ -79,22 +79,22 @@ namespace Ryujinx.Cpu.LightningJit.State GetStorage().V[index * 2 + 1] = value.Extract(1); } - public unsafe uint GetPstate() + public uint GetPstate() { return GetStorage().Flags; } - public unsafe void SetPstate(uint value) + public void SetPstate(uint value) { GetStorage().Flags = value; } - public unsafe uint GetFPState(uint mask = uint.MaxValue) + public uint GetFPState(uint mask = uint.MaxValue) { return GetStorage().FpFlags & mask; } - public unsafe void SetFPState(uint value, uint mask = uint.MaxValue) + public void SetFPState(uint value, uint mask = uint.MaxValue) { GetStorage().FpFlags = (value & mask) | (GetStorage().FpFlags & ~mask); } diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs b/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs index 48bec3633..00a6a2e3f 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading /// class BufferMap { - private ulong _bufferHandle = 0; + private ulong _bufferHandle; private readonly Dictionary _bufferMap = new(); private readonly HashSet _inFlight = []; diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs index 6375d290c..8a23f4d88 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading private int _refProducerPtr; private int _refConsumerPtr; - public uint ProgramCount { get; set; } = 0; + public uint ProgramCount { get; set; } private Action _interruptAction; private readonly Lock _interruptLock = new(); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs index 475d1ee4e..802035ff4 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs @@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME maxDrawCount, stride, indexCount, - Threed.IndirectDrawType.DrawIndexedIndirectCount); + IndirectDrawType.DrawIndexedIndirectCount); } /// diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs index c2276480b..5d420a140 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs @@ -1,6 +1,5 @@ using Ryujinx.Common; using Ryujinx.Graphics.GAL; -using System; using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs index 2095fcd7a..b7fffac64 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs @@ -15,10 +15,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed // State associated with direct uniform buffer updates. // This state is used to attempt to batch together consecutive updates. - private ulong _ubBeginCpuAddress = 0; - private ulong _ubFollowUpAddress = 0; - private ulong _ubByteCount = 0; - private int _ubIndex = 0; + private ulong _ubBeginCpuAddress; + private ulong _ubFollowUpAddress; + private ulong _ubByteCount; + private int _ubIndex; private readonly int[] _ubData = new int[UniformDataCacheSize]; /// diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs index 5f23b5b1a..357e5d9d3 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs @@ -4,7 +4,6 @@ using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Shader; using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.Image diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index a9444daa4..bc28675e9 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -60,13 +60,13 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// This is null until at least one modification occurs. /// - private BufferModifiedRangeList _modifiedRanges = null; + private BufferModifiedRangeList _modifiedRanges; /// /// A structure that is used to flush buffer data back to a host mapped buffer for cached readback. /// Only used if the buffer data is explicitly owned by device local memory. /// - private BufferPreFlush _preFlush = null; + private BufferPreFlush _preFlush; /// /// Usage tracking state that determines what type of backing the buffer should use. @@ -171,9 +171,9 @@ namespace Ryujinx.Graphics.Gpu.Memory _memoryTracking.RegisterPreciseAction(PreciseAction); } - _externalFlushDelegate = new RegionSignal(ExternalFlush); - _loadDelegate = new Action(LoadRegion); - _modifiedDelegate = new Action(RegionModified); + _externalFlushDelegate = ExternalFlush; + _loadDelegate = LoadRegion; + _modifiedDelegate = RegionModified; _virtualDependenciesLock = new ReaderWriterLockSlim(); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs index 86de37876..789fe504a 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs @@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Gpu.Memory } private List _dependencies; - private BufferModifiedRangeList _modifiedRanges = null; + private BufferModifiedRangeList _modifiedRanges; /// /// Creates a new instance of the buffer. diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs index e0396006d..805bce37a 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine; using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Shader; -using System; using System.Linq; namespace Ryujinx.Graphics.Gpu.Shader diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs index 0767cc9d6..090e198ae 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg { unsafe class FFmpegContext : IDisposable { - private unsafe delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt); + private delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt); private readonly AVCodec_decode _decodeFrame; private static readonly FFmpegApi.av_log_set_callback_callback _logFunc; diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs index 0267000c8..cad042556 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native public IntPtr SampleFmts; // Deprecated public unsafe ulong* ChannelLayouts; - public unsafe IntPtr PrivClass; + public IntPtr PrivClass; public IntPtr Profiles; public unsafe byte* WrapperName; public IntPtr ChLayouts; diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs index 9084f4024..162942628 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native public IntPtr SampleFmts; // Deprecated public unsafe ulong* ChannelLayouts; - public unsafe IntPtr PrivClass; + public IntPtr PrivClass; public IntPtr Profiles; public unsafe byte* WrapperName; #pragma warning restore CS0649 diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs index c743ab33e..857fa99b5 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native struct AVCodecContext { #pragma warning disable CS0649 // Field is never assigned to - public unsafe IntPtr AvClass; + public IntPtr AvClass; public int LogLevelOffset; public int CodecType; public unsafe AVCodec* Codec; diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs index fdd48a23d..f4239d374 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs @@ -281,7 +281,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types Array8 frameSizes = new(); int frameCount = 0; - res = Types.Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount); + res = Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount); if (res != CodecErr.Ok) { return res; @@ -322,7 +322,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types // Account for suboptimal termination by the encoder. while (dataStart.Length != 0) { - byte marker = Types.Decoder.ReadMarker(dataStart); + byte marker = Decoder.ReadMarker(dataStart); if (marker != 0) { break; diff --git a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs index 5ed508647..cff89a6d6 100644 --- a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Nvdec { private static readonly Decoder _decoder = new(); - public unsafe static void Decode(ResourceManager rm, ref NvdecRegisters state) + public static void Decode(ResourceManager rm, ref NvdecRegisters state) { PictureInfo pictureInfo = rm.MemoryManager.DeviceRead(state.SetDrvPicSetupOffset); EntropyProbs entropy = rm.MemoryManager.DeviceRead(state.Vp9SetProbTabBufOffset); diff --git a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs index f22e0df57..8bd6df6d1 100644 --- a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs +++ b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs @@ -5,7 +5,7 @@ using System.Threading; namespace Ryujinx.Graphics.OpenGL { - unsafe class BackgroundContextWorker : IDisposable + class BackgroundContextWorker : IDisposable { [ThreadStatic] public static bool InBackground; diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs index d58326367..bc3a76b2c 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs @@ -6,7 +6,7 @@ using System; namespace Ryujinx.Graphics.OpenGL.Effects.Smaa { - internal partial class SmaaPostProcessingEffect : IPostProcessingEffect + internal class SmaaPostProcessingEffect : IPostProcessingEffect { public const int AreaWidth = 160; public const int AreaHeight = 560; @@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa } } - private unsafe void RecreateShaders(int width, int height) + private void RecreateShaders(int width, int height) { string baseShader = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa.hlsl"); var pixelSizeDefine = $"#define SMAA_RT_METRICS float4(1.0 / {width}.0, 1.0 / {height}.0, {width}, {height}) \n"; diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index c241379c4..725e6e06e 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.OpenGL private readonly Sync _sync; - public uint ProgramCount { get; set; } = 0; + public uint ProgramCount { get; set; } public event EventHandler ScreenCaptured; diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs index 889517480..78b94342c 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries private readonly CounterQueue _queue; private readonly BufferedQuery _counter; - private bool _hostAccessReserved = false; + private bool _hostAccessReserved; private int _refCount = 1; // Starts with a reference from the counter queue. private readonly Lock _lock = new(); diff --git a/src/Ryujinx.Graphics.OpenGL/Sync.cs b/src/Ryujinx.Graphics.OpenGL/Sync.cs index dd9a9b3ec..5f646592b 100644 --- a/src/Ryujinx.Graphics.OpenGL/Sync.cs +++ b/src/Ryujinx.Graphics.OpenGL/Sync.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.OpenGL public IntPtr Handle; } - private ulong _firstHandle = 0; + private ulong _firstHandle; private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit; private readonly List _handles = []; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs index 4faba77f3..21cf79a68 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { using IrOperandType = IntermediateRepresentation.OperandType; - partial class CodeGenContext : Module + class CodeGenContext : Module { private const uint SpirvVersionMajor = 1; private const uint SpirvVersionMinor = 3; diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs index 8118deb89..e6ae98ff7 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs @@ -4,17 +4,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { class StructuredProgramInfo { - public List Functions { get; } + public List Functions { get; } = []; - public HashSet IoDefinitions { get; } + public HashSet IoDefinitions { get; } = []; public HelperFunctionsMask HelperFunctionsMask { get; set; } - - public StructuredProgramInfo() - { - Functions = []; - - IoDefinitions = []; - } } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs b/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs index 5504ef4ed..4d14590da 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs @@ -4,31 +4,22 @@ using System.Numerics; namespace Ryujinx.Graphics.Shader.Translation { - class AttributeUsage + class AttributeUsage(IGpuAccessor gpuAccessor) { public bool NextUsesFixedFuncAttributes { get; private set; } public int UsedInputAttributes { get; private set; } public int UsedOutputAttributes { get; private set; } - public HashSet UsedInputAttributesPerPatch { get; } - public HashSet UsedOutputAttributesPerPatch { get; } + public HashSet UsedInputAttributesPerPatch { get; } = []; + public HashSet UsedOutputAttributesPerPatch { get; } = []; public HashSet NextUsedInputAttributesPerPatch { get; private set; } public int PassthroughAttributes { get; private set; } private int _nextUsedInputAttributes; private int _thisUsedInputAttributes; private Dictionary _perPatchAttributeLocations; - private readonly IGpuAccessor _gpuAccessor; public UInt128 NextInputAttributesComponents { get; private set; } public UInt128 ThisInputAttributesComponents { get; private set; } - public AttributeUsage(IGpuAccessor gpuAccessor) - { - _gpuAccessor = gpuAccessor; - - UsedInputAttributesPerPatch = []; - UsedOutputAttributesPerPatch = []; - } - public void SetInputUserAttribute(int index, int component) { int mask = 1 << index; @@ -74,7 +65,7 @@ namespace Ryujinx.Graphics.Shader.Translation int location = BitOperations.TrailingZeroCount(freeMask); if (location == 32) { - _gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}."); + gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}."); break; } diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs index f831ec940..aa9f4af3e 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs @@ -61,18 +61,12 @@ namespace Ryujinx.Graphics.Shader.Translation private readonly TransformFeedbackOutput[] _transformFeedbackOutputs; - readonly struct TransformFeedbackVariable : IEquatable + readonly struct TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0) + : IEquatable { - public IoVariable IoVariable { get; } - public int Location { get; } - public int Component { get; } - - public TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0) - { - IoVariable = ioVariable; - Location = location; - Component = component; - } + public IoVariable IoVariable { get; } = ioVariable; + public int Location { get; } = location; + public int Component { get; } = component; public override bool Equals(object other) { diff --git a/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs b/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs index 3f8ca3401..679ef1572 100644 --- a/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs +++ b/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs @@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Vulkan return (access, stages); } - private readonly record struct StageFlags : IEquatable + private readonly record struct StageFlags { public readonly PipelineStageFlags Source; public readonly PipelineStageFlags Dest; @@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Vulkan } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public unsafe void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass) + public void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass) { if (_queuedIncoherentBarrier > IncoherentBarrierType.None) { @@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public unsafe void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass) + public void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass) { Flush(cbs, null, inRenderPass, rpHolder, endRenderPass); } diff --git a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs index 5e05701e9..dc7316990 100644 --- a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs @@ -640,7 +640,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public unsafe void SetDataUnchecked(int offset, ReadOnlySpan data) where T : unmanaged + public void SetDataUnchecked(int offset, ReadOnlySpan data) where T : unmanaged { SetDataUnchecked(offset, MemoryMarshal.AsBytes(data)); } diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs index 97669942c..dfaabf5ec 100644 --- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs @@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public unsafe DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan layouts, int consumedDescriptors) + public DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan layouts, int consumedDescriptors) { TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: false, out var dsc); return dsc; diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index 2362902e1..d4f3def3b 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -9,48 +9,48 @@ namespace Ryujinx.Graphics.Vulkan { class FormatCapabilities { - private static readonly GAL.Format[] _scaledFormats = + private static readonly Format[] _scaledFormats = [ - GAL.Format.R8Uscaled, - GAL.Format.R8Sscaled, - GAL.Format.R16Uscaled, - GAL.Format.R16Sscaled, - GAL.Format.R8G8Uscaled, - GAL.Format.R8G8Sscaled, - GAL.Format.R16G16Uscaled, - GAL.Format.R16G16Sscaled, - GAL.Format.R8G8B8Uscaled, - GAL.Format.R8G8B8Sscaled, - GAL.Format.R16G16B16Uscaled, - GAL.Format.R16G16B16Sscaled, - GAL.Format.R8G8B8A8Uscaled, - GAL.Format.R8G8B8A8Sscaled, - GAL.Format.R16G16B16A16Uscaled, - GAL.Format.R16G16B16A16Sscaled, - GAL.Format.R10G10B10A2Uscaled, - GAL.Format.R10G10B10A2Sscaled + Format.R8Uscaled, + Format.R8Sscaled, + Format.R16Uscaled, + Format.R16Sscaled, + Format.R8G8Uscaled, + Format.R8G8Sscaled, + Format.R16G16Uscaled, + Format.R16G16Sscaled, + Format.R8G8B8Uscaled, + Format.R8G8B8Sscaled, + Format.R16G16B16Uscaled, + Format.R16G16B16Sscaled, + Format.R8G8B8A8Uscaled, + Format.R8G8B8A8Sscaled, + Format.R16G16B16A16Uscaled, + Format.R16G16B16A16Sscaled, + Format.R10G10B10A2Uscaled, + Format.R10G10B10A2Sscaled ]; - private static readonly GAL.Format[] _intFormats = + private static readonly Format[] _intFormats = [ - GAL.Format.R8Uint, - GAL.Format.R8Sint, - GAL.Format.R16Uint, - GAL.Format.R16Sint, - GAL.Format.R8G8Uint, - GAL.Format.R8G8Sint, - GAL.Format.R16G16Uint, - GAL.Format.R16G16Sint, - GAL.Format.R8G8B8Uint, - GAL.Format.R8G8B8Sint, - GAL.Format.R16G16B16Uint, - GAL.Format.R16G16B16Sint, - GAL.Format.R8G8B8A8Uint, - GAL.Format.R8G8B8A8Sint, - GAL.Format.R16G16B16A16Uint, - GAL.Format.R16G16B16A16Sint, - GAL.Format.R10G10B10A2Uint, - GAL.Format.R10G10B10A2Sint + Format.R8Uint, + Format.R8Sint, + Format.R16Uint, + Format.R16Sint, + Format.R8G8Uint, + Format.R8G8Sint, + Format.R16G16Uint, + Format.R16G16Sint, + Format.R8G8B8Uint, + Format.R8G8B8Sint, + Format.R16G16B16Uint, + Format.R16G16B16Sint, + Format.R8G8B8A8Uint, + Format.R8G8B8A8Sint, + Format.R16G16B16A16Uint, + Format.R16G16B16A16Sint, + Format.R10G10B10A2Uint, + Format.R10G10B10A2Sint ]; private readonly FormatFeatureFlags[] _bufferTable; diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index 5756ba9ae..ce6d9f6f9 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Vulkan TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, [int.MinValue, -1, 0], 1, true); } - public unsafe void Barrier() + public void Barrier() { Gd.Barriers.QueueMemoryBarrier(); } @@ -255,7 +255,7 @@ namespace Ryujinx.Graphics.Vulkan Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect); } - public unsafe void CommandBufferBarrier() + public void CommandBufferBarrier() { Gd.Barriers.QueueCommandBufferBarrier(); } @@ -1348,7 +1348,7 @@ namespace Ryujinx.Graphics.Vulkan _descriptorSetUpdater.ForceImageDirty(); } - public unsafe void TextureBarrier() + public void TextureBarrier() { Gd.Barriers.QueueTextureBarrier(); } @@ -1446,7 +1446,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.SamplesCount = FramebufferParams.AttachmentSamples.Length != 0 ? FramebufferParams.AttachmentSamples[0] : 1; } - protected unsafe void CreateRenderPass() + protected void CreateRenderPass() { var hasFramebuffer = FramebufferParams != null; diff --git a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs index 90a47bb67..b220792fb 100644 --- a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs +++ b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs @@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.Vulkan /// The minimum size the reserved data requires /// The required alignment for the buffer offset /// The reserved range of the staging buffer - public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment) + public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment) { if (size > BufferSize) { @@ -235,7 +235,7 @@ namespace Ryujinx.Graphics.Vulkan /// Command buffer to reserve the data on /// The minimum size the reserved data requires /// The reserved range of the staging buffer - public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size) + public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size) { return TryReserveData(cbs, size, _resourceAlignment); } diff --git a/src/Ryujinx.Graphics.Vulkan/SyncManager.cs b/src/Ryujinx.Graphics.Vulkan/SyncManager.cs index 5f6214a4f..3f3ba5c3c 100644 --- a/src/Ryujinx.Graphics.Vulkan/SyncManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/SyncManager.cs @@ -6,7 +6,7 @@ using System.Linq; namespace Ryujinx.Graphics.Vulkan { - class SyncManager + class SyncManager(VulkanRenderer gd, Device device) { private class SyncHandle { @@ -23,19 +23,10 @@ namespace Ryujinx.Graphics.Vulkan private ulong _firstHandle; - private readonly VulkanRenderer _gd; - private readonly Device _device; - private readonly List _handles; + private readonly List _handles = []; private ulong _flushId; private long _waitTicks; - public SyncManager(VulkanRenderer gd, Device device) - { - _gd = gd; - _device = device; - _handles = []; - } - public void RegisterFlush() { _flushId++; @@ -45,17 +36,17 @@ namespace Ryujinx.Graphics.Vulkan { ulong flushId = _flushId; MultiFenceHolder waitable = new(); - if (strict || _gd.InterruptAction == null) + if (strict || gd.InterruptAction == null) { - _gd.FlushAllCommands(); - _gd.CommandBufferPool.AddWaitable(waitable); + gd.FlushAllCommands(); + gd.CommandBufferPool.AddWaitable(waitable); } else { // Don't flush commands, instead wait for the current command buffer to finish. // If this sync is waited on before the command buffer is submitted, interrupt the gpu thread and flush it manually. - _gd.CommandBufferPool.AddInUseWaitable(waitable); + gd.CommandBufferPool.AddInUseWaitable(waitable); } SyncHandle handle = new() @@ -88,7 +79,7 @@ namespace Ryujinx.Graphics.Vulkan if (handle.ID > lastHandle) { - bool signaled = handle.Signalled || handle.Waitable.WaitForFences(_gd.Api, _device, 0); + bool signaled = handle.Signalled || handle.Waitable.WaitForFences(gd.Api, device, 0); if (signaled) { lastHandle = handle.ID; @@ -134,11 +125,11 @@ namespace Ryujinx.Graphics.Vulkan if (result.NeedsFlush(_flushId)) { - _gd.InterruptAction(() => + gd.InterruptAction(() => { if (result.NeedsFlush(_flushId)) { - _gd.FlushAllCommands(); + gd.FlushAllCommands(); } }); } @@ -150,7 +141,7 @@ namespace Ryujinx.Graphics.Vulkan return; } - bool signaled = result.Signalled || result.Waitable.WaitForFences(_gd.Api, _device, 1000000000); + bool signaled = result.Signalled || result.Waitable.WaitForFences(gd.Api, device, 1000000000); if (!signaled) { @@ -182,7 +173,7 @@ namespace Ryujinx.Graphics.Vulkan break; } - bool signaled = first.Waitable.WaitForFences(_gd.Api, _device, 0); + bool signaled = first.Waitable.WaitForFences(gd.Api, device, 0); if (signaled) { // Delete the sync object. diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index 9d4f07736..d144d5474 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Vulkan private bool _initialized; - public uint ProgramCount { get; set; } = 0; + public uint ProgramCount { get; set; } internal FormatCapabilities FormatCapabilities { get; private set; } internal HardwareCapabilities Capabilities; diff --git a/src/Ryujinx.Graphics.Vulkan/Window.cs b/src/Ryujinx.Graphics.Vulkan/Window.cs index bfa15d9a5..885b7abdb 100644 --- a/src/Ryujinx.Graphics.Vulkan/Window.cs +++ b/src/Ryujinx.Graphics.Vulkan/Window.cs @@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Vulkan private ScalingFilter _currentScalingFilter; private bool _colorSpacePassthroughEnabled; - public unsafe Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device) + public Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device) { _gd = gd; _physicalDevice = physicalDevice; diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index 4e136a8da..d9e9e1f75 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -698,8 +698,6 @@ namespace Ryujinx.HLE.FileSystem { throw new InvalidFirmwarePackageException("Update not found in xci file."); } - default: - break; } SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory) diff --git a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index 1103329c1..619462eab 100644 --- a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -38,7 +38,7 @@ namespace Ryujinx.HLE.FileSystem private readonly ConcurrentDictionary _romFsByPid; - private static bool _isInitialized = false; + private static bool _isInitialized; public static VirtualFileSystem CreateInstance() { diff --git a/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs index 294b8d1f6..40ecd7ef0 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs @@ -128,13 +128,13 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet #region Structs [StructLayout(LayoutKind.Sequential, Pack = 1)] - public unsafe struct TagInfo + public struct TagInfo { public fixed byte Data[0x58]; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - public unsafe struct StartParamForAmiiboSettings + public struct StartParamForAmiiboSettings { public byte ZeroValue; // Left at zero by sdknso public byte Type; @@ -151,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet } [StructLayout(LayoutKind.Sequential, Pack = 1)] - public unsafe struct ReturnValueForAmiiboSettings + public struct ReturnValueForAmiiboSettings { public byte AmiiboSettingsReturnFlag; private byte Padding1; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 3545c71aa..2a127f74c 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Applets private SoftwareKeyboardState _foregroundState = SoftwareKeyboardState.Uninitialized; private volatile InlineKeyboardState _backgroundState = InlineKeyboardState.Uninitialized; - private bool _isBackground = false; + private bool _isBackground; private AppletSession _normalSession; private AppletSession _interactiveSession; @@ -53,14 +53,14 @@ namespace Ryujinx.HLE.HOS.Applets private byte[] _transferMemory; private string _textValue = ""; - private int _cursorBegin = 0; + private int _cursorBegin; private Encoding _encoding = Encoding.Unicode; private KeyboardResult _lastResult = KeyboardResult.NotSet; - private IDynamicTextInputHandler _dynamicTextInputHandler = null; - private SoftwareKeyboardRenderer _keyboardRenderer = null; - private NpadReader _npads = null; - private bool _canAcceptController = false; + private IDynamicTextInputHandler _dynamicTextInputHandler; + private SoftwareKeyboardRenderer _keyboardRenderer; + private NpadReader _npads; + private bool _canAcceptController; private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard; private readonly Lock _lock = new(); diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs index 9183b6383..ef9362b8e 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs @@ -23,15 +23,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private readonly Lock _bufferLock = new(); - private RenderingSurfaceInfo _surfaceInfo = null; + private RenderingSurfaceInfo _surfaceInfo; private SKImageInfo _imageInfo; - private SKSurface _surface = null; - private byte[] _bufferData = null; + private SKSurface _surface; + private byte[] _bufferData; - private readonly SKBitmap _ryujinxLogo = null; - private readonly SKBitmap _padAcceptIcon = null; - private readonly SKBitmap _padCancelIcon = null; - private readonly SKBitmap _keyModeIcon = null; + private readonly SKBitmap _ryujinxLogo; + private readonly SKBitmap _padAcceptIcon; + private readonly SKBitmap _padCancelIcon; + private readonly SKBitmap _keyModeIcon; private readonly float _textBoxOutlineWidth; private readonly float _padPressedPenWidth; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs index a8b137df2..089a245b6 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs @@ -25,8 +25,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard } } - private TRef _cancelled = null; - private Thread _thread = null; + private TRef _cancelled; + private Thread _thread; private readonly Lock _lock = new(); public bool IsRunning diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs index 72f906422..42046f39a 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs @@ -3,7 +3,7 @@ using Ryujinx.HLE.HOS.Kernel.Threading; namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall { - partial class SyscallHandler + class SyscallHandler { private readonly KernelContext _context; diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs index 19f1b8be0..60ecb497e 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs @@ -6,7 +6,7 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Kernel.Threading { - partial class KScheduler : IDisposable + class KScheduler : IDisposable { public const int PrioritiesCount = 64; public static int CpuCoresCount; diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs index 8c436b1b2..d41b208f3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs @@ -4,7 +4,6 @@ using Ryujinx.Common.Utilities; using Ryujinx.HLE.HOS.Services.Account.Acc.Types; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.IO; namespace Ryujinx.HLE.HOS.Services.Account.Acc diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs index 8e0f515ba..6b9793bd5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs @@ -26,21 +26,21 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys // TODO: Determine where those fields are used. #pragma warning disable IDE0052 // Remove unread private member - private bool _screenShotPermission = false; - private bool _operationModeChangedNotification = false; - private bool _performanceModeChangedNotification = false; - private bool _restartMessageEnabled = false; - private bool _outOfFocusSuspendingEnabled = false; - private bool _handlesRequestToDisplay = false; + private bool _screenShotPermission; + private bool _operationModeChangedNotification; + private bool _performanceModeChangedNotification; + private bool _restartMessageEnabled; + private bool _outOfFocusSuspendingEnabled; + private bool _handlesRequestToDisplay; #pragma warning restore IDE0052 - private bool _autoSleepDisabled = false; + private bool _autoSleepDisabled; #pragma warning disable IDE0052 // Remove unread private member - private bool _albumImageTakenNotificationEnabled = false; - private bool _recordVolumeMuted = false; + private bool _albumImageTakenNotificationEnabled; + private bool _recordVolumeMuted; - private uint _screenShotImageOrientation = 0; + private uint _screenShotImageOrientation; #pragma warning restore IDE0052 - private uint _idleTimeDetectionExtension = 0; + private uint _idleTimeDetectionExtension; public ISelfController(ServiceCtx context, ulong pid) { diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs index a13e77e72..57f46bdbd 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs [Service("irs")] class IIrSensorServer : IpcService { - private int _irsensorSharedMemoryHandle = 0; + private int _irsensorSharedMemoryHandle; public IIrSensorServer(ServiceCtx context) { } diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs index d3a8bead2..b7b82a4e6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs @@ -10,8 +10,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.Lp2p { private readonly KEvent _stateChangeEvent; private readonly KEvent _jointEvent; - private int _stateChangeEventHandle = 0; - private int _jointEventHandle = 0; + private int _stateChangeEventHandle; + private int _jointEventHandle; public ISfServiceMonitor(ServiceCtx context) { 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 054f38794..09ade3f88 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs @@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu { public bool NeedsRealId => true; - private static InitializeMessage InitializeMemory = new InitializeMessage(); + private static InitializeMessage InitializeMemory; private const int InactiveTimeout = 6000; private const int FailureTimeout = 4000; diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs index d0eeaf125..87c5cb07d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu private readonly int _headerSize = Marshal.SizeOf(); private readonly byte[] _buffer = new byte[MaxPacketSize]; - private int _bufferEnd = 0; + private int _bufferEnd; // Client Packets. public event Action Initialize; @@ -312,9 +312,6 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu break; } - - default: - break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs index 23a52d908..1e1ced8cf 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs @@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii class MiiDatabaseManager { private readonly bool _isTestModeEnabled = false; - private uint _mountCounter = 0; + private uint _mountCounter; private const ulong DatabaseTestSaveDataId = 0x8000000000000031; private const ulong DatabaseSaveDataId = 0x8000000000000030; diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 36a89070d..7e3e4c0a2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -7,7 +7,6 @@ using Ryujinx.HLE.HOS.Services.Mii.Types; using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption; using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager; using System; -using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs index 581a2906b..dcf30a1d5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs @@ -13,9 +13,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService { private readonly GeneralServiceDetail _generalServiceDetail; - private IPInterfaceProperties _targetPropertiesCache = null; - private UnicastIPAddressInformation _targetAddressInfoCache = null; - private string _cacheChosenInterface = null; + private IPInterfaceProperties _targetPropertiesCache; + private UnicastIPAddressInformation _targetAddressInfoCache; + private string _cacheChosenInterface; public IGeneralService() { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index fea09ef47..72ba7e3ef 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv private IVirtualMemoryManager _clientMemory; private ulong _owner; - private bool _transferMemInitialized = false; + private bool _transferMemInitialized; // TODO: This should call set:sys::GetDebugModeFlag private readonly bool _debugModeEnabled = false; diff --git a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs index 9b026a1c3..e755189a6 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory // TODO: Find where they are set. private readonly bool _restrictionEnabled = false; private readonly bool _featuresRestriction = false; - private bool _freeCommunicationEnabled = false; + private bool _freeCommunicationEnabled; private readonly bool _stereoVisionRestrictionConfigurable = true; - private bool _stereoVisionRestriction = false; + private bool _stereoVisionRestriction; #pragma warning restore IDE0052, CS0414 public IParentalControlService(ServiceCtx context, ulong pid, bool withInitialize, int permissionFlag) diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs index c7c459196..d45735066 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst [Service("clkrst:i")] // 8.0.0+ class IClkrstManager : IpcService { - private int _moduleStateTableEventHandle = 0; + private int _moduleStateTableEventHandle; public IClkrstManager(ServiceCtx context) { } diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index 40329aa36..a13b08edc 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services private KProcess _selfProcess; private KThread _selfThread; private KEvent _wakeEvent; - private int _wakeHandle = 0; + private int _wakeHandle; private readonly ReaderWriterLockSlim _handleLock = new(); private readonly Dictionary _sessions = new(); @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services private readonly MemoryStream _responseDataStream; private readonly BinaryWriter _responseDataWriter; - private int _isDisposed = 0; + private int _isDisposed; public ManualResetEvent InitDone { get; } public string Name { get; } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 2240f60e4..bc2994448 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { [Service("bsd:s", true)] [Service("bsd:u", false)] - class IClient : IpcService + class IClient(ServiceCtx context, bool isPrivileged) : IpcService(context.Device.System.BsdServer) { private static readonly List _pollManagers = [ @@ -23,12 +23,6 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd ]; private BsdContext _context; - private readonly bool _isPrivileged; - - public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer) - { - _isPrivileged = isPrivileged; - } private ResultCode WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = LinuxError.SUCCESS) { @@ -79,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT); } - else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !_isPrivileged) + else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !isPrivileged) { if (domain != BsdAddressFamily.InterNetwork || type != BsdSocketType.Raw || protocol != ProtocolType.Icmp) { @@ -1040,7 +1034,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd LinuxError errno = LinuxError.ENOENT; int newSockFd = -1; - if (_isPrivileged) + if (isPrivileged) { errno = LinuxError.SUCCESS; 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 84135d87a..77d9a7b1a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs @@ -1,6 +1,5 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy; -using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs index 0c1fa3a9f..bf967d8f2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd private readonly FqdnResolver _fqdnResolver; #pragma warning restore IDE0052 - private readonly bool _isInitialized = false; + private readonly bool _isInitialized; public IManager(ServiceCtx context) { diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs index 4a2a910f8..5f2e3b3ce 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs @@ -44,8 +44,6 @@ namespace Ryujinx.HLE.HOS.Services.Spl configValue = (ulong)HardwareState.Development; result = SmcResult.Success; break; - default: - break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index ae61d0bf7..68238a5eb 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -792,8 +792,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger freeSlot = slot; } break; - default: - break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs index 5151930a5..55d7d0ddb 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { private static readonly Dictionary _registeredBinderObjects = new(); - private static int _lastBinderId = 0; + private static int _lastBinderId; private static readonly Lock _lock = new(); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs index a6b33e4ae..e3ac777ad 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs @@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Time private readonly TimeManager _timeManager; private readonly TimePermissions _permissions; - private int _timeSharedMemoryNativeHandle = 0; + private int _timeSharedMemoryNativeHandle; public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) { } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Register.cs b/src/Ryujinx.HLE/HOS/Tamper/Register.cs index cce13ee69..7e46afe9a 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Register.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Register.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Tamper { class Register : IOperand { - private ulong _register = 0; + private ulong _register; private readonly string _alias; public Register(string alias) diff --git a/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs b/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs index 422e4ef0e..0f077115d 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Tamper public ProcessState State => _process.State; - public bool TamperedCodeMemory { get; set; } = false; + public bool TamperedCodeMemory { get; set; } public TamperedKProcess(KProcess process) { diff --git a/src/Ryujinx.HLE/HOS/TamperMachine.cs b/src/Ryujinx.HLE/HOS/TamperMachine.cs index 609221535..d65345051 100644 --- a/src/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/src/Ryujinx.HLE/HOS/TamperMachine.cs @@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS // cheat and the re-execution of the first one. private const int TamperMachineSleepMs = 1000 / 12; - private Thread _tamperThread = null; + private Thread _tamperThread; private readonly ConcurrentQueue _programs = new(); - private long _pressedKeys = 0; + private long _pressedKeys; private readonly Dictionary _programDictionary = new(); private void Activate() diff --git a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs index acec66e82..d74e50a61 100644 --- a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs @@ -2,7 +2,6 @@ using Ryujinx.Common; using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Sdk.Sf; using Ryujinx.Horizon.Sdk.Sf.Hipc; -using System; namespace Ryujinx.Horizon.Sdk.Codec.Detail { diff --git a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs index fc5cd683d..efbaca728 100644 --- a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs +++ b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs @@ -9,20 +9,11 @@ namespace Ryujinx.Horizon.Sdk.Ngc.Detail private const int CompressedEntriesPerBlock = 64; private const int BitsPerWord = Set.BitsPerWord; - private readonly struct BitfieldRange + private readonly struct BitfieldRange(uint range, int baseValue) { - private readonly uint _range; - private readonly int _baseValue; - - public int BitfieldIndex => (int)(_range & 0x7ffffff); - public int BitfieldLength => (int)(_range >> 27) + 1; - public int BaseValue => _baseValue; - - public BitfieldRange(uint range, int baseValue) - { - _range = range; - _baseValue = baseValue; - } + public int BitfieldIndex => (int)(range & 0x7ffffff); + public int BitfieldLength => (int)(range >> 27) + 1; + public int BaseValue => baseValue; } private uint[] _bitfieldRanges; diff --git a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs index 422f756e4..0cd147771 100644 --- a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs +++ b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; namespace Ryujinx.Horizon.Sdk.OsTypes diff --git a/src/Ryujinx.Memory/AddressSpaceManager.cs b/src/Ryujinx.Memory/AddressSpaceManager.cs index 916ac1ca6..02dbe8558 100644 --- a/src/Ryujinx.Memory/AddressSpaceManager.cs +++ b/src/Ryujinx.Memory/AddressSpaceManager.cs @@ -1,7 +1,6 @@ using Ryujinx.Memory.Range; using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; namespace Ryujinx.Memory diff --git a/src/Ryujinx.Memory/NativeMemoryManager.cs b/src/Ryujinx.Memory/NativeMemoryManager.cs index cb8d5c243..6d1cfacf4 100644 --- a/src/Ryujinx.Memory/NativeMemoryManager.cs +++ b/src/Ryujinx.Memory/NativeMemoryManager.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Memory _length = length; } - public unsafe T* Pointer => _pointer; + public T* Pointer => _pointer; public int Length => _length; diff --git a/src/Ryujinx.Memory/Tracking/RegionHandle.cs b/src/Ryujinx.Memory/Tracking/RegionHandle.cs index 4e81a9723..ed238f289 100644 --- a/src/Ryujinx.Memory/Tracking/RegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/RegionHandle.cs @@ -60,8 +60,8 @@ namespace Ryujinx.Memory.Tracking private readonly MemoryTracking _tracking; private bool _disposed; - private int _checkCount = 0; - private int _volatileCount = 0; + private int _checkCount; + private int _volatileCount; private bool _volatile; internal MemoryPermission RequiredPermission diff --git a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs index b7ad8efe7..3d8847dc4 100644 --- a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs +++ b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs @@ -1,5 +1,4 @@ using NUnit.Framework; -using System; namespace Ryujinx.Tests.Cpu { diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 005f70896..2b5e6aedd 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -795,10 +795,10 @@ namespace Ryujinx.UI.App.Common { ldnWebHost = DefaultLanPlayWebHost; } - IEnumerable ldnGameDataArray = Array.Empty(); + using HttpClient httpClient = new HttpClient(); string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games"); - ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); + IEnumerable ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); var evt = new LdnGameDataReceivedEventArgs { LdnData = ldnGameDataArray diff --git a/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs b/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs index 81193c5b3..e3b71c9d4 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs @@ -12,7 +12,7 @@ namespace Ryujinx.UI.App.Common public TimeSpan TimePlayed { get; set; } = TimeSpan.Zero; [JsonPropertyName("last_played_utc")] - public DateTime? LastPlayed { get; set; } = null; + public DateTime? LastPlayed { get; set; } [JsonPropertyName("time_played")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index de8b68ace..8f4afcc2b 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -13,7 +13,6 @@ using Ryujinx.UI.Common.Helper; using System; using System.Collections.Generic; using System.Globalization; -using System.Text.Json.Nodes; namespace Ryujinx.UI.Common.Configuration { @@ -26,44 +25,23 @@ namespace Ryujinx.UI.Common.Configuration { public class Columns { - public ReactiveObject FavColumn { get; private set; } - public ReactiveObject IconColumn { get; private set; } - public ReactiveObject AppColumn { get; private set; } - public ReactiveObject DevColumn { get; private set; } - public ReactiveObject VersionColumn { get; private set; } - public ReactiveObject LdnInfoColumn { get; private set; } - public ReactiveObject TimePlayedColumn { get; private set; } - public ReactiveObject LastPlayedColumn { get; private set; } - public ReactiveObject FileExtColumn { get; private set; } - public ReactiveObject FileSizeColumn { get; private set; } - public ReactiveObject PathColumn { get; private set; } - - public Columns() - { - FavColumn = new ReactiveObject(); - IconColumn = new ReactiveObject(); - AppColumn = new ReactiveObject(); - DevColumn = new ReactiveObject(); - VersionColumn = new ReactiveObject(); - LdnInfoColumn = new ReactiveObject(); - TimePlayedColumn = new ReactiveObject(); - LastPlayedColumn = new ReactiveObject(); - FileExtColumn = new ReactiveObject(); - FileSizeColumn = new ReactiveObject(); - PathColumn = new ReactiveObject(); - } + public ReactiveObject FavColumn { get; private set; } = new(); + public ReactiveObject IconColumn { get; private set; } = new(); + public ReactiveObject AppColumn { get; private set; } = new(); + public ReactiveObject DevColumn { get; private set; } = new(); + public ReactiveObject VersionColumn { get; private set; } = new(); + public ReactiveObject LdnInfoColumn { get; private set; } = new(); + public ReactiveObject TimePlayedColumn { get; private set; } = new(); + public ReactiveObject LastPlayedColumn { get; private set; } = new(); + public ReactiveObject FileExtColumn { get; private set; } = new(); + public ReactiveObject FileSizeColumn { get; private set; } = new(); + public ReactiveObject PathColumn { get; private set; } = new(); } public class ColumnSortSettings { - public ReactiveObject SortColumnId { get; private set; } - public ReactiveObject SortAscending { get; private set; } - - public ColumnSortSettings() - { - SortColumnId = new ReactiveObject(); - SortAscending = new ReactiveObject(); - } + public ReactiveObject SortColumnId { get; private set; } = new(); + public ReactiveObject SortAscending { get; private set; } = new(); } /// @@ -71,22 +49,12 @@ namespace Ryujinx.UI.Common.Configuration /// public class ShownFileTypeSettings { - public ReactiveObject NSP { get; private set; } - public ReactiveObject PFS0 { get; private set; } - public ReactiveObject XCI { get; private set; } - public ReactiveObject NCA { get; private set; } - public ReactiveObject NRO { get; private set; } - public ReactiveObject NSO { get; private set; } - - public ShownFileTypeSettings() - { - NSP = new ReactiveObject(); - PFS0 = new ReactiveObject(); - XCI = new ReactiveObject(); - NCA = new ReactiveObject(); - NRO = new ReactiveObject(); - NSO = new ReactiveObject(); - } + public ReactiveObject NSP { get; private set; } = new(); + public ReactiveObject PFS0 { get; private set; } = new(); + public ReactiveObject XCI { get; private set; } = new(); + public ReactiveObject NCA { get; private set; } = new(); + public ReactiveObject NRO { get; private set; } = new(); + public ReactiveObject NSO { get; private set; } = new(); } // @@ -94,20 +62,11 @@ namespace Ryujinx.UI.Common.Configuration /// public class WindowStartupSettings { - public ReactiveObject WindowSizeWidth { get; private set; } - public ReactiveObject WindowSizeHeight { get; private set; } - public ReactiveObject WindowPositionX { get; private set; } - public ReactiveObject WindowPositionY { get; private set; } - public ReactiveObject WindowMaximized { get; private set; } - - public WindowStartupSettings() - { - WindowSizeWidth = new ReactiveObject(); - WindowSizeHeight = new ReactiveObject(); - WindowPositionX = new ReactiveObject(); - WindowPositionY = new ReactiveObject(); - WindowMaximized = new ReactiveObject(); - } + public ReactiveObject WindowSizeWidth { get; private set; } = new(); + public ReactiveObject WindowSizeHeight { get; private set; } = new(); + public ReactiveObject WindowPositionX { get; private set; } = new(); + public ReactiveObject WindowPositionY { get; private set; } = new(); + public ReactiveObject WindowMaximized { get; private set; } = new(); } /// @@ -421,32 +380,24 @@ namespace Ryujinx.UI.Common.Configuration /// /// Enable or disable keyboard support (Independent from controllers binding) /// - public ReactiveObject EnableKeyboard { get; private set; } + public ReactiveObject EnableKeyboard { get; private set; } = new(); /// /// Enable or disable mouse support (Independent from controllers binding) /// - public ReactiveObject EnableMouse { get; private set; } + public ReactiveObject EnableMouse { get; private set; } = new(); /// /// Hotkey Keyboard Bindings /// - public ReactiveObject Hotkeys { get; private set; } + public ReactiveObject Hotkeys { get; private set; } = new(); /// /// Input device configuration. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed. /// TODO: Implement a ReactiveList class. /// - public ReactiveObject> InputConfig { get; private set; } - - public HidSection() - { - EnableKeyboard = new ReactiveObject(); - EnableMouse = new ReactiveObject(); - Hotkeys = new ReactiveObject(); - InputConfig = new ReactiveObject>(); - } + public ReactiveObject> InputConfig { get; private set; } = new(); } /// diff --git a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs index ea6d7c32a..975eda3ff 100644 --- a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs @@ -99,16 +99,13 @@ namespace Ryujinx.UI.Common.Helper Dictionary updates = pfs.GetContentData(ContentMetaType.Patch, vfs, checkLevel); - Nca patchNca = null; - Nca controlNca = null; - if (!updates.TryGetValue(applicationIdBase, out ContentMetaData content)) { continue; } - patchNca = content.GetNcaByType(vfs.KeySet, ContentType.Program); - controlNca = content.GetNcaByType(vfs.KeySet, ContentType.Control); + Nca patchNca = content.GetNcaByType(vfs.KeySet, ContentType.Program); + Nca controlNca = content.GetNcaByType(vfs.KeySet, ContentType.Control); if (controlNca == null || patchNca == null) { diff --git a/src/Ryujinx/App.axaml.cs b/src/Ryujinx/App.axaml.cs index 22c8d59de..cd4416aa1 100644 --- a/src/Ryujinx/App.axaml.cs +++ b/src/Ryujinx/App.axaml.cs @@ -144,7 +144,7 @@ namespace Ryujinx.Ava public static ThemeVariant DetectSystemTheme() { - if (Application.Current is App app) + if (Current is App app) { var colorValues = app.PlatformSettings.GetColorValues(); diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 400831cfa..08302d7fb 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -92,7 +92,7 @@ namespace Ryujinx.Ava private long _lastCursorMoveTime; private bool _isCursorInRenderer = true; - private bool _ignoreCursorState = false; + private bool _ignoreCursorState; private enum CursorStates { @@ -106,7 +106,7 @@ namespace Ryujinx.Ava private DateTime _lastShaderReset; private uint _displayCount; - private uint _previousCount = 0; + private uint _previousCount; private bool _isStopped; private bool _isActive; diff --git a/src/Ryujinx/UI/Models/CheatNode.cs b/src/Ryujinx/UI/Models/CheatNode.cs index 9179fb0ef..9007593ed 100644 --- a/src/Ryujinx/UI/Models/CheatNode.cs +++ b/src/Ryujinx/UI/Models/CheatNode.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Ava.UI.Models { public class CheatNode : BaseModel { - private bool _isEnabled = false; + private bool _isEnabled; public ObservableCollection SubNodes { get; } = []; public string CleanName => Name.Length > 0 ? Name[1..^7] : Name; public string BuildIdKey => $"{BuildId}-{Name}"; diff --git a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs index e651baa22..a404a2ab4 100644 --- a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Ava.UI.ViewModels private AvaloniaList _downloadableContents = []; private AvaloniaList _selectedDownloadableContents = []; private AvaloniaList _views = []; - private bool _showBundledContentNotice = false; + private bool _showBundledContentNotice; private string _search; private readonly ApplicationData _applicationData; diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index e195b9e3b..b3377b018 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -6,7 +6,6 @@ using Avalonia.Media; using Avalonia.Platform.Storage; using Avalonia.Threading; using DynamicData; -using DynamicData.Alias; using DynamicData.Binding; using FluentAvalonia.UI.Controls; using Gommon; @@ -466,7 +465,7 @@ namespace Ryujinx.Ava.UI.ViewModels public bool OpenDeviceSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0; - public bool TrimXCIEnabled => Ryujinx.Common.Utilities.XCIFileTrimmer.CanTrim(SelectedApplication.Path, new Common.XCIFileTrimmerMainWindowLog(this)); + public bool TrimXCIEnabled => XCIFileTrimmer.CanTrim(SelectedApplication.Path, new XCIFileTrimmerMainWindowLog(this)); public bool OpenBcatSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0; @@ -1542,7 +1541,7 @@ namespace Ryujinx.Ava.UI.ViewModels Dispatcher.UIThread.InvokeAsync(() => { Application.Current.Styles.TryGetResource(args.VSyncMode, - Avalonia.Application.Current.ActualThemeVariant, + Application.Current.ActualThemeVariant, out object color); if (color is not null) @@ -2218,7 +2217,7 @@ namespace Ryujinx.Ava.UI.ViewModels } } - public async void ProcessTrimResult(String filename, Ryujinx.Common.Utilities.XCIFileTrimmer.OperationOutcome operationOutcome) + public async void ProcessTrimResult(String filename, XCIFileTrimmer.OperationOutcome operationOutcome) { string notifyUser = operationOutcome.ToLocalisedText(); @@ -2233,8 +2232,8 @@ namespace Ryujinx.Ava.UI.ViewModels { switch (operationOutcome) { - case Ryujinx.Common.Utilities.XCIFileTrimmer.OperationOutcome.Successful: - if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + case XCIFileTrimmer.OperationOutcome.Successful: + if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { if (desktop.MainWindow is MainWindow mainWindow) mainWindow.LoadApplications(); @@ -2251,7 +2250,7 @@ namespace Ryujinx.Ava.UI.ViewModels return; } - var trimmer = new XCIFileTrimmer(filename, new Common.XCIFileTrimmerMainWindowLog(this)); + var trimmer = new XCIFileTrimmer(filename, new XCIFileTrimmerMainWindowLog(this)); if (trimmer.CanBeTrimmed) { diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index a6be45eea..a10a5db3e 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Ava.UI.ViewModels private AvaloniaList _titleUpdates = []; private AvaloniaList _views = []; private object _selectedUpdate = new TitleUpdateViewNoUpdateSentinal(); - private bool _showBundledContentNotice = false; + private bool _showBundledContentNotice; public AvaloniaList TitleUpdates { diff --git a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs index 45c631ded..4d9cd9bfe 100644 --- a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs @@ -6,7 +6,6 @@ using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; using Ryujinx.UI.App.Common; using Ryujinx.UI.Common.Configuration; -using System; using System.Collections.Generic; using System.Globalization; using System.IO; diff --git a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs index 639085b63..cfaca7818 100644 --- a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs @@ -231,7 +231,7 @@ namespace Ryujinx.Ava.UI.Windows ViewModel.ShowContent = true; ViewModel.IsLoadingIndeterminate = false; - if (startFullscreen && ViewModel.WindowState != MainWindow.FullScreenWindowState) + if (startFullscreen && ViewModel.WindowState != FullScreenWindowState) { ViewModel.ToggleFullscreen(); } @@ -243,7 +243,7 @@ namespace Ryujinx.Ava.UI.Windows ViewModel.ShowLoadProgress = true; ViewModel.IsLoadingIndeterminate = true; - if (startFullscreen && ViewModel.WindowState != MainWindow.FullScreenWindowState) + if (startFullscreen && ViewModel.WindowState != FullScreenWindowState) { ViewModel.ToggleFullscreen(); }