Files
2026-08-27 10:56:38 -06:00

40 lines
1.8 KiB
C#

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 SynthesizedEmbeddedRefSafetyRulesAttributeSymbol : SynthesizedEmbeddedAttributeSymbolBase
{
private readonly ImmutableArray<FieldSymbol> _fields;
private readonly ImmutableArray<MethodSymbol> _constructors;
public override ImmutableArray<MethodSymbol> Constructors => _constructors;
public SynthesizedEmbeddedRefSafetyRulesAttributeSymbol(string name, NamespaceSymbol containingNamespace, ModuleSymbol containingModule, NamedTypeSymbol systemAttributeType, TypeSymbol int32Type)
: base(name, containingNamespace, containingModule, systemAttributeType)
{
_fields = ImmutableArray.Create((FieldSymbol)new SynthesizedFieldSymbol(this, int32Type, "Version", isPublic: true, isReadOnly: true));
_constructors = ImmutableArray.Create((MethodSymbol)new SynthesizedEmbeddedAttributeConstructorWithBodySymbol(this, (MethodSymbol m) => ImmutableArray.Create(SynthesizedParameterSymbol.Create(m, TypeWithAnnotations.Create(int32Type), 0, (RefKind)0, "", (ScopedKind)0)), GenerateConstructorBody));
}
internal override IEnumerable<FieldSymbol> 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<BoundStatement> statements, ImmutableArray<ParameterSymbol> parameters)
{
statements.Add((BoundStatement)factory.ExpressionStatement(factory.AssignmentExpression(factory.Field(factory.This(), _fields.Single()), factory.Parameter(parameters.Single()))));
}
}