Right, it's likely the methods and fields collections will be in the order they were defined (but as you said, this could change), but you won't know if a field has be defined in between two methods.
Jb On Mon, Nov 3, 2014 at 10:40 AM, Greg Young <[email protected]> wrote: > So you can somewhat get it with the current c# compiler but it's not assured > to stay that way in the future nor does it work for other compilers. > > Source is the only reliable way to get it. Roslyn makes this relatively > painless > > > On Monday, November 3, 2014, Jb Evain <[email protected]> wrote: >> >> Hi, >> >> That information is not persisted in the assembly or in the debug >> symbols. So you're out of luck using Cecil alone. >> >> The only way to get that information is to have access to the original >> source code, and parse it with a capable parser. I suggest either >> using NRefactory.CSharp or Roslyn for C#. >> >> Jb >> >> >> On Mon, Nov 3, 2014 at 3:02 AM, vexe <[email protected]> wrote: >> > Hi all, >> > >> > so I was wondering if Mono.Cecil has a solution to this problem. Is >> > there >> > something like typeDef.GetMembers(Order.Original);? you get my point... >> > >> > If not, I thought I could somehow read the class code, parse it, use >> > regex >> > to get the fields/properties names and just use plain reflection >> > type.GetMember(name) >> > But I'm not sure how to get the class code in a string. Maybe MC could >> > help? >> > ir not.. maybe I could read from the class's file or ...? >> > >> > Please let me know if you know of a better way to do it other than what >> > I >> > mentioned. >> > >> > Any help is appreciated! >> > Cheers! >> > >> > -- >> > -- >> > -- >> > mono-cecil >> > --- >> > You received this message because you are subscribed to the Google >> > Groups >> > "mono-cecil" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > For more options, visit https://groups.google.com/d/optout. >> >> -- >> -- >> -- >> mono-cecil >> --- >> You received this message because you are subscribed to the Google Groups >> "mono-cecil" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. > > > > -- > Studying for the Turing test > > -- > -- > -- > mono-cecil > --- > You received this message because you are subscribed to the Google Groups > "mono-cecil" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
