Skip to content

Commit

Permalink
Auto-load handler type assembly if not found in platform
Browse files Browse the repository at this point in the history
This fixes auto-loading subclasses when they are in a different assembly as the type with the handler
cwensley committed May 28, 2020
1 parent 55e42ce commit 20a4c07
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Eto/Platform.cs
Original file line number Diff line number Diff line change
@@ -611,14 +611,24 @@ internal HandlerInfo FindHandler(Type type)
return info;

var handler = type.GetCustomAttribute<HandlerAttribute>(true);
Func<object> activator;
if (handler != null && instantiatorMap.TryGetValue(handler.Type, out activator))
if (handler != null)
{
var autoInit = handler.Type.GetCustomAttribute<AutoInitializeAttribute>(true);
info = new HandlerInfo(autoInit == null || autoInit.Initialize, activator);
handlerMap.Add(type, info);
return info;
if (instantiatorMap.TryGetValue(handler.Type, out var activator))
{
var autoInit = handler.Type.GetCustomAttribute<AutoInitializeAttribute>(true);
info = new HandlerInfo(autoInit == null || autoInit.Initialize, activator);
handlerMap.Add(type, info);
return info;
}
// load the assembly of the handler type (needed when type is a subclass)
if (!loadedAssemblies.Contains(handler.Type.GetAssembly()))
{
LoadAssembly(handler.Type.GetAssembly());
return FindHandler(type);
}
}

// load the assembly of the target type (can be a subclass)
if (!loadedAssemblies.Contains(type.GetAssembly()))
{
LoadAssembly(type.GetAssembly());

0 comments on commit 20a4c07

Please sign in to comment.