Skip to content

Commit

Permalink
Merge pull request #337 from PHOENIXCONTACT/hotfix/exported-types
Browse files Browse the repository at this point in the history
Fix LoadComponents for private types with missing reference
  • Loading branch information
MarisaGoergen authored Aug 30, 2023
2 parents 4a5a956 + 41e0d2d commit 445ab0c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Moryx.Container/CastleContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,28 @@ public virtual void LoadComponents<T>(Predicate<Type> condition) where T : class
{
_knownTypes = ReflectionTool.GetAssemblies()
.Where(a => a.GetCustomAttribute<ComponentLoaderIgnoreAttribute>() == null)
.SelectMany(a => a.GetTypes())
.SelectMany(a =>
{
// TODO: Replace with exported types in MORYX 8
try
{
// This should only return exported types
return a.GetTypes();
}
catch
{
// Fall back to exported types in case of exception
try
{
return a.GetExportedTypes();
}
catch
{
// Give up
return new Type[0];
}
}
})
.Where(t => t.GetCustomAttribute<RegistrationAttribute>(true) != null).ToArray();
}

Expand Down

0 comments on commit 445ab0c

Please sign in to comment.