diff --git a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index fa8b054c1..381d686ff 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -190,9 +190,15 @@ public sealed class MainWindowViewModel : ViewModelBase set => this.RaiseAndSetIfChanged(ref _devicesSupported, value); } - public bool NativeMenuSupported => - NativeMenu.GetIsNativeMenuExported((Application.Current?.ApplicationLifetime as - IClassicDesktopStyleApplicationLifetime)?.MainWindow); + public bool NativeMenuSupported + { + get + { + Window mainWindow = (Application.Current?.ApplicationLifetime as + IClassicDesktopStyleApplicationLifetime)?.MainWindow; + return mainWindow is not null && NativeMenu.GetIsNativeMenuExported(mainWindow); + } + } [NotNull] public string Greeting => UI.Welcome_to_Aaru; diff --git a/Aaru.Images/UDIF/Read.cs b/Aaru.Images/UDIF/Read.cs index aa5461831..e88f94573 100644 --- a/Aaru.Images/UDIF/Read.cs +++ b/Aaru.Images/UDIF/Read.cs @@ -571,6 +571,11 @@ public sealed partial class Udif } buffer = new byte[SECTOR_SIZE]; + + // Shall not happen + if(data is null) + return ErrorNumber.InvalidArgument; + Array.Copy(data, relOff, buffer, 0, SECTOR_SIZE); if(_sectorCache.Count >= MAX_CACHED_SECTORS) diff --git a/Aaru/Commands/Archive/Info.cs b/Aaru/Commands/Archive/Info.cs index 2de902881..1fb3f6649 100644 --- a/Aaru/Commands/Archive/Info.cs +++ b/Aaru/Commands/Archive/Info.cs @@ -31,6 +31,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; @@ -54,7 +55,7 @@ sealed class ArchiveInfoCommand : Command Name = "archive-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string imagePath) diff --git a/Aaru/Commands/Database/Statistics.cs b/Aaru/Commands/Database/Statistics.cs index c7c716ed9..ad411e4bc 100644 --- a/Aaru/Commands/Database/Statistics.cs +++ b/Aaru/Commands/Database/Statistics.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine.NamingConventionBinder; using System.Linq; using Aaru.CommonTypes.Enums; @@ -45,7 +46,7 @@ namespace Aaru.Commands.Database; sealed class StatisticsCommand : Command { public StatisticsCommand() : base("stats", UI.Database_Stats_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool debug, bool verbose) { diff --git a/Aaru/Commands/Device/DeviceReport.cs b/Aaru/Commands/Device/DeviceReport.cs index d0290e67d..1af005e0e 100644 --- a/Aaru/Commands/Device/DeviceReport.cs +++ b/Aaru/Commands/Device/DeviceReport.cs @@ -72,7 +72,7 @@ sealed class DeviceReportCommand : Command Add(new Option(new[] { "--trap-disc", "-t" }, () => false, UI.Device_report_using_trap_disc)); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string devicePath, bool trapDisc) @@ -274,7 +274,7 @@ sealed class DeviceReportCommand : Command } else if(!removable && report.ATA.IdentifyDevice?.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit. - Removable) == true) + Removable) == true) removable = AnsiConsole.Confirm($"[italic]{UI.Is_the_media_removable}[/]"); if(removable) diff --git a/Aaru/Commands/Device/Info.cs b/Aaru/Commands/Device/Info.cs index 06e1234f3..a37cc18ea 100644 --- a/Aaru/Commands/Device/Info.cs +++ b/Aaru/Commands/Device/Info.cs @@ -77,7 +77,7 @@ sealed class DeviceInfoCommand : Command Name = "device-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string devicePath, string outputPrefix) diff --git a/Aaru/Commands/Device/List.cs b/Aaru/Commands/Device/List.cs index 70bc578a6..88c5f43f3 100644 --- a/Aaru/Commands/Device/List.cs +++ b/Aaru/Commands/Device/List.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.Linq; @@ -56,7 +57,7 @@ sealed class ListDevicesCommand : Command Name = "aaru-remote-host" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, [CanBeNull] string aaruRemoteHost) diff --git a/Aaru/Commands/Filesystem/ExtractFiles.cs b/Aaru/Commands/Filesystem/ExtractFiles.cs index ee2186c01..62a6539c2 100644 --- a/Aaru/Commands/Filesystem/ExtractFiles.cs +++ b/Aaru/Commands/Filesystem/ExtractFiles.cs @@ -80,7 +80,7 @@ sealed class ExtractFilesCommand : Command Name = "output-dir" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string encoding, bool xattrs, string imagePath, diff --git a/Aaru/Commands/Filesystem/Ls.cs b/Aaru/Commands/Filesystem/Ls.cs index 03cd7fcb2..a0c056a63 100644 --- a/Aaru/Commands/Filesystem/Ls.cs +++ b/Aaru/Commands/Filesystem/Ls.cs @@ -72,7 +72,7 @@ sealed class LsCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string encoding, string imagePath, bool longFormat, diff --git a/Aaru/Commands/Filesystem/Options.cs b/Aaru/Commands/Filesystem/Options.cs index e863136db..26438088c 100644 --- a/Aaru/Commands/Filesystem/Options.cs +++ b/Aaru/Commands/Filesystem/Options.cs @@ -50,7 +50,7 @@ sealed class ListOptionsCommand : Command const string MODULE_NAME = "List-Options command"; public ListOptionsCommand() : base("options", UI.Filesystem_Options_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool debug, bool verbose) { diff --git a/Aaru/Commands/Formats.cs b/Aaru/Commands/Formats.cs index f3100d3df..0fc0d0ac4 100644 --- a/Aaru/Commands/Formats.cs +++ b/Aaru/Commands/Formats.cs @@ -50,7 +50,7 @@ sealed class FormatsCommand : Command const string MODULE_NAME = "Formats command"; public FormatsCommand() : base("formats", UI.List_Formats_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool verbose, bool debug) { diff --git a/Aaru/Commands/Image/Checksum.cs b/Aaru/Commands/Image/Checksum.cs index 5a09ae13b..7e3381aae 100644 --- a/Aaru/Commands/Image/Checksum.cs +++ b/Aaru/Commands/Image/Checksum.cs @@ -89,7 +89,7 @@ sealed class ChecksumCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, bool adler32, bool crc16, bool crc32, bool crc64, diff --git a/Aaru/Commands/Image/Compare.cs b/Aaru/Commands/Image/Compare.cs index d7444d1d3..1ed96202a 100644 --- a/Aaru/Commands/Image/Compare.cs +++ b/Aaru/Commands/Image/Compare.cs @@ -71,7 +71,7 @@ sealed class CompareCommand : Command Name = "image-path2" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string imagePath1, string imagePath2) diff --git a/Aaru/Commands/Image/Convert.cs b/Aaru/Commands/Image/Convert.cs index 92d0985f0..4c0c5d7b8 100644 --- a/Aaru/Commands/Image/Convert.cs +++ b/Aaru/Commands/Image/Convert.cs @@ -138,7 +138,7 @@ sealed class ConvertImageCommand : Command Name = "output-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool verbose, bool debug, string cicmXml, string comments, int count, string creator, @@ -564,7 +564,7 @@ sealed class ConvertImageCommand : Command } foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag => - !outputFormat.SupportedMediaTags.Contains(mediaTag) && !force)) + !outputFormat.SupportedMediaTags.Contains(mediaTag) && !force)) { AaruConsole.ErrorWriteLine(UI.Converting_image_will_lose_media_tag_0, mediaTag); AaruConsole.ErrorWriteLine(UI.If_you_dont_care_use_force_option); @@ -575,7 +575,7 @@ sealed class ConvertImageCommand : Command bool useLong = inputFormat.Info.ReadableSectorTags.Count != 0; foreach(SectorTagType sectorTag in inputFormat.Info.ReadableSectorTags.Where(sectorTag => - !outputFormat.SupportedSectorTags.Contains(sectorTag))) + !outputFormat.SupportedSectorTags.Contains(sectorTag))) { if(force) { @@ -624,7 +624,7 @@ sealed class ConvertImageCommand : Command } if((outputFormat as IWritableOpticalImage)?.OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreSessions) != true && + CanStoreSessions) != true && (inputFormat as IOpticalMediaImage)?.Sessions?.Count > 1) { // TODO: Disabled until 6.0 @@ -639,7 +639,7 @@ sealed class ConvertImageCommand : Command } if((outputFormat as IWritableOpticalImage)?.OpticalCapabilities.HasFlag(OpticalImageCapabilities. - CanStoreHiddenTracks) != true && + CanStoreHiddenTracks) != true && (inputFormat as IOpticalMediaImage)?.Tracks?.Any(t => t.Sequence == 0) == true) { // TODO: Disabled until 6.0 @@ -707,7 +707,7 @@ sealed class ConvertImageCommand : Command List dumpHardware = inputFormat.DumpHardware; foreach(MediaTagType mediaTag in inputFormat.Info.ReadableMediaTags.Where(mediaTag => - !force || outputFormat.SupportedMediaTags.Contains(mediaTag))) + !force || outputFormat.SupportedMediaTags.Contains(mediaTag))) { ErrorNumber errorNumber = ErrorNumber.NoError; @@ -908,7 +908,7 @@ sealed class ConvertImageCommand : Command Core.Filesystems. Identify(inputOptical, out List - idPlugins, p); + idPlugins, p); return idPlugins. Contains("iso9660 filesystem"); @@ -969,7 +969,7 @@ sealed class ConvertImageCommand : Command Core.Filesystems. Identify(inputOptical, out List - idPlugins, p); + idPlugins, p); return idPlugins. Contains("iso9660 filesystem"); diff --git a/Aaru/Commands/Image/CreateSidecar.cs b/Aaru/Commands/Image/CreateSidecar.cs index 3a5f87369..12a58000c 100644 --- a/Aaru/Commands/Image/CreateSidecar.cs +++ b/Aaru/Commands/Image/CreateSidecar.cs @@ -72,7 +72,7 @@ sealed class CreateSidecarCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, uint blockSize, [CanBeNull] string encodingName, diff --git a/Aaru/Commands/Image/Decode.cs b/Aaru/Commands/Image/Decode.cs index d279791e1..abaa36974 100644 --- a/Aaru/Commands/Image/Decode.cs +++ b/Aaru/Commands/Image/Decode.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.Globalization; @@ -68,7 +69,7 @@ sealed class DecodeCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags, diff --git a/Aaru/Commands/Image/Entropy.cs b/Aaru/Commands/Image/Entropy.cs index 054dcddc8..41cd82f42 100644 --- a/Aaru/Commands/Image/Entropy.cs +++ b/Aaru/Commands/Image/Entropy.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes; @@ -65,7 +66,7 @@ sealed class EntropyCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, bool duplicatedSectors, string imagePath, bool separatedTracks, diff --git a/Aaru/Commands/Image/Info.cs b/Aaru/Commands/Image/Info.cs index 02b984c77..b77d557f3 100644 --- a/Aaru/Commands/Image/Info.cs +++ b/Aaru/Commands/Image/Info.cs @@ -56,7 +56,7 @@ sealed class ImageInfoCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string imagePath) diff --git a/Aaru/Commands/Image/Options.cs b/Aaru/Commands/Image/Options.cs index 916da4320..774d24e22 100644 --- a/Aaru/Commands/Image/Options.cs +++ b/Aaru/Commands/Image/Options.cs @@ -50,7 +50,7 @@ sealed class ListOptionsCommand : Command const string MODULE_NAME = "List-Options command"; public ListOptionsCommand() : base("options", UI.Image_Options_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool debug, bool verbose) { diff --git a/Aaru/Commands/Image/Print.cs b/Aaru/Commands/Image/Print.cs index e4875454d..acb1cbf58 100644 --- a/Aaru/Commands/Image/Print.cs +++ b/Aaru/Commands/Image/Print.cs @@ -65,7 +65,7 @@ sealed class PrintHexCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string imagePath, ulong length, bool longSectors, ulong start, diff --git a/Aaru/Commands/Image/Verify.cs b/Aaru/Commands/Image/Verify.cs index a046ac8f5..4feb81449 100644 --- a/Aaru/Commands/Image/Verify.cs +++ b/Aaru/Commands/Image/Verify.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; using System.CommandLine; using System.CommandLine.NamingConventionBinder; @@ -70,7 +71,7 @@ sealed class VerifyCommand : Command Name = "image-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string imagePath, bool verifyDisc, bool verifySectors, diff --git a/Aaru/Commands/ListEncodings.cs b/Aaru/Commands/ListEncodings.cs index 8892688be..0b6a19d2f 100644 --- a/Aaru/Commands/ListEncodings.cs +++ b/Aaru/Commands/ListEncodings.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using System.Linq; @@ -47,7 +48,7 @@ sealed class ListEncodingsCommand : Command const string MODULE_NAME = "List-Encodings command"; public ListEncodingsCommand() : base("list-encodings", UI.List_Encodings_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool debug, bool verbose) { diff --git a/Aaru/Commands/ListNamespaces.cs b/Aaru/Commands/ListNamespaces.cs index 4aa26f095..3bed6e342 100644 --- a/Aaru/Commands/ListNamespaces.cs +++ b/Aaru/Commands/ListNamespaces.cs @@ -49,7 +49,7 @@ sealed class ListNamespacesCommand : Command const string MODULE_NAME = "List-Namespaces command"; public ListNamespacesCommand() : base("list-namespaces", UI.List_Namespaces_Command_Description) => - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); public static int Invoke(bool debug, bool verbose) { diff --git a/Aaru/Commands/Media/Dump.cs b/Aaru/Commands/Media/Dump.cs index e4a727d7f..28a762178 100644 --- a/Aaru/Commands/Media/Dump.cs +++ b/Aaru/Commands/Media/Dump.cs @@ -156,7 +156,7 @@ sealed class DumpMediaCommand : Command Add(new Option(new[] { "--aaru-metadata", "-m" }, () => null, "Take metadata from existing Aaru Metadata sidecar.")); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string cicmXml, string devicePath, bool resume, string encoding, diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs index 75354f861..3210f7539 100644 --- a/Aaru/Commands/Media/Info.cs +++ b/Aaru/Commands/Media/Info.cs @@ -78,7 +78,7 @@ sealed class MediaInfoCommand : Command Name = "device-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string devicePath, string outputPrefix) diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs index 61459ef94..72099c645 100644 --- a/Aaru/Commands/Media/Scan.cs +++ b/Aaru/Commands/Media/Scan.cs @@ -30,6 +30,7 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.CommandLine; using System.CommandLine.NamingConventionBinder; using Aaru.CommonTypes.Enums; @@ -66,7 +67,7 @@ sealed class MediaScanCommand : Command Name = "device-path" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string devicePath, string ibgLog, string mhddLog, diff --git a/Aaru/Commands/Remote.cs b/Aaru/Commands/Remote.cs index d6ca9e2ee..e4e88cbbf 100644 --- a/Aaru/Commands/Remote.cs +++ b/Aaru/Commands/Remote.cs @@ -57,7 +57,7 @@ sealed class RemoteCommand : Command Name = "host" }); - Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); + Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)) ?? throw new NullReferenceException()); } public static int Invoke(bool debug, bool verbose, string host)