Skip to content

Commit 00ee76d

Browse files
committed
fix: Fixed FileNotFound exception when Assembly-CSharp is not generated in a project
1 parent e626059 commit 00ee76d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Editor/Util/TypeCollector.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,15 @@ public static List<Assembly> GetAssembliesTypeHasAccessTo(Type type)
5454

5555
public static List<Assembly> GetAssembliesTypeHasAccessTo(Type type, out bool containsMSCorLib)
5656
{
57-
containsMSCorLib = false;
58-
Assembly typeAssembly;
59-
60-
try
61-
{
62-
typeAssembly = type == null ? Assembly.Load("Assembly-CSharp") : type.Assembly;
63-
}
64-
catch (FileNotFoundException)
57+
if (type == null)
6558
{
66-
throw new FileNotFoundException("Assembly-CSharp.dll was not found. Please create any " +
67-
"script in the Assets folder so that the assembly is generated.");
59+
containsMSCorLib = true;
60+
return GetAllAssemblies();
6861
}
6962

63+
containsMSCorLib = false;
64+
Assembly typeAssembly = type.Assembly;
65+
7066
var referencedAssemblies = typeAssembly.GetReferencedAssemblies();
7167
var assemblies = new List<Assembly>(referencedAssemblies.Length + 1);
7268

@@ -92,6 +88,11 @@ public static List<Assembly> GetAssembliesTypeHasAccessTo(Type type, out bool co
9288
return assemblies;
9389
}
9490

91+
private static List<Assembly> GetAllAssemblies()
92+
{
93+
return new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
94+
}
95+
9596
public static List<Type> GetFilteredTypesFromAssemblies(
9697
List<Assembly> assemblies,
9798
TypeOptionsAttribute filter)

0 commit comments

Comments
 (0)