Ejemplo n.º 1
0
        /// <summary>
        /// Gets the syntax list of custom attributes that declares atributes for this parameter symbol.
        /// </summary>
        internal virtual OneOrMany <SyntaxList <AttributeListSyntax> > GetAttributeDeclarations()
        {
            // C# spec:
            // The attributes on the parameters of the resulting method declaration
            // are the combined attributes of the corresponding parameters of the defining
            // and the implementing partial method declaration in unspecified order.
            // Duplicates are not removed.

            SyntaxList <AttributeListSyntax> attributes = AttributeDeclarationList;

            var sourceMethod = this.ContainingSymbol as SourceMemberMethodSymbol;

            if ((object)sourceMethod == null)
            {
                return(OneOrMany.Create(attributes));
            }

            SyntaxList <AttributeListSyntax> otherAttributes;

            // if this is a definition get the implementation and vice versa
            SourceMemberMethodSymbol otherPart = sourceMethod.OtherPartOfPartial;

            if ((object)otherPart != null)
            {
                otherAttributes = ((SourceParameterSymbol)otherPart.Parameters[this.Ordinal]).AttributeDeclarationList;
            }
            else
            {
                otherAttributes = default(SyntaxList <AttributeListSyntax>);
            }

            if (attributes.Equals(default(SyntaxList <AttributeListSyntax>)))
            {
                return(OneOrMany.Create(otherAttributes));
            }
            else if (otherAttributes.Equals(default(SyntaxList <AttributeListSyntax>)))
            {
                return(OneOrMany.Create(attributes));
            }

            return(OneOrMany.Create(ImmutableArray.Create(attributes, otherAttributes)));
        }