GNOME Bugzilla – Bug 437434
Support property metadata
Last modified: 2008-10-18 21:07:42 UTC
Add support for property metadata like nick, blurb, and default value to Vala, possibly using attributes.
In the spirit of C# I'd suggest using the attributes Description and DefaultValue for blurb and default value. Regarding the nick: Shouldn't it get generated automatically?
Description and DefaultValue attributes sound fine to me. What should Vala use as nick for properties?
(In reply to comment #2) > What should Vala use as nick for properties? From my experience and from scanning the source code of GTK+ I'd suggest replacing underscores by spaces and converting the lower-case property name to title case: So "tooltip_column" would become "Tooltip Column". Well, but you are right when you claim there are exceptions from this rule. For instance the "scroll-arrow-hlength" property has the nick "Horizontal Scroll Arrow Length". So it seems to be necessary to allow overriding of the nick. What would be good attribute name? "DisplayName"? Or should we just extend the "Description" attribute to have an optional "displayName" property?
An attribute might not be the best place for the default value. I currently tend to the following syntax: public int foo { get; set; default (42); }
Created attachment 103993 [details] [review] proposed patch to add Description metadata to properties I try to add metadata to properties and with this patch you can insert attributes in this form: [Description(nickname="Short Descrition", fulldesc="Full Descrition of this property")] public string example_property {get; set;} I dont know if its enougth with these small changes or if its necesary change more files. Also im nor sure if the initialization in the Property class its good or if exist another better way to do it. Anyway its my first path i hope you undertand. Thankyou.
Thanks for the patch. I'll go for nick and blurb for now to use the same names as in the GObject documentation.
2008-02-02 Jürg Billeter <j@bitron.ch> * vala/valaproperty.vala, gobject/valaccodegeneratorinterface.vala: support [Description (nick = "foo", blurb = "bar")] attribute, based on patch by Juan Carlos Girardi, fixes part of bug 437434 Partly fixed in r948.
2008-02-05 Jürg Billeter <j@bitron.ch> * vala/parser.y, vala/valaclass.vala, vala/valaproperty.vala, gobject/valaccodegeneratorinterface.vala: support default values for properties, fixes bug 437434 Fixed in r980.
Are there no plans for other metadata, such as the range for numeric types?
test case added to vala-tests