diff --git a/src/Ryujinx.Memory/AddressSpaceManager.cs b/src/Ryujinx.Memory/AddressSpaceManager.cs index 7bd572d7a..76c679d41 100644 --- a/src/Ryujinx.Memory/AddressSpaceManager.cs +++ b/src/Ryujinx.Memory/AddressSpaceManager.cs @@ -109,7 +109,7 @@ namespace Ryujinx.Memory yield break; } - foreach (var hostRegion in GetHostRegionsImpl(va, size)) + foreach (HostMemoryRange hostRegion in GetHostRegionsImpl(va, size)) { yield return hostRegion; } @@ -123,7 +123,7 @@ namespace Ryujinx.Memory yield break; } - var hostRegions = GetHostRegionsImpl(va, size); + IEnumerable hostRegions = GetHostRegionsImpl(va, size); if (hostRegions == null) { yield break; @@ -132,7 +132,7 @@ namespace Ryujinx.Memory ulong backingStart = (ulong)_backingMemory.Pointer; ulong backingEnd = backingStart + _backingMemory.Size; - foreach (var hostRegion in hostRegions) + foreach (HostMemoryRange hostRegion in hostRegions) { if (hostRegion.Address >= backingStart && hostRegion.Address < backingEnd) { diff --git a/src/Ryujinx.Memory/BytesReadOnlySequenceSegment.cs b/src/Ryujinx.Memory/BytesReadOnlySequenceSegment.cs index 5fe8d936c..6ac83464c 100644 --- a/src/Ryujinx.Memory/BytesReadOnlySequenceSegment.cs +++ b/src/Ryujinx.Memory/BytesReadOnlySequenceSegment.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Memory public BytesReadOnlySequenceSegment Append(Memory memory) { - var nextSegment = new BytesReadOnlySequenceSegment(memory) + BytesReadOnlySequenceSegment nextSegment = new BytesReadOnlySequenceSegment(memory) { RunningIndex = RunningIndex + Memory.Length }; @@ -34,8 +34,8 @@ namespace Ryujinx.Memory /// True if the segments are contiguous, otherwise false public unsafe bool IsContiguousWith(Memory other, out nuint contiguousStart, out int contiguousSize) { - if (MemoryMarshal.TryGetMemoryManager>(Memory, out var thisMemoryManager) && - MemoryMarshal.TryGetMemoryManager>(other, out var otherMemoryManager) && + if (MemoryMarshal.TryGetMemoryManager>(Memory, out NativeMemoryManager thisMemoryManager) && + MemoryMarshal.TryGetMemoryManager>(other, out NativeMemoryManager otherMemoryManager) && thisMemoryManager.Pointer + thisMemoryManager.Length == otherMemoryManager.Pointer) { contiguousStart = (nuint)thisMemoryManager.Pointer; diff --git a/src/Ryujinx.Memory/IVirtualMemoryManager.cs b/src/Ryujinx.Memory/IVirtualMemoryManager.cs index 102cedc94..1f8ca37aa 100644 --- a/src/Ryujinx.Memory/IVirtualMemoryManager.cs +++ b/src/Ryujinx.Memory/IVirtualMemoryManager.cs @@ -118,7 +118,7 @@ namespace Ryujinx.Memory { int copySize = (int)Math.Min(MaxChunkSize, size - subOffset); - using var writableRegion = GetWritableRegion(va + subOffset, copySize); + using WritableRegion writableRegion = GetWritableRegion(va + subOffset, copySize); writableRegion.Memory.Span.Fill(value); } diff --git a/src/Ryujinx.Memory/MemoryManagementWindows.cs b/src/Ryujinx.Memory/MemoryManagementWindows.cs index 468355dd0..e5a50f866 100644 --- a/src/Ryujinx.Memory/MemoryManagementWindows.cs +++ b/src/Ryujinx.Memory/MemoryManagementWindows.cs @@ -102,7 +102,7 @@ namespace Ryujinx.Memory public static nint CreateSharedMemory(nint size, bool reserve) { - var prot = reserve ? FileMapProtection.SectionReserve : FileMapProtection.SectionCommit; + FileMapProtection prot = reserve ? FileMapProtection.SectionReserve : FileMapProtection.SectionCommit; nint handle = WindowsApi.CreateFileMapping( WindowsApi.InvalidHandleValue, diff --git a/src/Ryujinx.Memory/Range/MultiRange.cs b/src/Ryujinx.Memory/Range/MultiRange.cs index 093e21903..c3bb99f35 100644 --- a/src/Ryujinx.Memory/Range/MultiRange.cs +++ b/src/Ryujinx.Memory/Range/MultiRange.cs @@ -73,7 +73,7 @@ namespace Ryujinx.Memory.Range } else { - var ranges = new List(); + List ranges = []; foreach (MemoryRange range in _ranges) { diff --git a/src/Ryujinx.Memory/Range/MultiRangeList.cs b/src/Ryujinx.Memory/Range/MultiRangeList.cs index c3c6ae797..f5fd6164d 100644 --- a/src/Ryujinx.Memory/Range/MultiRangeList.cs +++ b/src/Ryujinx.Memory/Range/MultiRangeList.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Memory.Range for (int i = 0; i < range.Count; i++) { - var subrange = range.GetSubRange(i); + MemoryRange subrange = range.GetSubRange(i); if (MemoryRange.IsInvalid(ref subrange)) { @@ -54,7 +54,7 @@ namespace Ryujinx.Memory.Range for (int i = 0; i < range.Count; i++) { - var subrange = range.GetSubRange(i); + MemoryRange subrange = range.GetSubRange(i); if (MemoryRange.IsInvalid(ref subrange)) { @@ -97,7 +97,7 @@ namespace Ryujinx.Memory.Range for (int i = 0; i < range.Count; i++) { - var subrange = range.GetSubRange(i); + MemoryRange subrange = range.GetSubRange(i); if (MemoryRange.IsInvalid(ref subrange)) { @@ -172,8 +172,8 @@ namespace Ryujinx.Memory.Range private List GetList() { - var items = _items.AsList(); - var result = new List(); + List> items = _items.AsList(); + List result = new List(); foreach (RangeNode item in items) { diff --git a/src/Ryujinx.Memory/Range/NonOverlappingRangeList.cs b/src/Ryujinx.Memory/Range/NonOverlappingRangeList.cs index 511589176..894078aee 100644 --- a/src/Ryujinx.Memory/Range/NonOverlappingRangeList.cs +++ b/src/Ryujinx.Memory/Range/NonOverlappingRangeList.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Memory.Range // For instance, while a virtual mapping could cover 0-2 in physical space, the space 0-1 may have already been reserved... // So we need to return both the split 0-1 and 1-2 ranges. - var results = new T[1]; + T[] results = new T[1]; int count = FindOverlapsNonOverlapping(address, size, ref results); if (count == 0) diff --git a/src/Ryujinx.Memory/Tracking/MemoryTracking.cs b/src/Ryujinx.Memory/Tracking/MemoryTracking.cs index 96cb2c5f5..d60a3bd8f 100644 --- a/src/Ryujinx.Memory/Tracking/MemoryTracking.cs +++ b/src/Ryujinx.Memory/Tracking/MemoryTracking.cs @@ -76,7 +76,7 @@ namespace Ryujinx.Memory.Tracking lock (TrackingLock) { - ref var overlaps = ref ThreadStaticArray.Get(); + ref VirtualRegion[] overlaps = ref ThreadStaticArray.Get(); for (int type = 0; type < 2; type++) { @@ -114,7 +114,7 @@ namespace Ryujinx.Memory.Tracking lock (TrackingLock) { - ref var overlaps = ref ThreadStaticArray.Get(); + ref VirtualRegion[] overlaps = ref ThreadStaticArray.Get(); for (int type = 0; type < 2; type++) { @@ -228,7 +228,7 @@ namespace Ryujinx.Memory.Tracking /// The memory tracking handle public RegionHandle BeginTracking(ulong address, ulong size, int id, RegionFlags flags = RegionFlags.None) { - var (paAddress, paSize) = PageAlign(address, size); + (ulong paAddress, ulong paSize) = PageAlign(address, size); lock (TrackingLock) { @@ -251,7 +251,7 @@ namespace Ryujinx.Memory.Tracking /// The memory tracking handle internal RegionHandle BeginTrackingBitmap(ulong address, ulong size, ConcurrentBitmap bitmap, int bit, int id, RegionFlags flags = RegionFlags.None) { - var (paAddress, paSize) = PageAlign(address, size); + (ulong paAddress, ulong paSize) = PageAlign(address, size); lock (TrackingLock) { @@ -296,7 +296,7 @@ namespace Ryujinx.Memory.Tracking lock (TrackingLock) { - ref var overlaps = ref ThreadStaticArray.Get(); + ref VirtualRegion[] overlaps = ref ThreadStaticArray.Get(); NonOverlappingRangeList regions = guest ? _guestVirtualRegions : _virtualRegions; diff --git a/src/Ryujinx.Memory/Tracking/MultiRegionHandle.cs b/src/Ryujinx.Memory/Tracking/MultiRegionHandle.cs index 6fdca69f5..a9b79ab3e 100644 --- a/src/Ryujinx.Memory/Tracking/MultiRegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/MultiRegionHandle.cs @@ -320,7 +320,7 @@ namespace Ryujinx.Memory.Tracking if (startHandle == lastHandle) { - var handle = _handles[startHandle]; + RegionHandle handle = _handles[startHandle]; if (_sequenceNumberBitmap.Set(startHandle)) { _uncheckedHandles--; @@ -410,7 +410,7 @@ namespace Ryujinx.Memory.Tracking { GC.SuppressFinalize(this); - foreach (var handle in _handles) + foreach (RegionHandle handle in _handles) { handle.Dispose(); } diff --git a/src/Ryujinx.Memory/Tracking/RegionHandle.cs b/src/Ryujinx.Memory/Tracking/RegionHandle.cs index 4e81a9723..b938c6ea9 100644 --- a/src/Ryujinx.Memory/Tracking/RegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/RegionHandle.cs @@ -199,7 +199,7 @@ namespace Ryujinx.Memory.Tracking _allRegions.AddRange(_regions); _allRegions.AddRange(_guestRegions); - foreach (var region in _allRegions) + foreach (VirtualRegion region in _allRegions) { region.Handles.Add(this); } @@ -217,8 +217,8 @@ namespace Ryujinx.Memory.Tracking { // Assumes the tracking lock is held, so nothing else can signal right now. - var oldBitmap = Bitmap; - var oldBit = DirtyBit; + ConcurrentBitmap oldBitmap = Bitmap; + int oldBit = DirtyBit; bitmap.Set(bit, Dirty); diff --git a/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs b/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs index 57129a182..1e44c0916 100644 --- a/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/SmartMultiRegionHandle.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Memory.Tracking public void ForceDirty(ulong address, ulong size) { - foreach (var handle in _handles) + foreach (RegionHandle handle in _handles) { if (handle != null && handle.OverlapsWith(address, size)) { @@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Tracking public void RegisterAction(RegionSignal action) { - foreach (var handle in _handles) + foreach (RegionHandle handle in _handles) { if (handle != null) { @@ -67,7 +67,7 @@ namespace Ryujinx.Memory.Tracking public void RegisterPreciseAction(PreciseRegionSignal action) { - foreach (var handle in _handles) + foreach (RegionHandle handle in _handles) { if (handle != null) { @@ -273,7 +273,7 @@ namespace Ryujinx.Memory.Tracking { GC.SuppressFinalize(this); - foreach (var handle in _handles) + foreach (RegionHandle handle in _handles) { handle?.Dispose(); } diff --git a/src/Ryujinx.Memory/Tracking/VirtualRegion.cs b/src/Ryujinx.Memory/Tracking/VirtualRegion.cs index 35e9c2d9b..7f5eb9b11 100644 --- a/src/Ryujinx.Memory/Tracking/VirtualRegion.cs +++ b/src/Ryujinx.Memory/Tracking/VirtualRegion.cs @@ -90,7 +90,7 @@ namespace Ryujinx.Memory.Tracking MemoryPermission result = MemoryPermission.ReadAndWrite; - foreach (var handle in Handles) + foreach (RegionHandle handle in Handles) { result &= handle.RequiredPermission; if (result == 0) @@ -143,7 +143,7 @@ namespace Ryujinx.Memory.Tracking // The new region inherits all of our parents. newRegion.Handles = new List(Handles); - foreach (var parent in Handles) + foreach (RegionHandle parent in Handles) { parent.AddChild(newRegion); } diff --git a/src/Ryujinx.Memory/VirtualMemoryManagerBase.cs b/src/Ryujinx.Memory/VirtualMemoryManagerBase.cs index f41072244..eb5d66829 100644 --- a/src/Ryujinx.Memory/VirtualMemoryManagerBase.cs +++ b/src/Ryujinx.Memory/VirtualMemoryManagerBase.cs @@ -234,7 +234,7 @@ namespace Ryujinx.Memory nuint pa = TranslateVirtualAddressChecked(va); - var target = GetPhysicalAddressSpan(pa, data.Length); + Span target = GetPhysicalAddressSpan(pa, data.Length); bool changed = !data.SequenceEqual(target); diff --git a/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs b/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs index 2a294bba9..f1bbf2f41 100644 --- a/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs +++ b/src/Ryujinx.Memory/WindowsShared/PlaceholderManager.cs @@ -128,7 +128,7 @@ namespace Ryujinx.Memory.WindowsShared /// Memory block that owns the mapping public void MapView(nint sharedMemory, ulong srcOffset, nint location, nint size, MemoryBlock owner) { - ref var partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; + ref NativeReaderWriterLock partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; partialUnmapLock.AcquireReaderLock(); try @@ -155,7 +155,7 @@ namespace Ryujinx.Memory.WindowsShared { SplitForMap((ulong)location, (ulong)size, srcOffset); - var ptr = WindowsApi.MapViewOfFile3( + IntPtr ptr = WindowsApi.MapViewOfFile3( sharedMemory, WindowsApi.CurrentProcessHandle, location, @@ -187,7 +187,7 @@ namespace Ryujinx.Memory.WindowsShared { ulong endAddress = address + size; - var overlaps = new RangeNode[InitialOverlapsSize]; + RangeNode[] overlaps = new RangeNode[InitialOverlapsSize]; lock (_mappings) { @@ -196,7 +196,7 @@ namespace Ryujinx.Memory.WindowsShared Debug.Assert(count == 1); Debug.Assert(!IsMapped(overlaps[0].Value)); - var overlap = overlaps[0]; + RangeNode overlap = overlaps[0]; ulong overlapStart = overlap.Start; ulong overlapEnd = overlap.End; @@ -257,7 +257,7 @@ namespace Ryujinx.Memory.WindowsShared /// Memory block that owns the mapping public void UnmapView(nint sharedMemory, nint location, nint size, MemoryBlock owner) { - ref var partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; + ref NativeReaderWriterLock partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; partialUnmapLock.AcquireReaderLock(); try @@ -289,7 +289,7 @@ namespace Ryujinx.Memory.WindowsShared ulong unmapSize = (ulong)size; ulong endAddress = startAddress + unmapSize; - var overlaps = new RangeNode[InitialOverlapsSize]; + RangeNode[] overlaps = new RangeNode[InitialOverlapsSize]; int count; lock (_mappings) @@ -299,7 +299,7 @@ namespace Ryujinx.Memory.WindowsShared for (int index = 0; index < count; index++) { - var overlap = overlaps[index]; + RangeNode overlap = overlaps[index]; if (IsMapped(overlap.Value)) { @@ -319,8 +319,8 @@ namespace Ryujinx.Memory.WindowsShared // This is necessary because Windows does not support partial view unmaps. // That is, you can only fully unmap a view that was previously mapped, you can't just unmap a chunck of it. - ref var partialUnmapState = ref GetPartialUnmapState(); - ref var partialUnmapLock = ref partialUnmapState.PartialUnmapLock; + ref PartialUnmapState partialUnmapState = ref GetPartialUnmapState(); + ref NativeReaderWriterLock partialUnmapLock = ref partialUnmapState.PartialUnmapLock; partialUnmapLock.UpgradeToWriterLock(); try @@ -400,7 +400,7 @@ namespace Ryujinx.Memory.WindowsShared for (; node != null; node = successor) { successor = node.Successor; - var overlap = node; + RangeNode overlap = node; if (!IsMapped(overlap.Value)) { @@ -456,7 +456,7 @@ namespace Ryujinx.Memory.WindowsShared /// True if the reprotection was successful, false otherwise public bool ReprotectView(nint address, nint size, MemoryPermission permission) { - ref var partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; + ref NativeReaderWriterLock partialUnmapLock = ref GetPartialUnmapState().PartialUnmapLock; partialUnmapLock.AcquireReaderLock(); try @@ -494,7 +494,7 @@ namespace Ryujinx.Memory.WindowsShared for (; node != null; node = successorNode) { successorNode = node.Successor; - var overlap = node; + RangeNode overlap = node; ulong mappedAddress = overlap.Start; ulong mappedSize = overlap.End - overlap.Start; @@ -604,7 +604,7 @@ namespace Ryujinx.Memory.WindowsShared for (; node != null; node = successorNode) { successorNode = node.Successor; - var protection = node; + RangeNode protection = node; ulong protAddress = protection.Start; ulong protEndAddress = protection.End; @@ -664,7 +664,7 @@ namespace Ryujinx.Memory.WindowsShared for (; node != null; node = successorNode) { successorNode = node.Successor; - var protection = node; + RangeNode protection = node; ulong protAddress = protection.Start; ulong protEndAddress = protection.End; @@ -698,7 +698,7 @@ namespace Ryujinx.Memory.WindowsShared private void RestoreRangeProtection(ulong address, ulong size) { ulong endAddress = address + size; - var overlaps = new RangeNode[InitialOverlapsSize]; + RangeNode[] overlaps = new RangeNode[InitialOverlapsSize]; int count; lock (_protections) @@ -708,7 +708,7 @@ namespace Ryujinx.Memory.WindowsShared for (int index = 0; index < count; index++) { - var protection = overlaps[index]; + RangeNode protection = overlaps[index]; // If protection is R/W we don't need to reprotect as views are initially mapped as R/W. if (protection.Value == MemoryPermission.ReadAndWrite)