Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JoinableTaskContext.CreateNoOpContext() method #1345

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Aug 13, 2024

The JoinableTaskContext constructor unfortunately has a poor design where folks passing in null for the SynchronizationContext may mistakenly believe that they're getting a no-op instance when they aren't, if SynchronizationContext.Current != null.

In this change, I add a method that definitely does what they expect.

I also add an analyzer and a code fix provider to help identify code that was likely written with the incorrect expectation to help them switch to the new method which matches their expectation, or suppress the warning with a more clear syntax.

@AArnott AArnott added this to the v17.12 milestone Aug 13, 2024
@AArnott AArnott requested review from BertanAygun and lifengl August 13, 2024 03:32
The `JoinableTaskContext` constructor unfortunately has a poor design where folks passing in `null` for the `SynchronizationContext` may mistakenly believe that they're getting a no-op instance when they aren't, if `SynchronizationContext.Current != null`.

In this change, I add a method that *definitely* does what they expect.

I also add an analyzer and a code fix provider to help identify code that was likely written with the incorrect expectation to help them switch to the new method which matches their expectation, or suppress the warning with a more clear syntax.
@AArnott AArnott merged commit cc929f4 into microsoft:main Aug 13, 2024
5 checks passed
@AArnott AArnott deleted the jtcCtor branch August 13, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants