NServiceBus 7.1 and 6.5 Beta includes Roslyn analyzer to catch async/await errors

(David Boike) #1

Hi everyone,

We recently released beta versions of NServiceBus 7.1.0 and NServiceBus 6.5.0. They include a Roslyn analyzer which helps you avoid errors when using async/await with NServiceBus APIs.

The analyzer will create a compile-time error when you use an NServiceBus API that returns a Task or Task<T> and do not either await the task or assign it to a variable. When that happens, you’ll see:

NSB0001: A Task returned by an NServiceBus method is not awaited or assigned to a variable.

Check out the NServiceBus Analyzer documentation for details about the analyzer’s features and limitations.

These errors can be pretty tough to track down. They often behave like a race condition between the completion of the task and the end of the message handling pipeline. The consequences can be severe: anything from unexpected behavior to outright message loss. We hope that including this analyzer in NServiceBus means you will never need to track down these errors yourself.

While these versions are in beta, we’d love to hear your feedback! If the analyzer detects a missing await in your code, please drop us a line at support@particular.net and let us know!

With thanks,

The team in Particular