using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.CSharp.Symbols; internal sealed class SynthesizedEmbeddedNullablePublicOnlyAttributeSymbol : SynthesizedEmbeddedAttributeSymbolBase { private readonly ImmutableArray _fields; private readonly ImmutableArray _constructors; public override ImmutableArray Constructors => _constructors; public SynthesizedEmbeddedNullablePublicOnlyAttributeSymbol(string name, NamespaceSymbol containingNamespace, ModuleSymbol containingModule, NamedTypeSymbol systemAttributeType, TypeSymbol systemBooleanType) : base(name, containingNamespace, containingModule, systemAttributeType) { _fields = ImmutableArray.Create((FieldSymbol)new SynthesizedFieldSymbol(this, systemBooleanType, "IncludesInternals", isPublic: true, isReadOnly: true)); _constructors = ImmutableArray.Create((MethodSymbol)new SynthesizedEmbeddedAttributeConstructorWithBodySymbol(this, (MethodSymbol m) => ImmutableArray.Create(SynthesizedParameterSymbol.Create(m, TypeWithAnnotations.Create(systemBooleanType), 0, (RefKind)0, "", (ScopedKind)0)), GenerateConstructorBody)); } internal override IEnumerable GetFieldsToEmit() { return _fields; } internal override AttributeUsageInfo GetAttributeUsageInfo() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return new AttributeUsageInfo(AttributeTargets.Module, false, false); } private void GenerateConstructorBody(SyntheticBoundNodeFactory factory, ArrayBuilder statements, ImmutableArray parameters) { statements.Add((BoundStatement)factory.ExpressionStatement(factory.AssignmentExpression(factory.Field(factory.This(), _fields.Single()), factory.Parameter(parameters.Single())))); } }