title: System.Attribute.GetCustomAttribute in .NET Core
body: <p>I'm trying to convert the following method (which works fine in .NET Framework 4.6.2) to .NET Core 1.1.</p>
  
  <pre><code>public static TAttribute GetCustomAttribute&lt;TAttribute&gt;(MemberInfo member) where TAttribute : Attribute
  {
      var attr = System.Attribute.GetCustomAttribute(member, typeof(TAttribute));
      if (attr is TAttribute)
         return attr;
      else
         return null;
  }
  </code></pre>
  
  <p>This code is giving me the error </p>
  
  <blockquote>
    <p>Attribute does not contain a definition for GetCustomAttribute.</p>
  </blockquote>
  
  <p>Any idea what the .NET Core equivalent of this should be?</p>
  
  <p>P.S. I tried the following but it seems to throw an exception. Not sure what the exception is because it just stops the app all together. I tried putting the code in a <code>try catch</code> block but still it just stops running so I couldn't capture the exception.</p>
  
  <pre><code>public static TAttribute GetCustomAttribute&lt;TAttribute&gt;(MemberInfo member) where TAttribute : Attribute
  {
     var attr = GetCustomAttribute&lt;TAttribute&gt;(member);
     if (attr is TAttribute)
        return attr;
     else
        return null;
  }
  </code></pre>