lundi 9 avril 2018

Get properties returning a constant value

I am trying to obtain all properties from a class returning constant values through reflection. I have seen this to be working for const fields, obviously, but not for properties.

Is there a way to determine if a property is actually returning a constant value?

Sample:

public class Foo
{
    public string Bar {get;set;} // should not be returned
    public string Baz => "hello there"; // SHOULD be returned
}

Any effort so far failed. I tried to call GetConstantValue() on the property, but that throws an exception.





Aucun commentaire:

Enregistrer un commentaire