My test code (below) shows only a single property; therefore I'm
guessing there is something else in your code that you aren't showing
that is causing the problem; can you reproduce with postable code?
Note that the default "Match" / "Equals" implementation for Attribute
tests the fields (instance, public + private) for equality; have you
any fields that might be set? If so you may need to override Equals,
or do somthing different.
Also - in 2.0 this would suit a TypeDescriptionProvider implementation
very nicely; for a related example (ignore the Reflection.Emit stuff)
see
http://www.codeproject.com/csharp/Hy...Descriptor.asp
This essentially allows you to intercept TypeDescriptor at a much
earlier point, allowing you to substitute / filter / append
roperties - in your case substitute would be quite nice.
using System;
using System.ComponentModel;
using System.Diagnostics;
static class Program {
static void Main() {
new TestClass().RunTest();
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false,
Inherited = true)]
public class TestAttribute : Attribute { }
public class TestClass {
public void RunTest() {
Attribute[] attribs = {new TestAttribute()};
foreach (PropertyDescriptor prop in
TypeDescriptor.GetProperties(this, attribs, true)) {
Trace.WriteLine(prop.Name);
}
}
public string Test1 {
get { return "abc"; }
}
[Test]
public string Test2 {
get { return "abc"; }
}
}
}