public void PropertyInheritanceAndAttributes()
{
{
// Case 1:
/// the virtual/override case works nearly as it should (must use static methods on Attribute class).
Assert.That( typeof( PB ).GetProperty( "PropAVirtual" ).GetCustomAttributes( typeof( PropNOTInheritedAttribute ), inherit: true ).Count() == 0,
"OK: PropNOTInherited is not available on B.PropAVirtual" );
Assert.That( typeof( PB ).GetProperty( "PropA" ).GetCustomAttributes( typeof( PropInheritedAttribute ), inherit: true ).Count() == 0,
"KO! PropInheritedAttribute is ALSO NOT available on B.PropAVirtual. PropertyInfo.GetCustomAttributes does NOT honor bool inherit parameter :-(." );
// To get it, one must use static methods on Attribute class.
// REVIEW: statics methods an Attribute does no longer exists.
// Assert.That( Attribute.GetCustomAttributes( typeof( PB ).GetProperty( "PropAVirtual" ), typeof( PropNOTInheritedAttribute ), inherit: true ).Length == 0,
// "OK: PropNOTInherited is not available on B.PropAVirtual" );
// Assert.That( Attribute.GetCustomAttributes( typeof( PB ).GetProperty( "PropAVirtual" ), typeof( PropInheritedAttribute ), inherit: true ).Length == 1,
// "OK! It works as it should!" );
}
{
// Case 2:
// Inheritance does not not work for Masked properties.
// REVIEW: statics methods an Attribute does no longer exists.
// Assert.That( Attribute.GetCustomAttributes( typeof( PB ).GetProperty( "PropA" ), typeof( PropInheritedAttribute ), inherit: true ).Length == 0,
// "No attribute inheritance here, a Masked property is a 'new' property :-)" );
}
}