Get & Set property methods show up in System.Reflection.MethodInfo

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

Does anyone know of a way that you can use
System.Reflection.MethodInfo to get a list of methods within a class
and NOT have it show the Get and Set methods of properties?
 
Doug,
Does anyone know of a way that you can use
System.Reflection.MethodInfo to get a list of methods within a class
and NOT have it show the Get and Set methods of properties?

Can't you just manually filter out any methods with names that start
with "get_" or "set_" and has IsSpecialName=true?



Mattias
 
I can, and actually decided to do that, however, with the way things
change, if Microsoft ever changes how they name methods for properties
(i.e. if they switch it from "get_PROPERTYNAME" to "GetPROPERTYNAME"
or even "PROPERTYNAMEGet" or maybe "PROPERTYNAME_Get") then my code is
hosed. It's the lesser of two evils right now but I was hoping for a
better solution if one is out there.
 
It's the lesser of two evils right now but I was hoping for a
better solution if one is out there.

Well you could also get the list of all properties with
Type.GetProperties(), then for each property, remove the getter and
setter methods (PropertyInfo.GetGetMethod()/.GetSetMethod()) from the
set of all methods you get from Type.GetMethods().



Mattias
 
Back
Top