Merge pull request #66253 from raulsntos/dotnet/assembly-may-be-null

C#: Guard against null assemblies
This commit is contained in:
Ignacio Roldán Etcheverry 2022-09-22 18:24:31 +02:00 committed by GitHub
commit 62792eeb9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -29,7 +29,7 @@ namespace Godot.SourceGenerators
{
while (symbol != null)
{
if (symbol.ContainingAssembly.Name == assemblyName &&
if (symbol.ContainingAssembly?.Name == assemblyName &&
symbol.ToString() == typeFullName)
{
return true;
@ -47,7 +47,7 @@ namespace Godot.SourceGenerators
while (symbol != null)
{
if (symbol.ContainingAssembly.Name == "GodotSharp")
if (symbol.ContainingAssembly?.Name == "GodotSharp")
return symbol;
symbol = symbol.BaseType;

View File

@ -124,8 +124,8 @@ namespace Godot.SourceGenerators
if (typeKind == TypeKind.Struct)
{
if (type.ContainingAssembly.Name == "GodotSharp" &&
type.ContainingNamespace.Name == "Godot")
if (type.ContainingAssembly?.Name == "GodotSharp" &&
type.ContainingNamespace?.Name == "Godot")
{
return type switch
{
@ -208,9 +208,9 @@ namespace Godot.SourceGenerators
if (type.SimpleDerivesFrom(typeCache.GodotObjectType))
return MarshalType.GodotObjectOrDerived;
if (type.ContainingAssembly.Name == "GodotSharp")
if (type.ContainingAssembly?.Name == "GodotSharp")
{
switch (type.ContainingNamespace.Name)
switch (type.ContainingNamespace?.Name)
{
case "Godot":
return type switch
@ -220,7 +220,7 @@ namespace Godot.SourceGenerators
_ => null
};
case "Collections"
when type.ContainingNamespace.FullQualifiedName() == "Godot.Collections":
when type.ContainingNamespace?.FullQualifiedName() == "Godot.Collections":
return type switch
{
{ Name: "Dictionary" } =>