public override ImmutableArray <AttributeData> GetAttributes()
 {
     // [CompilerGenerated]
     return(ImmutableArray.Create <AttributeData>(
                DeclaringCompilation.CreateCompilerGeneratedAttribute()
                ));
 }
예제 #2
0
        public override ImmutableArray <AttributeData> GetAttributes()
        {
            var builder = ImmutableArray.CreateBuilder <AttributeData>();

            if (IsPhpHidden)
            {
                // [PhpHiddenAttribute]
                builder.Add(new SynthesizedAttributeData(
                                DeclaringCompilation.CoreMethods.Ctors.PhpHiddenAttribute,
                                ImmutableArray <TypedConstant> .Empty,
                                ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty));
            }

            if (IsEditorBrowsableHidden)
            {
                builder.Add(new SynthesizedAttributeData(
                                (MethodSymbol)DeclaringCompilation.GetWellKnownTypeMember(WellKnownMember.System_ComponentModel_EditorBrowsableAttribute__ctor),
                                ImmutableArray.Create(
                                    new TypedConstant(
                                        DeclaringCompilation.GetWellKnownType(WellKnownType.System_ComponentModel_EditorBrowsableState),
                                        TypedConstantKind.Enum,
                                        System.ComponentModel.EditorBrowsableState.Never)),
                                ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty));
            }

            if (this is SynthesizedPhpCtorSymbol sctor && sctor.IsInitFieldsOnly) // we do it here to avoid allocating new ImmutableArray in derived class
            {
                // [PhpFieldsOnlyCtorAttribute]
                builder.Add(new SynthesizedAttributeData(
                                DeclaringCompilation.CoreMethods.Ctors.PhpFieldsOnlyCtorAttribute,
                                ImmutableArray <TypedConstant> .Empty,
                                ImmutableArray <KeyValuePair <string, TypedConstant> > .Empty));

                // [CompilerGeneratedAttribute]
                builder.Add(DeclaringCompilation.CreateCompilerGeneratedAttribute());
            }

            return(builder.ToImmutable());
        }