dotnet/roslyn
EnC: disallow editing async methods with incompatible constraints on their method builders
开放
#51,234 创建于 2021年2月15日
Area-InteractiveConcept-Continuous ImprovementInteractive-EnChelp wanted
仓库指标
- 星标
- (20,414 个星标)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Follow up on discussion: https://github.com/dotnet/roslyn/discussions/51189
In debug builds we emit async state machine types as classes so that we can add fields to them as needed during EnC. Emitting the state machine type as reference type instead of a value type might however conflict with a constraint:
If
- the return type of an async method specifies a custom builder
BviaAsyncMethodBuilder, and B.Start<TStateMachine>(ref TStateMachine),B.AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine), orB.AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)have a constraint onTStateMachinethat disallows it to be a reference type.
Fix: The compiler should identify these cases and keep the state machine type as struct. The IDE should disallow editing such async methods.