Particular / NServiceBus

Build, version, and monitor better microservices with the most powerful service platform for .NET
https://particular.net/nservicebus/
Other
2.07k stars 650 forks source link

AssemblyScanner doesn't scan message assemblies that reference Message Interfaces #7092

Open danielmarbach opened 2 weeks ago

danielmarbach commented 2 weeks ago

Symptoms

The assembly scanner doesn't scan message assemblies that reference the recently introduced NServiceBus.MessageInterfaces assembly

Who's affected

Customers using the recently introduced NServiceBus.MessageInterfaces assembly

Root cause

The idea of message interfaces was to provide a stable package that message assemblies can reference without having to reference NServiceBus.Core. Unfortunately, the assembly scanner has not be changed to include the assemblies that reference the interface package which means effectively message assemblies that reference it will be treated as unobtrusive messages.

This has implications because it means the types have to be always loaded at runtime and any code that previously relied on messages that are marked as "NServiceBus messages" are no longer discovered during scanning and therefore not added to the message metadata registry (*), which makes it difficult to discover all message types even though effectively, you are using a well known and defined marker interface.

So switching from referencing Core to message interfaces effectively is a behavior change that also has other consequences that the customer is not aware of.

(*) The direct handled type is though because we inspect the generic type of the handler, but we already do this with unobtrusive messages too.

Backported to