Detect async void lambdas in AsyncVoidAnalyzer (TUnit0031)#4758
Merged
Detect async void lambdas in AsyncVoidAnalyzer (TUnit0031)#4758
Conversation
…delegates Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix concurrency bug with Microsoft.Testing.Platform
Detect async void lambdas in AsyncVoidAnalyzer (TUnit0031)
Feb 13, 2026
1 task
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. This PR effectively addresses a critical gap in the
The fix resolves the |
This was referenced Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
AsyncVoidAnalyzeronly flaggedasync voidmethods via symbol analysis, missingasync voidlambdas and anonymous delegates. These silently swallow exceptions on the thread pool, causingSemaphoreFullExceptioncrashes when the unhandled exception races withExecuteRequestContext.Complete().Changes
AsyncVoidAnalyzer.cs— AddedRegisterSyntaxNodeActionforParenthesizedLambdaExpression,SimpleLambdaExpression, andAnonymousMethodExpression. Resolves the lambda'sIMethodSymbolvia semantic model to checkReturnsVoid.Resources.resx/Resources.Designer.cs— Diagnostic message updated to "Async void methods and lambdas are not allowed".AsyncVoidAnalyzerTests.cs— Five new test cases: parenthesized lambda, simple lambda, parameterized lambda, anonymous delegate, and aFunc<Task>negative case.Original prompt
This section details on the original issue you should resolve
<issue_title>[Bug]: concurrency bug with Microsoft.Testing.Platform</issue_title>
<issue_description>### Description
Running dotnet test (enabled MTP in global.json). It crashes in one specific project in the solution and in no others. I didn't manage to find the difference between this and other projects in the way we have set up tests.
Expected Behavior
Well, not to crash.
Actual Behavior
I am getting the same crash in dotnet test, VS 2026, and Rider 2026.1 EAP 3.
Noticing that if I run a smaller number of tests, it will run as expected. Increasing the number of tests running in parallel will sometimes have all test passing, sometimes trigger this crash. Selecting even more tests to run in parallel will reliably crash TUnit every time.
The same is happening with the latest v1.13.56, as was with v1.12.139.
Steps to Reproduce
Running dotnet test on solution, or running "Run all tests" on my Parser.MySql.UnitTests project.
TUnit Version
1.13.56
.NET Version
.NET 10.0
Operating System
Windows
IDE / Test Runner
JetBrains Rider
Error Output / Stack Trace