This question already has an answer here:
I've got following derivations:
interface IMyInterface
{
string myProperty {get;}
}
class MyBaseClass : IMyInterface // Base class is defining myProperty as abstract
{
public abstract string myProperty {get;}
}
class Myclass : MyBaseClass // Base class is defining myProperty as abstract
{
public sealed override string myProperty
{
get { return "value"; }
}
}
I would like to be able to check if a member of a class is declared as sealed. Somewhat like that:
PropertyInfo property = typeof(Myclass).GetProperty("myProperty")
bool isSealed = property.GetMethod.IsSealed; // IsSealed does not exist
Sense of all this is to be able to run a test, that checks the code/project for consistency.
Following test fails:
PropertyInfo property = typeof(Myclass).GetProperty("myProperty")
Assert.IsFalse(property.GetMethod.IsVirtual);
Aucun commentaire:
Enregistrer un commentaire