using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp.Emit; using Microsoft.CodeAnalysis.CSharp.Symbols; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Symbols; namespace Microsoft.CodeAnalysis.CSharp; internal sealed class IteratorConstructor : SynthesizedInstanceConstructor, ISynthesizedMethodBodyImplementationSymbol, ISymbolInternal { private readonly ImmutableArray _parameters; public override ImmutableArray Parameters => _parameters; public override Accessibility DeclaredAccessibility => (Accessibility)6; IMethodSymbolInternal ISynthesizedMethodBodyImplementationSymbol.Method => ((ISynthesizedMethodBodyImplementationSymbol)ContainingSymbol).Method; bool ISynthesizedMethodBodyImplementationSymbol.HasMethodBodyDependency => false; internal IteratorConstructor(StateMachineTypeSymbol container) : base(container) { NamedTypeSymbol specialType = container.DeclaringCompilation.GetSpecialType((SpecialType)13); _parameters = ImmutableArray.Create(SynthesizedParameterSymbol.Create(this, TypeWithAnnotations.Create(specialType), 0, (RefKind)0, GeneratedNames.MakeStateMachineStateFieldName(), (ScopedKind)0)); } internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder attributes) { base.AddSynthesizedAttributes(moduleBuilder, ref attributes); CSharpCompilation declaringCompilation = DeclaringCompilation; Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)70)); } }