I'm creating a custom attribute in C#.
So I have something like this:
[AttributeUsage(AttributeTargets.Property)] public class Something : Attribute { public Something { Assembly a = Assembly.GetCallingAssembly(); } } The code above will give me the assembly name of the assembly where the attribute is being called from.
What I would like to know is if there is a way to get the name and type of the property to which the attribute was added. So as an example if I had:
// This should return System.Int32 and MyString [Something] public int MyInt {get; set;} // This should return me System.String, and MyString [Something] public string MyString {get; set;} Is there any way to get those values upon adding the attribute, or will I have to resort to looping trough all the properties in the type and see which ones have an attribute assigned to them?
Thanks in advance.