Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

❇️ Re-implementation of plugins API #206

Merged
merged 12 commits into from
Nov 30, 2023
Merged

Conversation

pleonex
Copy link
Member

@pleonex pleonex commented Nov 29, 2023

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

  • Related code has been tested automatically or manually
  • Related documentation is updated
  • I acknowledge I have read and filled this checklist and accept the
    developer certificate of origin

Acceptance criteria

  • 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<,>));

@pleonex pleonex added this to the v4.0 milestone Nov 29, 2023
@pleonex pleonex self-assigned this Nov 29, 2023
@pleonex pleonex marked this pull request as ready for review November 30, 2023 13:34
@pleonex pleonex merged commit 7ae5d2c into develop Nov 30, 2023
5 checks passed
@pleonex pleonex deleted the feature/new-plugins branch November 30, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant