[dotnet watch] Enable CA2007 (ConfigureAwait) for startup hook assembly#54116
Merged
jonathanpeppers merged 1 commit intorelease/10.0.4xxfrom Apr 30, 2026
Merged
Conversation
Enable CA2007 as an error in the HotReloadAgent.Host .editorconfig and add ConfigureAwait(false) to awaits in the startup hook assembly. This assembly runs inside the user's app process where a SynchronizationContext may be present (e.g. UIKitSynchronizationContext on iOS), so missing ConfigureAwait(false) can cause deadlocks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
db753fa to
5b79f2d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Enables CA2007 as an error for the HotReloadAgent.Host startup hook assembly and updates awaits to use ConfigureAwait(false) to avoid deadlocks when a SynchronizationContext is present in the user’s app process (e.g., iOS UIKitSynchronizationContext).
Changes:
- Enable
CA2007as an error inHotReloadAgent.Host/.editorconfig. - Add
.ConfigureAwait(false)to awaited calls in the startup hook notification path. - Add
.ConfigureAwait(false)toNamedPipeTransport.SendAsyncawaits.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Dotnet.Watch/HotReloadAgent.Host/StartupHook.cs | Adds ConfigureAwait(false) when sending the rude-edit notification to avoid context-related deadlocks. |
| src/Dotnet.Watch/HotReloadAgent.Host/NamedPipeTransport.cs | Adds ConfigureAwait(false) to pipe write awaits to comply with CA2007 and avoid context capture. |
| src/Dotnet.Watch/HotReloadAgent.Host/.editorconfig | Enables CA2007 as an error for this assembly to prevent future context-capturing awaits. |
tmat
approved these changes
Apr 29, 2026
This was referenced Apr 30, 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.
Enable CA2007 as an error in the
HotReloadAgent.Host.editorconfigand addConfigureAwait(false)to awaits in the startup hook assembly. This assembly runs inside the user's app process where aSynchronizationContextmay be present (e.g.UIKitSynchronizationContexton iOS), so missingConfigureAwait(false)can cause deadlocks.Context: #54023 (comment)