Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 27, 2025

  • Detect SemaphoreSlim.Wait calls where the timeout argument is constant 0 or TimeSpan.Zero
  • Skip diagnostic reporting for these non-blocking patterns
  • Fix Task.Wait check to include type check in condition (prevents matching SemaphoreSlim.Wait)
  • Code review completed - no issues found
  • Security scan completed - no vulnerabilities found
  • Verify all tests pass in CI
Original prompt

MA0042 should not suggest to replace SemaphoreSlim.Wait(0) with WaitAsync. But only when the argument is the constant 0.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@meziantou meziantou marked this pull request as ready for review November 27, 2025 03:57
Copilot AI changed the title [WIP] Fix MA0042 to prevent replacing SemaphoreSlim.Wait(0) Fix MA0042 to not flag SemaphoreSlim.Wait(0) as blocking Nov 27, 2025
Copilot AI requested a review from meziantou November 27, 2025 04:01
@meziantou
Copy link
Owner

@copilot the tests are failing

Copy link
Contributor Author

Copilot AI commented Nov 27, 2025

@copilot the tests are failing

Fixed in 3ce839d. The issue was that the Task.Wait check (which checks targetMethod.Name == "Wait") was capturing SemaphoreSlim.Wait calls because they share the same method name. Moved the type check into the condition so the else if chain properly falls through to the SemaphoreSlim.Wait(0) skip logic.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.nuget.org
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.runtimeconfig.json --depsfile /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.deps.json /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/testhost.dll --port 41015 --endpoint 127.0.0.1:041015 --role client --parentprocessid 4102 --datacollectionport 38611 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.runtimeconfig.json --depsfile /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.deps.json /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/testhost.dll --port 45033 --endpoint 127.0.0.1:045033 --role client --parentprocessid 4285 --datacollectionport 33465 --telemetryoptedin false (dns block)
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.runtimeconfig.json --depsfile /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/Meziantou.Analyzer.Test.deps.json /home/REDACTED/work/Meziantou.Analyzer/Meziantou.Analyzer/tests/Meziantou.Analyzer.Test/bin/Debug/net10.0/testhost.dll --port 46193 --endpoint 127.0.0.1:046193 --role client --parentprocessid 4468 --datacollectionport 35167 --telemetryoptedin false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

This was referenced Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants