Particular / NServiceBus

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

Roslyn analyzer to prevent dispatching messages incorrectly #6866

Open SeanFeldman opened 11 months ago

SeanFeldman commented 11 months ago

Describe the feature.

Is your feature related to a problem? Please describe.

Publishing events and sending commands is validating at run-time. Having an analyzer to detect that during development time would be very helpful.

Describe the requested feature

When encountering one of these scenarios, e.g.

context.Publish(command);
// or
context.Send(event);

Have the Roslyn analyzer generate an error with a fix to the correct operation.

Additional Context

There are potential complications, such as message conventions.

kbaley commented 11 months ago

That's a good suggestion for cases when you use the marker interfaces. We'll keep this in mind for a future enhancement. Thanks!