Comments
3 comments
-
Hi Ronald,
Thanks for the suggestion. There is a slight ambiguity which worries me about analyzing a single member - if you have a look at System.Windows.Forms.ComboBox.ComboBoxStyle.GetDropdownStyle(); There is a cast in there from an int to a comboboxstyle - it theory this uses every part of the enum although ComboBoxStyle.DropDown is the only one mentioned explicitly in there - would you expect this to be a use of ComboBoxSyle.Simple?
Thanks,
James -
The intention for the requsted analyse method is to find places where specifically one single member (e.g. ComboBoxStyle.Simple) is used and *not* the other members.
Places where all enum members could potentially be used are already sufficiently covered through the analyse method on the enum type.
A small test program shows that even source code likeprivate static ComboBoxStyle Foo() { const int value = 1; return (ComboBoxStyle)value; }
is already disassembled asprivate static ComboBoxStyle Foo() { return ComboBoxStyle.DropDown; }
-
The problem is that enum members aren't really used. They're compiled to integers in code. For example, with this enum:
public enum MyEnum{
Zero, One, Two
}
to assign MyEnum.Two to an MyEnum local variable the following IL is generated:
ldc.i4.2
This doesn't give reflector a specific identifier to search for, it would have to search either for all uses of MyEnum then see if 2 is assigned to it, or vice versa. Obviously this would be very slow.
Add comment
Please sign in to leave a comment.
E.g. go to type System.Windows.Forms.ComboBoxStyle in Browser pane.
Invoke Analyze on the whole type and open the Used By node in Analyzer pane.
There are a lot of uses of the enum, e.g. System.Windows.Forms.ComboBox.OnResize uses ComboBoxStyle.Simple.
Go back to the System.Windows.Forms.ComboBoxStyle type in Browser pane.
Invoke Analyze on the ComboBoxStyle.Simple member and open the Used By node in Analyzer pane.
The Used By node is empty but should show at least System.Windows.Forms.ComboBox.OnResize, or?