misc: chore: Fix possible System.NullReferenceExceptions

This commit is contained in:
KeatonTheBot
2025-04-12 12:27:15 -05:00
parent 19013d360a
commit 3c644a712d
8 changed files with 26 additions and 27 deletions
@@ -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)