diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 2b5e6aedd..97eae54ee 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -1160,7 +1160,7 @@ namespace Ryujinx.UI.App.Common return _ncaIcon; } - return Path.GetExtension(applicationPath).ToLower() switch + return Path.GetExtension(applicationPath)?.ToLower() switch { ".nsp" => _nspIcon, ".pfs0" => _nspIcon, @@ -1177,7 +1177,7 @@ namespace Ryujinx.UI.App.Common // Look for icon only if applicationPath is not a directory if (!Directory.Exists(applicationPath)) { - string extension = Path.GetExtension(applicationPath).ToLower(); + string extension = Path.GetExtension(applicationPath)?.ToLower(); using FileStream file = new(applicationPath, FileMode.Open, FileAccess.Read); @@ -1233,7 +1233,7 @@ namespace Ryujinx.UI.App.Common { using var icon = new UniqueRef(); - controlFs.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + controlFs?.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure(); using MemoryStream stream = new(); @@ -1251,7 +1251,7 @@ namespace Ryujinx.UI.App.Common using var icon = new UniqueRef(); - controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); + controlFs?.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); using MemoryStream stream = new(); icon.Get.AsStream().CopyTo(stream); @@ -1435,7 +1435,10 @@ namespace Ryujinx.UI.App.Common { return new Nca(_virtualFileSystem.KeySet, ncaStorage); } - catch (Exception) { } + catch (Exception) + { + // ignored + } return null; } diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 08302d7fb..faab95996 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -666,7 +666,7 @@ namespace Ryujinx.Ava SystemVersion firmwareVersion = ContentManager.GetCurrentFirmwareVersion(); - if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { if (!SetupValidator.CanStartApplication(ContentManager, ApplicationPath, out UserError userError)) { @@ -888,7 +888,7 @@ namespace Ryujinx.Ava { renderer = new VulkanRenderer( Vk.GetApi(), - (RendererHost.EmbeddedWindow as EmbeddedWindowVulkan).CreateSurface, + ((EmbeddedWindowVulkan)RendererHost.EmbeddedWindow).CreateSurface, VulkanHelper.GetRequiredInstanceExtensions, ConfigurationState.Instance.Graphics.PreferredGpu.Value); } @@ -1053,7 +1053,7 @@ namespace Ryujinx.Ava Width = (int)RendererHost.Bounds.Width; Height = (int)RendererHost.Bounds.Height; - _renderer.Window.SetSize((int)(Width * _topLevel.RenderScaling), (int)(Height * _topLevel.RenderScaling)); + _renderer?.Window?.SetSize((int)(Width * _topLevel.RenderScaling), (int)(Height * _topLevel.RenderScaling)); _chrono.Start(); @@ -1296,7 +1296,7 @@ namespace Ryujinx.Ava _viewModel.Volume = Device.GetVolume(); break; case KeyboardHotkeyState.None: - (_keyboardInterface as AvaloniaKeyboard).Clear(); + (_keyboardInterface as AvaloniaKeyboard)?.Clear(); break; } } @@ -1315,7 +1315,7 @@ namespace Ryujinx.Ava if (_viewModel.IsActive && !ConfigurationState.Instance.Hid.EnableMouse.Value) { - hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as AvaloniaMouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat()); + hasTouch = TouchScreenManager.Update(true, ((AvaloniaMouseDriver)_inputManager.MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat()); } if (!hasTouch) diff --git a/src/Ryujinx/UI/ViewModels/XCITrimmerViewModel.cs b/src/Ryujinx/UI/ViewModels/XCITrimmerViewModel.cs index 43d3c631c..fbd491e07 100644 --- a/src/Ryujinx/UI/ViewModels/XCITrimmerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/XCITrimmerViewModel.cs @@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers; using Ryujinx.Common.Utilities; using Ryujinx.UI.App.Common; using Ryujinx.UI.Common.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -264,7 +265,7 @@ namespace Ryujinx.Ava.UI.ViewModels switch (_viewModel.SortingField) { case SortField.Name: - result = x.Name.CompareTo(y.Name); + result = String.Compare(x?.Name, y?.Name, StringComparison.Ordinal); break; case SortField.Saved: result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB); @@ -275,7 +276,7 @@ namespace Ryujinx.Ava.UI.ViewModels result = -result; if (result == 0) - result = x.Path.CompareTo(y.Path); + result = String.Compare(x?.Path, y?.Path, StringComparison.Ordinal); return result; }