Castle dynamic proxy don't write custom attributes to proxy

c#, castle-dynamicproxy

Solution

Use `Attribute.GetCustomAttributes(...)` instead, the method you're using doesn't work on properties.

Problem

I have simple unit test to reproduce situation: ``` [Test] public void Castle_Writes_Attribute_To_Proxy() { var generator = new ProxyGenerator(); var proxy = generator.CreateClassProxy<MyType>(); var type = proxy.GetType(); var prop = type.GetProperty("SomeProp"); var attrs = prop.GetCustomAttributes(typeof(DescriptionAttribute), true); Assert.That(attrs.Length, Is.Not.EqualTo(0)); } public class MyType { [Description("some description here")] public virtual string SomeProp { get; set; } } ``` Test fails because Castle dynamic proxy don't writes custom attributes, It is possible to write parent attributes to generated proxies? SOLUTION: use `Attribute.GetCustomAttributes(...)` ``` var attrs = Attribute.GetCustomAttributes(prop, typeof(DescriptionAttribute)); ```

Original source