This PR introduces a new design of the plugins API. The classes are now in the new library Yarhl.Plugins. This implementation does not use any underlying technology like MEF in the past.
There are two main classes:
TypeLocator: it scans the current loaded assemblies to find types that implement the given interface.
ConverterLocator using TypeLocator keeps a cache of types and converters found in assemblies.
Additionally, new extension methods for AssemblyLoadContext help to load assemblies from the current executing directory or a given path. By default it does not load any additional assembly from any folder anymore. This was a potential security risk. Developers can choose to do it via these extension methods, alerting the user first if wanted.
Quality check list
[x] Related code has been tested automatically or manually
The library does not load additional assemblies by default
The library can find formats in the loaded assemblies
The library can find converters in the loaded assemblies
Developers can load assemblies from additional paths with APIs
Follow-up work
None
Example
Find converters
var converters = ConverterLocator.Instance.Converters;
Find formats
var formats = ConverterLocator.Instance.Format;
Find a type that implements the given interface
var types1 = TypeLocator.Instance.FindImplementationOf(typeof(IFormat));
// For generic types use this overload
var types2 = TypeLocator.Instance.FindImplementationOfGeneric(typeof(IConverter<,>));
This PR introduces a new design of the plugins API. The classes are now in the new library
Yarhl.Plugins
. This implementation does not use any underlying technology like MEF in the past.There are two main classes:
TypeLocator
: it scans the current loaded assemblies to find types that implement the given interface.ConverterLocator
usingTypeLocator
keeps a cache of types and converters found in assemblies.Additionally, new extension methods for
AssemblyLoadContext
help to load assemblies from the current executing directory or a given path. By default it does not load any additional assembly from any folder anymore. This was a potential security risk. Developers can choose to do it via these extension methods, alerting the user first if wanted.Quality check list
Acceptance criteria
Follow-up work
None
Example