Skip to content

Instantly share code, notes, and snippets.

@ianwaldrop
Last active August 29, 2015 14:03
Show Gist options
  • Save ianwaldrop/c498e6202780ca2b3fda to your computer and use it in GitHub Desktop.
Save ianwaldrop/c498e6202780ca2b3fda to your computer and use it in GitHub Desktop.
Get Properties with Attribute
var props = t.GetProperties().Where(
prop => Attribute.IsDefined(prop, typeof(T)));
@ianwaldrop
Copy link
Author

http://stackoverflow.com/questions/2281972/how-to-get-a-list-of-properties-with-a-given-attribute

This avoids having to materialize any attribute instances (i.e. it is cheaper than GetCustomAttributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment