fluentcms / fluentcms/FluentCMS.Infrastructure

[Design] PluginSystemOptions.RegisteredALCs is hidden mutable state — side-channel coupling between PluginLoader and PluginManager

Offen
#16 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
C#
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Summary

`PluginSystemOptions` contains an `internal` mutable list of `AssemblyLoadContext` instances (`RegisteredALCs`). This list is populated by `PluginLoader` and consumed by `PluginManager`. Using a public options/configuration object as a hidden communication channel between two components is an anti-pattern: the options class should carry only configuration values, not mutable runtime state.

## Location

`Plugins/FluentCMS.Infrastructure.Plugins/PluginSystemOptions.cs` — line 51

## Problematic Code

```csharp
internal List RegisteredALCs { get; } = [];
```

## Impact

- **Hidden coupling:** `PluginLoader` and `PluginManager` are implicitly coupled through the shared options object with no documented contract.
- **Unexpected mutation:** Any component that holds a reference to `PluginSystemOptions` can observe or modify the ALC list, which should be an implementation detail.
- **Testing difficulty:** Creating a `PluginSystemOptions` instance in tests doesn't give the expected clean state without knowing about this hidden list.
- **Violation of SRP:** `PluginSystemOptions` now serves two roles: configuration data-bag and runtime ALC registry.

## Recommendation

Remove `RegisteredALCs` from `PluginSystemOptions` and change `LoadPluginTypes` to return a result type that packages both outputs together:

```csharp
public record PluginLoadResult(
IReadOnlyList PluginTypes,
IReadOnlyList LoadContexts
);

// PluginLoader.LoadPluginTypes() returns PluginLoadResult
// PluginManager receives PluginLoadResult directly
```

This makes the data-flow explicit and removes the hidden state from the configuration object.

## Severity

🔵 **Design / Maintainability**

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start with Plugins/FluentCMS.Infrastructure.Plugins/PluginSystemOptions.cs at the RegisteredALCs property, then trace PluginLoader.LoadPluginTypes and the PluginManager call sites that consume the list. Define the result shape described in the issue, pass it directly between the components, and remove the runtime registry from the options object. Done means the data flow is explicit and existing plugin behavior remains intact.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
backend
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.