Esempio n. 1
0
        public static AttributeSyntax EmitSyntax(AttributeDescription description)
        {
            var syntax = Attribute(SyntaxHelpers.GetTypeFullNameSyntax(description.AttributeType));

            if (description.ConstructorArguments.Count > 0 || description.PropertyValues.Count > 0)
            {
                syntax = syntax
                         .WithArgumentList(
                    AttributeArgumentList(
                        SeparatedList <AttributeArgumentSyntax>(
                            description.ConstructorArguments.Select(arg =>
                                                                    AttributeArgument(SyntaxHelpers.GetLiteralSyntax(arg)))
                            .Concat(description.PropertyValues.Select(pv =>
                                                                      AttributeArgument(ExpressionSyntaxEmitter.EmitSyntax(pv.Value))
                                                                      .WithNameEquals(NameEquals(IdentifierName(pv.Name)))
                                                                      ))
                            )
                        )
                    );
            }

            return(syntax);
        }
Esempio n. 2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        protected BaseTypeSyntax ToBaseTypeSyntax(TypeMember baseTypeMember)
        {
            return(SimpleBaseType(SyntaxHelpers.GetTypeFullNameSyntax(baseTypeMember)));
        }