title: Get properties in order of declaration using reflection
body: <p>I need to get all the properties using reflection in the order in which they are declared in the class. According to MSDN the order can not be guaranteed when using <code>GetProperties()</code></p>
  
  <blockquote>
    <p>The GetProperties method does not return properties in a particular
    order, such as alphabetical or declaration order.</p>
  </blockquote>
  
  <p>But I've read that there is a workaround by ordering the properties by the <code>MetadataToken</code>. So my question is, is that safe? I cant seem find any information on MSDN about it. Or is there any other way of solving this problem?</p>
  
  <p>My current implementation looks as follows:</p>
  
  <pre><code>var props = typeof(T)
     .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
     .OrderBy(x =&gt; x.MetadataToken);
  </code></pre>