Fix serialization issue

This commit is contained in:
Matt Nadareski
2024-11-13 02:48:38 -05:00
parent 1cf3d50864
commit d0a8e3770b
2 changed files with 16 additions and 8 deletions

View File

@@ -121,19 +121,23 @@ namespace SabreTools.Serialization.Deserializers
return default;
// If not all types can be loaded, use the ones that could be
List<Type> assemblyTypes = [];
Type?[] assemblyTypes = [];
try
{
assemblyTypes = [.. assembly.GetTypes()];
assemblyTypes = assembly.GetTypes();
}
catch (ReflectionTypeLoadException rtle)
{
assemblyTypes = [.. rtle.Types];
assemblyTypes = rtle.Types ?? [];
}
// Loop through all types
foreach (Type type in assemblyTypes)
foreach (Type? type in assemblyTypes)
{
// If the type is invalid
if (type == null)
continue;
// If the type isn't a class
if (!type.IsClass)
continue;

View File

@@ -120,19 +120,23 @@ namespace SabreTools.Serialization.Serializers
return default;
// If not all types can be loaded, use the ones that could be
List<Type> assemblyTypes = [];
Type?[] assemblyTypes = [];
try
{
assemblyTypes = [.. assembly.GetTypes()];
assemblyTypes = assembly.GetTypes();
}
catch (ReflectionTypeLoadException rtle)
{
assemblyTypes = [.. rtle.Types];
assemblyTypes = rtle.Types ?? [];
}
// Loop through all types
foreach (Type type in assemblyTypes)
foreach (Type? type in assemblyTypes)
{
// If the type is invalid
if (type == null)
continue;
// If the type isn't a class
if (!type.IsClass)
continue;