Skip to content

Commit

Permalink
Merge pull request #165 from hadashiA/ku/fix-refrection-type-loaded-e…
Browse files Browse the repository at this point in the history
…xception

Fix RefrectionTypeLoadException
  • Loading branch information
hadashiA committed Mar 24, 2021
2 parents d13885a + 4f4275f commit d1fecbd
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using VContainer.Unity;
Expand All @@ -15,10 +16,26 @@ static string[] GetAllTypeNames()

foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
var types = assembly.GetTypes();
if (assembly.FullName.StartsWith("UnityEngine.") ||
assembly.FullName.StartsWith("Unity.") ||
assembly.FullName.StartsWith("System."))
{
continue;
}

Type[] types;
try
{
types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types;
}

foreach (var type in types)
{
if (type.IsSubclassOf(typeof(LifetimeScope)))
if (type?.IsSubclassOf(typeof(LifetimeScope)) == true)
{
result.Add(type.FullName);
}
Expand Down

1 comment on commit d1fecbd

@vercel
Copy link

@vercel vercel bot commented on d1fecbd Mar 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.