NServiceBus
NServiceBus copied to clipboard
Use .NET 5 source generators to build message and handler metadata registry at compile time
NServiceBus endpoint is doing assembly scanning during startup. In scenarios, where assemblies are known and available at compile time (probably the majority of cases) we could use source generators to run the scanning once and provide the results as additional type generated pre-compile-time.
There is probably some impact on the development experience i.e. how long it takes to do the scanning so that this does not impede the F5 experience.
This feature would enable us to have a quicker cold-start experience in Cloud environments like container hosting, Azure Functions, and AWS Lambda.
where assemblies are known and available at compile time (probably the majority of cases)
would that be something the user has to explicitly define? I'm not sure how else we can be sure that there will be no assembly to scan?
@timbussmann did not dig deep into possible solutions but I see at least 3 options here:
- Assume there are no runtime drop-in assemblies and let the user switch back to current behavior with explicit configuration setting
- Go the other way round (have an explicit setting to turn the scanning off).
- Try to be smart and do the scanning only for the assemblies we did not see at compile time.
It's important to remember that ADSD teaches that the project view in Visual Studio (or wherever compilation and thus source generators are acting) isn't necessarily the same as your deployment view, and that service composition can be done by deploying DLLs together.