misc: chore: Fix possible System.NullReferenceExceptions

This commit is contained in:
KeatonTheBot 2025-04-11 12:46:19 -05:00
parent 19013d360a
commit 3c644a712d
8 changed files with 26 additions and 27 deletions

View file

@ -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}";