elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

Add possibility to use dynamically loaded assemblies

Open truthz03 opened this issue 1 year ago • 9 comments

Because I need a way to load assemblies dynamically (plugins) in my project, I found some problems while serializing/deserializing payloads. In order to solve this problem, I would like to implement a mechanism to resolve the necessary types manually if needed.


This change is Reviewable

truthz03 avatar May 08 '24 11:05 truthz03

@dotnet-policy-service agree

truthz03 avatar May 08 '24 11:05 truthz03

@truthz03

Please confirm whether the commit "https://github.com/elsa-workflows/elsa-core/pull/5352/commits/367f5749e8d5676ae10de5abb2003b4781ef6fba" will resolve the bug "https://github.com/elsa-workflows/elsa-core/issues/5356"

cvijayak avatar May 13 '24 06:05 cvijayak

@cvijayak No, my commit will not fix this bug. My commit gives the possibility to deserialize stored things into unknown objects. This means, if I add some activities and there payloads as plugin (within a different AppDomain), it will be possible to deserialize the json content to a type only known by the plugin AppDomain.

The bug #5356 shows problems with the serialization. It throws an error because the type is System.Type, which is a known type. I also don't know why System.Type is not serializeable.

truthz03 avatar May 13 '24 10:05 truthz03

Is there something to do for my to get the "SonarCloud Code Analysis" ready? Or have I still to wait?

truthz03 avatar May 13 '24 10:05 truthz03

@truthz03 Thanks for your PR! At this point there's nothing for you to do, I just need time to review and test. Thank you for your patience.

sfmskywalker avatar May 20 '24 09:05 sfmskywalker

@sfmskywalker Hi, can you tell me how long it will take to get my PR merged?

truthz03 avatar Jun 13 '24 08:06 truthz03

@truthz03 Hey there, sorry it's been taking a while. I will get this merged this week. Thanks again for your contribution, your PR makes sense!

sfmskywalker avatar Jun 13 '24 09:06 sfmskywalker

@truthz03 Unfortunately, the main branch received an update that uses the PolymorphicObjectConverterFactory as a type in a JsonConverterAttribute - which only works with parameterless constructors.

In other words, we need to revisit either that change, or your change, such that you can still resolve services from DI.

sfmskywalker avatar Jun 20 '24 21:06 sfmskywalker

@sfmskywalker Ok. Let me know if you find a solution. Maybe its possible to have 2 constructors. One parameterless for the attribute where it is not possible to inject anything and one with parameters.

truthz03 avatar Jun 21 '24 06:06 truthz03