If I understand your question correctly, you already have an instance of the custom attribute MyAttributeInstance, and you want to get CustomAttributeData for the same instance, preferably in one step.
Since you have already found MyAttributeInstance and are tied to a property (or class or ...), I will assume that you have an available property. So this might work for you:
CustomAttributeData CAD = property.GetCustomAttributesData().First(x => x.AttributeType == MyAttributeInstance.GetType());
I think this answers your real question. However, I think your intention was to really ask how to get the CustomAttributeData property from the property directly. In this case, try the following:
CustomAttributeData CAD = property.GetCustomAttributesData().First(x => x.AttributeType == typeof(MyAttribute));
source
share