Getting more information from fields

25 views
Skip to first unread message

deedee

unread,
Jul 11, 2012, 5:16:36 PM7/11/12
to mono-...@googlegroups.com

Hi,

Is there a way to fetch more information from a fieldDefinition?
For example, I am trying to look for all the MenuItems in a type, so for a given field name '_menuItem1' and it's fieldDefinition, can I obtain some more information - like the properties of that MenuItem (Text, Visible, etc)?

If so, how?
Thanks,

deedee

unread,
Jul 11, 2012, 5:23:31 PM7/11/12
to mono-...@googlegroups.com
I can iterate through the instructions in InitializeComponent, but it's a matter of performance. and also sometimes, menuitems in the code are generated at runtime, hence this will not give me the complete list.

Fabian Schmied

unread,
Jul 12, 2012, 2:35:52 AM7/12/12
to mono-...@googlegroups.com
You could look at the FieldDefinition's FieldType property. This
returns a TypeReference that can be resolved
(https://github.com/jbevain/cecil/wiki/Resolving) into a
TypeDefinition. That then provides access to the field type's
properties.

Is that what you want?

Fabian

Simon Goldschmidt

unread,
Jul 12, 2012, 3:07:05 AM7/12/12
to mono-...@googlegroups.com
You can get the name and type of the properties you mentioned, but not the actual values. These are assigned at runtime and as you already stated in your other mail, you'll have to iterate all instructions (e.g. in InitializeComponent()) to find out the assigned values if you want to do this with cecil.

Simon
Reply all
Reply to author
Forward
0 new messages