예제 #1
0
        protected override string GetFieldDeclaration(FieldDefinition field)
        {
            TypeDefinition declType = (TypeDefinition)field.DeclaringType;

            if (declType.IsEnum && field.Name == "value__")
            {
                return(null); // This member of enums aren't documented.
            }
            StringBuilder buf = new StringBuilder();

            AppendFieldVisibility(buf, field);
            if (buf.Length == 0)
            {
                return(null);
            }

            if (declType.IsEnum)
            {
                return(field.Name);
            }

            if (field.IsStatic && !field.IsLiteral)
            {
                buf.Append(" static");
            }
            if (field.IsInitOnly)
            {
                buf.Append(" readonly");
            }
            if (field.IsLiteral)
            {
                buf.Append(" const");
            }

            buf.Append(' ');
            var context        = AttributeParserContext.Create(field);
            var isNullableType = context.IsNullable();

            buf.Append(GetTypeName(field.FieldType, context));
            buf.Append(GetTypeNullableSymbol(field.FieldType, isNullableType));
            buf.Append(' ');
            buf.Append(field.Name);
            DocUtils.AppendFieldValue(buf, field);
            buf.Append(';');

            return(buf.ToString());
        }