Files

35 lines
1.6 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:56:38 -06:00
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<ParameterSymbol> _parameters;
public override ImmutableArray<ParameterSymbol> 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<SynthesizedAttributeData> attributes)
{
base.AddSynthesizedAttributes(moduleBuilder, ref attributes);
CSharpCompilation declaringCompilation = DeclaringCompilation;
Symbol.AddSynthesizedAttribute(ref attributes, declaringCompilation.TrySynthesizeAttribute((WellKnownMember)70));
}
}