Skip to content

Commit c2ef4fe

Browse files
valadasdavid-poindexter
authored andcommitted
Returns the working types if some fail (#2953)
1 parent 189a246 commit c2ef4fe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

DNN Platform/DotNetNuke.DependencyInjection/Extensions/TypeExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using System.Reflection;
34

45
namespace DotNetNuke.DependencyInjection.Extensions
@@ -32,8 +33,15 @@ public static Type[] SafeGetTypes(this Assembly assembly)
3233
{
3334
types = assembly.GetTypes();
3435
}
36+
catch (ReflectionTypeLoadException ex)
37+
{
38+
//TODO: We should log the reason of the exception after the API cleanup
39+
//Ensure that Dnn obtains all types that were loaded, ignoring the failure(s)
40+
types = ex.Types.Where(x => x != null).ToArray<Type>();
41+
}
3542
catch (Exception)
36-
{
43+
{
44+
//TODO: We should log the reason of the exception after the API cleanup
3745
types = new Type[0];
3846
}
3947

0 commit comments

Comments
 (0)