elsa-workflows / elsa-workflows/elsa-core

DLL discovery feature

Open
#1,285 1 comment 3 reactions 0 assignees View on GitHub
enhancement triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

I reference all elsa features as NuGet packages:
![image](https://user-images.githubusercontent.com/1503577/126303090-ba2b41c8-3647-4946-94ac-30b2dec785af.png)

And then I need to define them in my startup like this:
```csharp
var startups = new[]
{
typeof(Elsa.Activities.Console.Startup),
...
typeof(Webhooks.Persistence.YesSql.MySqlStartup),
typeof(Webhooks.Persistence.YesSql.PostgreSqlStartup),
};

services
.AddElsa(options => options
.AddActivitiesFrom()
.AddWorkflowsFrom()
.AddFeatures(new[] { typeof(Startup) }, Configuration)
// this line should be obsolete!
.AddFeatures(startups, Configuration)
```

Can we get rid of `.AddFeatures(startups, Configuration)` and instead search for all the libraries automatically?

I did something like this before in another project:
```csharp
ServiceAssemblies = Directory.EnumerateFiles(serviceDir, "*.dll", SearchOption.TopDirectoryOnly)
.Select(Assembly.LoadFrom)
.Where(_ => !_.ManifestModule.Name.StartsWith("ServiceDefinitions.dll"))
.ToArray();

builder.RegisterAssemblyTypes(ServiceAssemblies)
.Where(t => t.IsAssignableTo())
.Where(t => !t.IsAbstract)
.As()
.AsSelf()
.InstancePerDependency();
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing AddFeatures(startups, Configuration) registration path alongside AddActivitiesFrom() and AddWorkflowsFrom(). Review the referenced assembly-loading approach using Directory.EnumerateFiles and Assembly.LoadFrom, then determine the supported discovery scope and configuration behavior. Done means feature assemblies are discovered without manually listing startup types and existing registration still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.