title: Reflection: inconsistent framework behavior with GetRuntimeProperty methods
body: <p>When playing around with reflection in the new .NET Framework 4.5, I encountered a strange behavior that I found quite unexpected. The namespace System.Reflection provides some new extension methods for exploiting Type objects. Two of those are GetRuntimeProperty(string name) and GetRuntimeProperties().</p>
  
  <p>Now imagine that you have a simple object with an internal property.</p>
  
  <pre><code>public class ObjectBase
  {
      protected int Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>And you now try to exploit this type.</p>
  
  <pre><code>var properties = typeof(ObjectBase).GetRuntimeProperties();
  // properties.Count = 2
  
  var idProperty = typeof(ObjectBase).GetRuntimeProperty("Id");
  var nameProperty = typeof(ObjectBase).GetRuntimeProperty("Name");
  // idProperty = null
  // nameProperty = System.String Name
  </code></pre>
  
  <p>As expected the <code>properties</code> object holds two property definition for the Id and Name property defintions and the nameProperty holds the Name property definition. What was not expected was the <code>idProperty</code> object to be null...</p>
  
  <p>Coming from the .NET Framework, I guess this was intended by Microsoft architects but I must say it does not seem like something you would really expect to happen. I do believe such similar methods should behave the same but it seems that GetRuntimeProperty filters on public properties where GetRuntimeProperties apply no filters.</p>
  
  <p><strong>Does anybody have a reasonable explanation on why do Microsoft decided that those similar methods should have different behaviors? A design error?</strong></p>
  
  <p>Thanks.</p>