protected override void GenerateControlFields() { this.stateField = F.StateMachineField(F.SpecialType(SpecialType.System_Int32), GeneratedNames.MakeStateMachineStateFieldName()); // Add a field: T current _currentField = F.StateMachineField(_elementType, GeneratedNames.MakeIteratorCurrentFieldName()); }
protected override void GenerateControlFields() { // the fields are initialized from entry-point method (which replaces the async-iterator method), so they need to be public base.GenerateControlFields(); NamedTypeSymbol boolType = F.SpecialType(SpecialType.System_Boolean); // Add a field: ManualResetValueTaskSourceLogic<bool> promiseOfValueOrEnd _promiseOfValueOrEndField = F.StateMachineField( F.WellKnownType(WellKnownType.System_Threading_Tasks_Sources_ManualResetValueTaskSourceCore_T).Construct(boolType), GeneratedNames.MakeAsyncIteratorPromiseOfValueOrEndFieldName(), isPublic: true); // the element type may contain method type parameters, which are now alpha-renamed into type parameters of the generated class TypeSymbol elementType = ((AsyncStateMachine)stateMachineType).IteratorElementType; // Add a field: T current _currentField = F.StateMachineField(elementType, GeneratedNames.MakeIteratorCurrentFieldName()); // Add a field: bool disposeMode _disposeModeField = F.StateMachineField(boolType, GeneratedNames.MakeDisposeModeFieldName()); if (_isEnumerable && this.method.Parameters.Any(p => p.IsSourceParameterWithEnumeratorCancellationAttribute())) { // Add a field: CancellationTokenSource combinedTokens _combinedTokensField = F.StateMachineField( F.WellKnownType(WellKnownType.System_Threading_CancellationTokenSource), GeneratedNames.MakeAsyncIteratorCombinedTokensFieldName()); } }
protected override void GenerateControlFields() { this.stateField = F.StateMachineField(F.SpecialType(SpecialType.System_Int32), GeneratedNames.MakeStateMachineStateFieldName()); // Add a field: T current _currentField = F.StateMachineField(_elementType, GeneratedNames.MakeIteratorCurrentFieldName()); // if it is an enumerable, and either Environment.CurrentManagedThreadId or Thread.ManagedThreadId are available // add a field: int initialThreadId bool addInitialThreadId = _isEnumerable && CanGetThreadId(); _initialThreadIdField = addInitialThreadId ? F.StateMachineField(F.SpecialType(SpecialType.System_Int32), GeneratedNames.MakeIteratorCurrentThreadIdFieldName()) : null; }
protected override void GenerateControlFields() { // the fields are initialized from entry-point method (which replaces the async-iterator method), so they need to be public base.GenerateControlFields(); NamedTypeSymbol boolType = F.SpecialType(SpecialType.System_Boolean); // Add a field: ManualResetValueTaskSourceLogic<bool> promiseOfValueOrEnd _promiseOfValueOrEndField = F.StateMachineField( F.WellKnownType(WellKnownType.System_Threading_Tasks_Sources_ManualResetValueTaskSourceCore_T).Construct(boolType), GeneratedNames.MakeAsyncIteratorPromiseOfValueOrEndFieldName(), isPublic: true); // the element type may contain method type parameters, which are now alpha-renamed into type parameters of the generated class TypeSymbol elementType = ((AsyncStateMachine)stateMachineType).IteratorElementType; // Add a field: T current _currentField = F.StateMachineField(elementType, GeneratedNames.MakeIteratorCurrentFieldName()); }
protected override void GenerateControlFields() { this.stateField = F.StateMachineField(F.SpecialType(SpecialType.System_Int32), GeneratedNames.MakeStateMachineStateFieldName()); // Add a field: T current _currentField = F.StateMachineField(_elementType, GeneratedNames.MakeIteratorCurrentFieldName()); // if it is an enumerable, and either Environment.CurrentManagedThreadId or System.Thread are available // add a field: int initialThreadId bool addInitialThreadId = _isEnumerable && ((object)F.WellKnownMember(WellKnownMember.System_Threading_Thread__ManagedThreadId, isOptional: true) != null || (object)F.WellKnownMember(WellKnownMember.System_Environment__CurrentManagedThreadId, isOptional: true) != null); _initialThreadIdField = addInitialThreadId ? F.StateMachineField(F.SpecialType(SpecialType.System_Int32), GeneratedNames.MakeIteratorCurrentThreadIdFieldName()) : null; }