Skip to content

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
@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