mercredi 11 mars 2020

Distinguish between getter-only property and expression body property?

Is it possible, using reflection, to distinguish between a getter-only property and an expression body property?

For example, how could the method below be completed?

enum PropertyKind
{
    NotInteresting,

    GetterOnly,

    ExpressionBody,
}

PropertyKind GetPropertyKind(PropertyInfo propertyInfo)
{
    if (propertyInfo.GetSetMethod(true) == null)
    {
        // what goes here??
    }

    return PropertyKind.NotInteresting;
}

Related post: What is the difference between getter-only auto properties and expression body properties?





Aucun commentaire:

Enregistrer un commentaire