Closed
Description
Problem
It's recommended to always use ConfigureAwait(false)
in certain kinds of libraries. While it's definitely possible to use an analyzer (e.g. ConfigureAwaitChecker.Analyzer) to catch those cases, the analyzer has to be installed separately and the resulting code is awkward and verbose.
Potential solutions
Option A
Provide an assembly-level attribute that would force compiler to generate (pattern-based) ConfigureAwait(false)
calls for each await
.
Option B
- Implement CallerMethodAttribute from automatic resource management for try/catch/finally statement for C# (duplicate for https://github.com/dotnet/roslyn/issues/4005, c# only) #351
- Add support for method info attributes to pattern-based GetAwaiter calls
- This would allow for a new overload
GetAwaiter([CallerMethod] MethodBase method = null)
Task
could use this overload to look for some attribute onmethod.Assembly
and return a correspondingly preconfigured awaiter.
Metadata
Metadata
Assignees
Labels
No labels