diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 6d8fcb4d8..df7815968 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 6d8fcb4d8bce23a9f767b164fb20ddf12c87137a +Subproject commit df78159688a5824291ff95b0ae963fdf51f2bb3a diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 74fab4275..69f39d1cf 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -847,8 +847,7 @@ public partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index 82ca4159a..7082adceb 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -382,7 +382,7 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || + if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { sense = _dev.ReadCd(out cmdBuf, out _, firstSectorToRead, blockSize, blocksToRead, diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index 647eb4f2f..e624c4ca4 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -1393,8 +1393,7 @@ sealed partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs index 4efefe4a9..cd468db74 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Error.cs @@ -257,7 +257,7 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || + if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead, @@ -280,7 +280,7 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || + if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { sense = _dev.ReadCd(out cmdBuf, out _, badSectorToReRead, blockSize, sectorsToReRead, diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs index ef7957d45..b48b046e2 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs @@ -159,7 +159,7 @@ partial class Dump DecodedSense? decSense = Sense.Decode(senseBuf); // Try to workaround firmware - if(decSense?.ASC == 0x11 && decSense?.ASCQ == 0x05 || + if(decSense is { ASC: 0x11, ASCQ: 0x05 } || decSense?.ASC == 0x64) { sense = _dev.ReadCd(out cmdBuf, out _, badSectorToRead, blockSize, sectorsToTrim, diff --git a/Aaru.Core/Devices/Dumping/MMC.cs b/Aaru.Core/Devices/Dumping/MMC.cs index 8b8a5c395..b9c494c3a 100644 --- a/Aaru.Core/Devices/Dumping/MMC.cs +++ b/Aaru.Core/Devices/Dumping/MMC.cs @@ -305,8 +305,7 @@ partial class Dump { PFI.PhysicalFormatInformation? nintendoPfi = PFI.Decode(cmdBuf, dskType); - if(nintendoPfi?.DiskCategory == DiskCategory.Nintendo && - nintendoPfi.Value.PartVersion == 15) + if(nintendoPfi is { DiskCategory: DiskCategory.Nintendo, PartVersion: 15 }) { _dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented."); diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 4525eda17..8c151f43c 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -829,8 +829,7 @@ partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index f8a3d8f2c..f50609ee5 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -385,7 +385,7 @@ public partial class Dump if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + modePage.Page == 0x01 && modePage.Subpage == 0x00)) currentModePage = modePage; } @@ -681,8 +681,7 @@ public partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 2268dfbd3..fd7860164 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -383,7 +383,7 @@ public partial class Dump if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + modePage.Page == 0x01 && modePage.Subpage == 0x00)) currentModePage = modePage; } @@ -589,8 +589,7 @@ public partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 163d801bb..d08d10352 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -187,8 +187,7 @@ partial class Dump PulseProgress?.Invoke("Rewinding, please wait..."); _dev.RequestSense(out senseBuf, _dev.Timeout, out duration); decSense = Sense.Decode(senseBuf); - } while(decSense is { ASC: 0x00 } && - decSense.Value.ASCQ is 0x1A or 0x19); + } while(decSense is { ASC: 0x00, ASCQ: 0x1A or 0x19 }); // And yet, did not rewind! if(decSense.HasValue && @@ -732,8 +731,7 @@ partial class Dump PulseProgress?.Invoke("Rewinding, please wait..."); _dev.RequestSense(out senseBuf, _dev.Timeout, out duration); decSense = Sense.Decode(senseBuf); - } while(decSense is { ASC: 0x00 } && - decSense.Value.ASCQ is 0x1A or 0x19); + } while(decSense is { ASC: 0x00, ASCQ: 0x1A or 0x19 }); // And yet, did not rewind! if(decSense.HasValue && @@ -1410,8 +1408,7 @@ partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index c106093e1..62f321c71 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -1254,8 +1254,7 @@ partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index cc6cbd881..c24af2665 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -952,8 +952,7 @@ public partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index e198cf5db..534a67949 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -1010,7 +1010,7 @@ partial class Dump if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage.Page == 0x01 && modePage.Subpage == 0x00)) + modePage.Page == 0x01 && modePage.Subpage == 0x00)) currentModePage = modePage; } @@ -1249,8 +1249,7 @@ partial class Dump if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); - if(minSpeed > 0 && - minSpeed < double.MaxValue) + if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke($"Slowest speed burst: {minSpeed:F3} MiB/sec."); UpdateStatus?.Invoke($"{_resume.BadBlocks.Count} sectors could not be read."); diff --git a/Aaru.Core/Devices/ReaderSCSI.cs b/Aaru.Core/Devices/ReaderSCSI.cs index 0603d7798..8f03a2524 100644 --- a/Aaru.Core/Devices/ReaderSCSI.cs +++ b/Aaru.Core/Devices/ReaderSCSI.cs @@ -194,9 +194,7 @@ sealed partial class Reader { decSense = Sense.Decode(senseBuf); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { CanReadRaw = true; @@ -437,9 +435,7 @@ sealed partial class Reader { decSense = Sense.Decode(senseBuf); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { CanReadRaw = true; diff --git a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs index 8341b5437..e055ee379 100644 --- a/Aaru.Core/Devices/Report/GdRomSwapTrick.cs +++ b/Aaru.Core/Devices/Report/GdRomSwapTrick.cs @@ -96,10 +96,7 @@ public sealed partial class DeviceReport DecodedSense? decodedSense = Sense.Decode(senseBuffer); - if(decodedSense?.ASC != 0x04) - break; - - if(decodedSense?.ASCQ != 0x01) + if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) break; Thread.Sleep(2000); @@ -218,10 +215,7 @@ public sealed partial class DeviceReport DecodedSense? decodedSense = Sense.Decode(senseBuffer); - if(decodedSense?.ASC != 0x04) - break; - - if(decodedSense?.ASCQ != 0x01) + if(decodedSense is not { ASC: 0x04, ASCQ: 0x01 }) break; } while(retries < 25); @@ -1618,10 +1612,7 @@ public sealed partial class DeviceReport DecodedSense? decoded = Sense.Decode(senseBuffer); - if(decoded?.ASC != 0x64) - break; - - if(decoded?.ASCQ != 0x00) + if(decoded is not { ASC: 0x64, ASCQ: 0x00 }) break; trackModeChange = true; diff --git a/Aaru.Core/Devices/Report/MMC.cs b/Aaru.Core/Devices/Report/MMC.cs index 032e676df..5b818de29 100644 --- a/Aaru.Core/Devices/Report/MMC.cs +++ b/Aaru.Core/Devices/Report/MMC.cs @@ -1874,9 +1874,7 @@ public sealed partial class DeviceReport { DecodedSense? decSense = Sense.Decode(senseBuffer); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { mediaTest.SupportsReadLong = true; diff --git a/Aaru.Core/Devices/Report/Scsi.cs b/Aaru.Core/Devices/Report/Scsi.cs index ed9acb518..0ab19f741 100644 --- a/Aaru.Core/Devices/Report/Scsi.cs +++ b/Aaru.Core/Devices/Report/Scsi.cs @@ -599,9 +599,7 @@ public sealed partial class DeviceReport { DecodedSense? decSense = Sense.Decode(senseBuffer); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { mediaTest.SupportsReadLong = true; @@ -631,9 +629,7 @@ public sealed partial class DeviceReport { DecodedSense? decSense = Sense.Decode(senseBuffer); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { mediaTest.SupportsReadLong16 = true; @@ -908,9 +904,7 @@ public sealed partial class DeviceReport { DecodedSense? decSense = Sense.Decode(senseBuffer); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { capabilities.SupportsReadLong = true; @@ -942,9 +936,7 @@ public sealed partial class DeviceReport capabilities.SupportsReadLong16 = true; DecodedSense? decSense = Sense.Decode(senseBuffer); - if(decSense?.SenseKey == SenseKeys.IllegalRequest && - decSense.Value.ASC == 0x24 && - decSense.Value.ASCQ == 0x00) + if(decSense is { SenseKey: SenseKeys.IllegalRequest, ASC: 0x24, ASCQ: 0x00 }) { capabilities.SupportsReadLong16 = true; diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index 6c3a2b48e..e3340add2 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -173,8 +173,7 @@ public static class ImageInfo AaruConsole.WriteLine("[bold]Media geometry:[/] [italic]{0} cylinders, {1} heads, {2} sectors per track[/]", imageFormat.Info.Cylinders, imageFormat.Info.Heads, imageFormat.Info.SectorsPerTrack); - if(imageFormat.Info.ReadableMediaTags != null && - imageFormat.Info.ReadableMediaTags.Count > 0) + if(imageFormat.Info.ReadableMediaTags is { Count: > 0 }) { AaruConsole.WriteLine("[bold]Contains {0} readable media tags:[/]", imageFormat.Info.ReadableMediaTags.Count); @@ -185,8 +184,7 @@ public static class ImageInfo AaruConsole.WriteLine(); } - if(imageFormat.Info.ReadableSectorTags != null && - imageFormat.Info.ReadableSectorTags.Count > 0) + if(imageFormat.Info.ReadableSectorTags is { Count: > 0 }) { AaruConsole.WriteLine("[bold]Contains {0} readable sector tags:[/]", imageFormat.Info.ReadableSectorTags.Count); @@ -805,8 +803,7 @@ public static class ImageInfo try { - if(opticalImage.Sessions != null && - opticalImage.Sessions.Count > 0) + if(opticalImage.Sessions is { Count: > 0 }) { var table = new Table { diff --git a/Aaru.Core/Media/Detection/MMC.cs b/Aaru.Core/Media/Detection/MMC.cs index d896c8d41..5015c2fc7 100644 --- a/Aaru.Core/Media/Detection/MMC.cs +++ b/Aaru.Core/Media/Detection/MMC.cs @@ -485,7 +485,7 @@ public static class MMC } foreach(FullTOC.TrackDataDescriptor track in - decodedToc.Value.TrackDescriptors.Where(t => t.POINT > 0 && t.POINT <= 0x99)) + decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99)) { if(track.TNO == 1 && ((TocControl)(track.CONTROL & 0x0D) == TocControl.DataTrack || @@ -553,8 +553,7 @@ public static class MMC } if(mediaType is MediaType.CD or MediaType.CDROM && hasDataTrack) - foreach(uint startAddress in decodedToc.Value.TrackDescriptors. - Where(t => t.POINT > 0 && t.POINT <= 0x99 && + foreach(uint startAddress in decodedToc.Value.TrackDescriptors.Where(t => t.POINT is > 0 and <= 0x99 && ((TocControl)(t.CONTROL & 0x0D) == TocControl.DataTrack || (TocControl)(t.CONTROL & 0x0D) == @@ -2327,8 +2326,7 @@ public static class MMC } } - if(blurayDi != null && - blurayDi?.Units?.Length > 0 && + if(blurayDi is { Units.Length: > 0 } && blurayDi?.Units[0].DiscTypeIdentifier != null) { string blurayType = StringHandlers.CToString(blurayDi?.Units[0].DiscTypeIdentifier); diff --git a/Aaru.Decoders b/Aaru.Decoders index e72768392..83612d608 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit e72768392972d93a0f31a4ae740fce0c34a96a69 +Subproject commit 83612d6084e3b207d4789e98a8940673975e796e diff --git a/Aaru.Filesystems/FAT/BPB.cs b/Aaru.Filesystems/FAT/BPB.cs index 48ff09c9d..a1e9e5938 100644 --- a/Aaru.Filesystems/FAT/BPB.cs +++ b/Aaru.Filesystems/FAT/BPB.cs @@ -312,10 +312,8 @@ public sealed partial class FAT useDos32Bpb = true; minBootNearJump = 0x1E; } - else if(dos30Bpb.sptrk > 0 && - dos30Bpb.sptrk < 64 && - dos30Bpb.heads > 0 && - dos30Bpb.heads < 256) + else if(dos30Bpb.sptrk is > 0 and < 64 && + dos30Bpb.heads is > 0 and < 256) if(atariBpb.jump[0] == 0x60 || atariBpb.jump[0] == 0xE9 && atariBpb.jump[1] == 0x00 && Encoding.ASCII.GetString(dos33Bpb.oem_name) != "NEXT ") diff --git a/Aaru.Filesystems/FAT/File.cs b/Aaru.Filesystems/FAT/File.cs index d9403e30e..5712f3320 100644 --- a/Aaru.Filesystems/FAT/File.cs +++ b/Aaru.Filesystems/FAT/File.cs @@ -268,8 +268,7 @@ public sealed partial class FAT nextEntry = (int)(nextCluster % _fatEntriesPerSector); } else if(_fat16) - while(nextCluster > 0 && - nextCluster <= FAT16_RESERVED) + while(nextCluster is > 0 and <= FAT16_RESERVED) { if(nextCluster > _fatEntries.Length) return null; @@ -278,8 +277,7 @@ public sealed partial class FAT nextCluster = _fatEntries[nextCluster]; } else - while(nextCluster > 0 && - nextCluster <= FAT12_RESERVED) + while(nextCluster is > 0 and <= FAT12_RESERVED) { if(nextCluster > _fatEntries.Length) return null; diff --git a/Aaru.Filesystems/FAT/Info.cs b/Aaru.Filesystems/FAT/Info.cs index 2525ea1cf..bea4446f1 100644 --- a/Aaru.Filesystems/FAT/Info.cs +++ b/Aaru.Filesystems/FAT/Info.cs @@ -625,8 +625,7 @@ public sealed partial class FAT XmlFsType.FreeClustersSpecified = true; } - if(fsInfo.last_cluster > 2 && - fsInfo.last_cluster < 0xFFFFFFFF) + if(fsInfo.last_cluster is > 2 and < 0xFFFFFFFF) sb.AppendFormat("Last allocated cluster {0}", fsInfo.last_cluster).AppendLine(); } } @@ -930,10 +929,8 @@ public sealed partial class FAT sb.AppendFormat("{0} sectors per FAT.", fakeBpb.spfat).AppendLine(); - if(fakeBpb.sptrk > 0 && - fakeBpb.sptrk < 64 && - fakeBpb.heads > 0 && - fakeBpb.heads < 256) + if(fakeBpb.sptrk is > 0 and < 64 && + fakeBpb.heads is > 0 and < 256) { sb.AppendFormat("{0} sectors per track.", fakeBpb.sptrk).AppendLine(); sb.AppendFormat("{0} heads.", fakeBpb.heads).AppendLine(); diff --git a/Aaru.Filesystems/FATX/File.cs b/Aaru.Filesystems/FATX/File.cs index b8e29ded3..5a0efe92b 100644 --- a/Aaru.Filesystems/FATX/File.cs +++ b/Aaru.Filesystems/FATX/File.cs @@ -239,8 +239,7 @@ public sealed partial class XboxFatPlugin nextCluster = _fat32[nextCluster]; } else - while(nextCluster > 0 && - nextCluster <= FAT16_RESERVED) + while(nextCluster is > 0 and <= FAT16_RESERVED) { clusters.Add(nextCluster); nextCluster = _fat16[nextCluster]; diff --git a/Aaru.Filesystems/HPOFS/Info.cs b/Aaru.Filesystems/HPOFS/Info.cs index 7c795dd1d..cd4c5d574 100644 --- a/Aaru.Filesystems/HPOFS/Info.cs +++ b/Aaru.Filesystems/HPOFS/Info.cs @@ -201,7 +201,7 @@ public sealed partial class HPOFS sb.AppendFormat("Volume created on {0}", DateHandlers.DosToDateTime(mib.creationDate, mib.creationTime)). AppendLine(); - sb.AppendFormat("Volume uses {0} codepage {1}", mib.codepageType > 0 && mib.codepageType < 3 + sb.AppendFormat("Volume uses {0} codepage {1}", mib.codepageType is > 0 and < 3 ? mib.codepageType == 2 ? "EBCDIC" : "ASCII" : "Unknown", mib.codepage).AppendLine(); diff --git a/Aaru.Filters/ZZZNoFilter.cs b/Aaru.Filters/ZZZNoFilter.cs index 6b8cef7d9..297fc1bfa 100644 --- a/Aaru.Filters/ZZZNoFilter.cs +++ b/Aaru.Filters/ZZZNoFilter.cs @@ -74,10 +74,10 @@ public sealed class ZZZNoFilter : IFilter public bool HasResourceFork => false; /// - public bool Identify(byte[] buffer) => buffer != null && buffer.Length > 0; + public bool Identify(byte[] buffer) => buffer is { Length: > 0 }; /// - public bool Identify(Stream stream) => stream != null && stream.Length > 0; + public bool Identify(Stream stream) => stream is { Length: > 0 }; /// public bool Identify(string path) => File.Exists(path); diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 50585e8e2..8ba1ac31f 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -188,13 +188,11 @@ public sealed class ImageInfoViewModel : ViewModelBase MediaGeometryText = $"Media geometry: {imageFormat.Info.Cylinders} cylinders, {imageFormat.Info.Heads} heads, {imageFormat.Info.SectorsPerTrack} sectors per track"; - if(imageFormat.Info.ReadableMediaTags != null && - imageFormat.Info.ReadableMediaTags.Count > 0) + if(imageFormat.Info.ReadableMediaTags is { Count: > 0 }) foreach(MediaTagType tag in imageFormat.Info.ReadableMediaTags.OrderBy(t => t)) MediaTagsList.Add(tag.ToString()); - if(imageFormat.Info.ReadableSectorTags != null && - imageFormat.Info.ReadableSectorTags.Count > 0) + if(imageFormat.Info.ReadableSectorTags is { Count: > 0 }) foreach(SectorTagType tag in imageFormat.Info.ReadableSectorTags.OrderBy(t => t)) SectorTagsList.Add(tag.ToString()); @@ -624,8 +622,7 @@ public sealed class ImageInfoViewModel : ViewModelBase { try { - if(opticalMediaImage.Sessions != null && - opticalMediaImage.Sessions.Count > 0) + if(opticalMediaImage.Sessions is { Count: > 0 }) foreach(Session session in opticalMediaImage.Sessions) Sessions.Add(session); } @@ -636,8 +633,7 @@ public sealed class ImageInfoViewModel : ViewModelBase try { - if(opticalMediaImage.Tracks != null && - opticalMediaImage.Tracks.Count > 0) + if(opticalMediaImage.Tracks is { Count: > 0 }) foreach(Track track in opticalMediaImage.Tracks) Tracks.Add(track); } diff --git a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs index db92fbc19..3eb5f542c 100644 --- a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs @@ -99,8 +99,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase if(!string.IsNullOrEmpty(mcn)) McnText = mcn; - if(isrcs != null && - isrcs.Count > 0) + if(isrcs is { Count: > 0 }) foreach(KeyValuePair isrc in isrcs) IsrcList.Add(new IsrcModel { diff --git a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs index cbc0c8179..b43110586 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs @@ -37,7 +37,6 @@ using System.Collections.ObjectModel; using System.Globalization; using System.Reactive; using System.Threading; -using System.Threading.Tasks; using Aaru.CommonTypes.Interfaces; using Aaru.Console; using Aaru.Core; @@ -302,9 +301,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase StopVisible = false; ProgressVisible = true; - if(WholeDiscChecked && - _inputFormat is IOpticalMediaImage opticalFormat && - opticalFormat.Sessions?.Count > 1) + if(WholeDiscChecked && _inputFormat is IOpticalMediaImage { Sessions.Count: > 1 }) { AaruConsole.ErrorWriteLine("Calculating disc entropy of multisession images is not yet implemented."); WholeDiscChecked = false; diff --git a/Aaru.Helpers b/Aaru.Helpers index 98f08919d..7fbeaebfd 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit 98f08919d6b06ce0240843ddd7c984fcfd44711c +Subproject commit 7fbeaebfd3564d26268fecb9f85d0a41bf6ebf65 diff --git a/Aaru.Images/AaruFormat/Write.cs b/Aaru.Images/AaruFormat/Write.cs index fab63768b..3886ad42a 100644 --- a/Aaru.Images/AaruFormat/Write.cs +++ b/Aaru.Images/AaruFormat/Write.cs @@ -3127,7 +3127,7 @@ public sealed partial class AaruFormat // Write the sector prefix, suffix and subchannels if present switch(_imageInfo.XmlMediaType) { - case XmlMediaType.OpticalDisc when Tracks != null && Tracks.Count > 0: + case XmlMediaType.OpticalDisc when Tracks is { Count: > 0 }: DateTime startCompress; DateTime endCompress; diff --git a/Aaru.Images/Alcohol120/Read.cs b/Aaru.Images/Alcohol120/Read.cs index bff9fbd34..0457af4f7 100644 --- a/Aaru.Images/Alcohol120/Read.cs +++ b/Aaru.Images/Alcohol120/Read.cs @@ -154,9 +154,8 @@ public sealed partial class Alcohol120 oldIncorrectImage = true; // Solve our own mistake here, sorry, but anyway seems Alcohol doesn't support DDCD - if(track.zero > 0 && - track.point >= 1 && - track.point <= 99) + if(track.zero > 0 && + track.point is >= 1 and <= 99) { track.pmin += (byte)(track.zero * 60); track.zero = 0; diff --git a/Aaru.Images/Alcohol120/Write.cs b/Aaru.Images/Alcohol120/Write.cs index be4d3686e..e5bd2eac9 100644 --- a/Aaru.Images/Alcohol120/Write.cs +++ b/Aaru.Images/Alcohol120/Write.cs @@ -625,8 +625,8 @@ public sealed partial class Alcohol120 allBlocks = (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i) ?? _writingTracks.Count(t => t.Session == i) + 3), nonTrackBlocks = - (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i && t.POINT >= 0xA0 && - t.POINT <= 0xAF) ?? 3), + (byte)(decodedToc?.TrackDescriptors.Count(t => t.SessionNumber == i && + t.POINT is >= 0xA0 and <= 0xAF) ?? 3), firstTrack = (ushort)firstTrack.Sequence, lastTrack = (ushort)lastTrack.Sequence, trackOffset = (uint)currentTrackOffset @@ -646,11 +646,11 @@ public sealed partial class Alcohol120 (byte minute, byte second, byte frame) leadinPmsf = LbaToMsf(lastTrack.EndSector + 1); - if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT >= 0xA0 && t.POINT <= 0xAF) == + if(decodedToc?.TrackDescriptors.Any(t => t.SessionNumber == i && t.POINT is >= 0xA0 and <= 0xAF) == true) foreach(FullTOC.TrackDataDescriptor tocTrk in - decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && t.POINT >= 0xA0 && - t.POINT <= 0xAF)) + decodedToc.Value.TrackDescriptors.Where(t => t.SessionNumber == i && + t.POINT is >= 0xA0 and <= 0xAF)) { thisSessionTracks.Add(tocTrk.POINT, new Track { diff --git a/Aaru.Images/CDRWin/Read.cs b/Aaru.Images/CDRWin/Read.cs index 3020e454b..df9c6c7b9 100644 --- a/Aaru.Images/CDRWin/Read.cs +++ b/Aaru.Images/CDRWin/Read.cs @@ -1550,9 +1550,9 @@ public sealed partial class CdrWin var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39 || mediaTypeAsInt is 112 or 113 || - mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152 || mediaTypeAsInt is 154 or 155 || - mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179 || mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749; + _isCd = mediaTypeAsInt is >= 10 and <= 39 || mediaTypeAsInt is 112 or 113 || + mediaTypeAsInt is >= 150 and <= 152 || mediaTypeAsInt is 154 or 155 || + mediaTypeAsInt is >= 171 and <= 179 || mediaTypeAsInt is >= 740 and <= 749; if(currentSession > 1 && leadouts.Count == 0 && diff --git a/Aaru.Images/CDRWin/Write.cs b/Aaru.Images/CDRWin/Write.cs index 27096d9d7..5eba9ed7a 100644 --- a/Aaru.Images/CDRWin/Write.cs +++ b/Aaru.Images/CDRWin/Write.cs @@ -107,9 +107,9 @@ public sealed partial class CdrWin var mediaTypeAsInt = (int)_discImage.MediaType; - _isCd = mediaTypeAsInt >= 10 && mediaTypeAsInt <= 39 || mediaTypeAsInt is 112 or 113 || - mediaTypeAsInt >= 150 && mediaTypeAsInt <= 152 || mediaTypeAsInt is 154 or 155 || - mediaTypeAsInt >= 171 && mediaTypeAsInt <= 179 || mediaTypeAsInt >= 740 && mediaTypeAsInt <= 749; + _isCd = mediaTypeAsInt is >= 10 and <= 39 || mediaTypeAsInt is 112 or 113 || + mediaTypeAsInt is >= 150 and <= 152 || mediaTypeAsInt is 154 or 155 || + mediaTypeAsInt is >= 171 and <= 179 || mediaTypeAsInt is >= 740 and <= 749; if(_isCd) { diff --git a/Aaru.Images/CloneCD/Read.cs b/Aaru.Images/CloneCD/Read.cs index c82036bee..de71abcf0 100644 --- a/Aaru.Images/CloneCD/Read.cs +++ b/Aaru.Images/CloneCD/Read.cs @@ -457,8 +457,7 @@ public sealed partial class CloneCd break; default: - if(descriptor.POINT >= 0x01 && - descriptor.POINT <= 0x63) + if(descriptor.POINT is >= 0x01 and <= 0x63) { if(!firstTrackInSession) { diff --git a/Aaru.Images/NDIF/Read.cs b/Aaru.Images/NDIF/Read.cs index 1e65b0366..3a5df3f82 100644 --- a/Aaru.Images/NDIF/Read.cs +++ b/Aaru.Images/NDIF/Read.cs @@ -159,9 +159,9 @@ public sealed partial class Ndif } // TODO: Handle compressed chunks - if(bChnk.type > CHUNK_TYPE_COPY && bChnk.type < CHUNK_TYPE_KENCODE || - bChnk.type > CHUNK_TYPE_ADC && bChnk.type < CHUNK_TYPE_STUFFIT || - bChnk.type > CHUNK_TYPE_STUFFIT && bChnk.type < CHUNK_TYPE_END || + if(bChnk.type is > CHUNK_TYPE_COPY and < CHUNK_TYPE_KENCODE || + bChnk.type is > CHUNK_TYPE_ADC and < CHUNK_TYPE_STUFFIT || + bChnk.type is > CHUNK_TYPE_STUFFIT and < CHUNK_TYPE_END || bChnk.type == 1) { AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found"); diff --git a/Aaru.Images/UDIF/Read.cs b/Aaru.Images/UDIF/Read.cs index 671dd1710..31f5e6ee3 100644 --- a/Aaru.Images/UDIF/Read.cs +++ b/Aaru.Images/UDIF/Read.cs @@ -414,8 +414,8 @@ public sealed partial class Udif return ErrorNumber.NotImplemented; } - if(bChnk.type > CHUNK_TYPE_NOCOPY && bChnk.type < CHUNK_TYPE_COMMNT || - bChnk.type > CHUNK_TYPE_LZMA && bChnk.type < CHUNK_TYPE_END) + if(bChnk.type is > CHUNK_TYPE_NOCOPY and < CHUNK_TYPE_COMMNT || + bChnk.type is > CHUNK_TYPE_LZMA and < CHUNK_TYPE_END) { AaruConsole.ErrorWriteLine($"Unsupported chunk type 0x{bChnk.type:X8} found");