Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Property | Value |
---|---|
Rule ID | MSTEST0040 |
Title | Do not assert inside 'async void' contexts |
Category | Usage |
Fix is breaking or non-breaking | Non-breaking |
Enabled by default | Yes |
Default severity | Warning |
Introduced in version | 3.8.0 |
Is there a code fix | No |
The use of any assertion method in an async void
method, local function, or lambda.
Exceptions that are thrown in an async void
context are unhandled. A failing assertion in an async void
method will be swallowed and will not crash the process when using VSTest under .NET Framework. Under .NET, a failing assertion in an async void
method might crash the process when using Microsoft.Testing.Platform or VSTest. In cases where a custom SynchronizationContext
is present that catches the exception, the failing assertion might be silently swallowed.
Refactor the code to not use assertions in async void
.
Do not suppress a warning from this rule.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now