diff --git a/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs b/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs index dbfb8b933..07ded7edd 100644 --- a/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs +++ b/src/Ryujinx.HLE.Generators/IpcServiceGenerator.cs @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.Generators var type = constructors.Where(x => x.ParameterList.Parameters.Count == 2).FirstOrDefault().ParameterList.Parameters[1].Type; var model = context.Compilation.GetSemanticModel(type.SyntaxTree); var typeSymbol = model.GetSymbolInfo(type).Symbol as INamedTypeSymbol; - var fullName = typeSymbol.ToString(); + var fullName = typeSymbol?.ToString(); generator.EnterScope("if (parameter != null)"); generator.AppendLine($"return new {GetFullName(className, context)}(context, ({fullName})parameter);"); generator.LeaveScope(); @@ -67,7 +67,7 @@ namespace Ryujinx.HLE.Generators { var typeSymbol = context.Compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode); - return typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + return typeSymbol?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); } public void Initialize(GeneratorInitializationContext context) diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs index 3b8840a3d..3fbcd20b8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs @@ -124,7 +124,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv { targetPrevAddress = InvalidAddress; } - node = node.Previous; + node = node?.Previous; _tree.Remove(prevAddress); _list.Remove(_dictionary[prevAddress]); _dictionary.Remove(prevAddress); diff --git a/src/Ryujinx.Headless.SDL2/WindowBase.cs b/src/Ryujinx.Headless.SDL2/WindowBase.cs index 3ac001dea..6fb937c51 100644 --- a/src/Ryujinx.Headless.SDL2/WindowBase.cs +++ b/src/Ryujinx.Headless.SDL2/WindowBase.cs @@ -418,7 +418,7 @@ namespace Ryujinx.Headless.SDL2 // Get screen touch position if (!_enableMouse) { - hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as SDL2MouseDriver).IsButtonPressed(MouseButton.Button1), _aspectRatio.ToFloat()); + hasTouch = TouchScreenManager.Update(true, ((SDL2MouseDriver)_inputManager.MouseDriver).IsButtonPressed(MouseButton.Button1), _aspectRatio.ToFloat()); } if (!hasTouch) diff --git a/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs b/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs index 3b408e555..272d934de 100644 --- a/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs +++ b/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs @@ -210,7 +210,7 @@ namespace Ryujinx.Horizon.Kernel.Generators { string name = methodParameter.Identifier.Text; string argName = GetPrefixedArgName(name); - string typeName = methodParameter.Type.ToString(); + string typeName = methodParameter.Type?.ToString(); string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type); if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword)) @@ -329,7 +329,7 @@ namespace Ryujinx.Horizon.Kernel.Generators { string name = methodParameter.Identifier.Text; string argName = GetPrefixedArgName(name); - string typeName = methodParameter.Type.ToString(); + string typeName = methodParameter.Type?.ToString(); string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type); if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword)) @@ -415,9 +415,9 @@ namespace Ryujinx.Horizon.Kernel.Generators private static string GetCanonicalTypeName(Compilation compilation, SyntaxNode syntaxNode) { TypeInfo typeInfo = compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetTypeInfo(syntaxNode); - if (typeInfo.Type.ContainingNamespace == null) + if (typeInfo.Type?.ContainingNamespace == null) { - return typeInfo.Type.Name; + return typeInfo.Type?.Name; } return $"{typeInfo.Type.ContainingNamespace.ToDisplayString()}.{typeInfo.Type.Name}"; diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index e928c0892..f16aad34a 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -46,7 +46,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input private PlayerIndex _playerId; private PlayerIndex _playerIdChoose; private int _controller; - private int _controllerNumber; private string _controllerImage; private int _device; private object _configViewModel; @@ -247,8 +246,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input if (Program.PreviewerDetached) { _mainWindow = - (MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current - .ApplicationLifetime).MainWindow; + (MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current? + .ApplicationLifetime)?.MainWindow; AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner); @@ -519,7 +518,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input { ProfilesList.Clear(); - string basePath = GetProfileBasePath(); + string basePath = GetProfileBasePath() ?? string.Empty; if (!Directory.Exists(basePath)) { @@ -773,11 +772,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input if (IsKeyboard) { - config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig(); + config = (ConfigViewModel as KeyboardInputViewModel)?.Config.GetConfig(); } else if (IsController) { - config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig(); + config = (ConfigViewModel as ControllerInputViewModel)?.Config.GetConfig(); } config.ControllerType = Controllers[_controller].Type; @@ -842,18 +841,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input if (device.Type == DeviceType.Keyboard) { - var inputConfig = (ConfigViewModel as KeyboardInputViewModel).Config; + var inputConfig = ((KeyboardInputViewModel)ConfigViewModel).Config; inputConfig.Id = device.Id; } else { - var inputConfig = (ConfigViewModel as ControllerInputViewModel).Config; + var inputConfig = ((ControllerInputViewModel)ConfigViewModel).Config; inputConfig.Id = device.Id.Split(" ")[0]; } var config = !IsController - ? (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig() - : (ConfigViewModel as ControllerInputViewModel).Config.GetConfig(); + ? ((KeyboardInputViewModel)ConfigViewModel).Config.GetConfig() + : ((ControllerInputViewModel)ConfigViewModel).Config.GetConfig(); config.ControllerType = Controllers[_controller].Type; config.PlayerIndex = _playerId; diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index b9a5509a6..0f02e4c74 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -2251,7 +2251,7 @@ namespace Ryujinx.Ava.UI.ViewModels switch (operationOutcome) { case XCIFileTrimmer.OperationOutcome.Successful: - if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { if (desktop.MainWindow is MainWindow mainWindow) mainWindow.LoadApplications(); diff --git a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs index 839430f62..8012695fc 100644 --- a/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/ModManagerViewModel.cs @@ -93,9 +93,9 @@ namespace Ryujinx.Ava.UI.ViewModels _modJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationId.ToString("x16"), "mods.json"); - if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { - _storageProvider = desktop.MainWindow.StorageProvider; + _storageProvider = desktop.MainWindow?.StorageProvider; } LoadMods(applicationId, _installedDlcIds); @@ -117,8 +117,8 @@ namespace Ryujinx.Ava.UI.ViewModels foreach (var mod in modCache.RomfsDirs) { - var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd); - if (Mods.All(x => x.Path != mod.Path.Parent.FullName)) + var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd); + if (Mods.All(x => x.Path != mod.Path.Parent?.FullName)) { Mods.Add(modModel); } @@ -131,8 +131,8 @@ namespace Ryujinx.Ava.UI.ViewModels foreach (var mod in modCache.ExefsDirs) { - var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd); - if (Mods.All(x => x.Path != mod.Path.Parent.FullName)) + var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd); + if (Mods.All(x => x.Path != mod.Path.Parent?.FullName)) { Mods.Add(modModel); } diff --git a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs index 31f12af8c..71b20db40 100644 --- a/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml.cs @@ -106,7 +106,7 @@ namespace Ryujinx.Ava.UI.Views.Main private async void StopEmulation_Click(object sender, RoutedEventArgs e) { - await Window.ViewModel.AppHost?.ShowExitPrompt(); + await Window.ViewModel.AppHost.ShowExitPrompt(); } private void PauseEmulation_Click(object sender, RoutedEventArgs e) @@ -211,7 +211,7 @@ namespace Ryujinx.Ava.UI.Views.Main ViewModel.AreMimeTypesRegistered = FileAssociationHelper.Install(); if (ViewModel.AreMimeTypesRegistered) await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty); - else + else { await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesErrorMessage]); }