<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx</link><description>As John mentioned in his post , every Reflection user should keep this in mind: our code should not count on the member order returned by GetFields, GetMethods and other similar GetXXXs calls. Given two fields (F1, F2) in one type, I think the compiler</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#661174</link><pubDate>Mon, 10 Jul 2006 11:26:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:661174</guid><dc:creator>Jeroen Frijters</dc:creator><description>Hi,&lt;br&gt;&lt;br&gt;While I appreciate (and agree with) this point, it does remind me of the fact that sometimes you need a more accurate window into the metadata and it is unfortunate that Reflection doesn't provide that option. Here are a couple of examples:&lt;br&gt;- For types that have LayoutKind.Sequential, the order of the fields is significant and it would be nice to have a way to return the fields in the right order.&lt;br&gt;- For COM interop method order can be significant, but there is no way to get the methods in declaration order.&lt;br&gt;- In my Java runtime, I would like to have the ability to query what interfaces a type implements *directly* (and in what order), but this is currently not possible.&lt;br&gt;&lt;br&gt;I know that there are low level (unmanaged) metadata APIs, but they are more difficult to use and don't work in conjunction with dynamically generated Ref.Emit code.&lt;br&gt;</description></item><item><title>Reflection : ordre des &amp;amp;#233;l&amp;amp;#233;ments retourn&amp;amp;#233;s par les m&amp;amp;#233;thodes Type.Get*s</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#661288</link><pubDate>Mon, 10 Jul 2006 13:38:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:661288</guid><dc:creator>CoqBlog</dc:creator><description>Haibo Luo nous livre un post int&amp;amp;#233;ressant dans lequel il insiste sur le fait que nous ne pouvons faire...</description></item><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#661924</link><pubDate>Tue, 11 Jul 2006 06:31:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:661924</guid><dc:creator>Haibo_Luo</dc:creator><description>Jeroen - thanks for your comment. I will ask our feature PM to consider whether/how we can support those scenarios.</description></item><item><title>Technical Related Notes  &amp;raquo; Blog Archive   &amp;raquo; links for 2006-07-11</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#677493</link><pubDate>Tue, 25 Jul 2006 06:35:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:677493</guid><dc:creator>Technical Related Notes  » Blog Archive   » links for 2006-07-11</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://technote.thedeveloperside.com/?p=49"&gt;http://technote.thedeveloperside.com/?p=49&lt;/a&gt;</description></item><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#746722</link><pubDate>Fri, 08 Sep 2006 22:40:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746722</guid><dc:creator>João Nóbrega</dc:creator><description>I need to get fields in the correct order and I cant. In the humongus amount of information we can get from reflection I can't understand how FieldInfo definition order was discarded. At leas we should always be able to get the FieldOffsetAttribute out of the FieldInfo object.&lt;br&gt;&lt;br&gt;In answer to Jeroen Frijters, you can get Com members in the correct order using Marshal.GetMethodInfoForComSlot, Marshal.GetStartComSlot and Marshal.GetEndComSlot.&lt;br&gt;&lt;br&gt;Still can't understand how am I going to solve the field order problem though. :)&lt;br&gt;&lt;br&gt;Regards,&lt;br&gt;Jo&amp;#227;o N&amp;#243;brega.</description></item><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#4175190</link><pubDate>Wed, 01 Aug 2007 22:41:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4175190</guid><dc:creator>Joshua Melcon</dc:creator><description>&lt;p&gt;The order of field definitons within classes is important metadata. We are currently using the fixed order returned from C# 1.0 to decide in what order to put some classes into a network stream. &amp;nbsp;Need a method that returns the same order as in 1.0.&lt;/p&gt;
</description></item><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#4201022</link><pubDate>Fri, 03 Aug 2007 09:03:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4201022</guid><dc:creator>Haibo_Luo</dc:creator><description>&lt;p&gt;You may try to get all FieldInfos first, and then sort by MetadataToken. &lt;/p&gt;
</description></item><item><title>re: Member Order Returned by GetFields, GetMethods ...</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#4210009</link><pubDate>Fri, 03 Aug 2007 21:57:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4210009</guid><dc:creator>MarcosMeli_FileHelpers</dc:creator><description>&lt;p&gt;I just found a solution for our open source project&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.filehelpers.com"&gt;http://www.filehelpers.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The best way that I found is to clear the cache of the RunTimeType using reflection to solve another refleciton problem :P&lt;/p&gt;
&lt;p&gt;This is some of the code where mRecordType is the Type to be cleared&lt;/p&gt;
&lt;p&gt;object cache = mRecordType.GetType().GetProperty(&amp;quot;Cache&amp;quot;, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(mRecordType, null); &lt;/p&gt;
&lt;p&gt;cache.GetType().GetField(&amp;quot;m_fieldInfoCache&amp;quot;, BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(cache, null);&lt;/p&gt;
&lt;p&gt;In that way the framework always return the fields in the declaration order, I know that is not a good practice, but is better than the other solutions that I tried with GC or so.&lt;/p&gt;
&lt;p&gt;I only want to ask what permisson I need to run this code ??&lt;/p&gt;
&lt;p&gt;ie. our code has reflection permission, we need some other ??&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;
&lt;p&gt;Marcos&lt;/p&gt;
&lt;p&gt;Open Source developer&lt;/p&gt;
&lt;p&gt;Filehelpers Project&lt;/p&gt;
&lt;p&gt;www.filehelpers.com&lt;/p&gt;
</description></item><item><title>Really simple Business Rule validation using lambdas</title><link>http://blogs.msdn.com/haibo_luo/archive/2006/07/09/661091.aspx#7021068</link><pubDate>Tue, 08 Jan 2008 01:32:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7021068</guid><dc:creator>Flawless Code</dc:creator><description>&lt;p&gt;Really simple Business Rule validation using lambdas&lt;/p&gt;
</description></item></channel></rss>