Howdy.
Does anyone know how to write an ExpressionHelper.GetName method so I can get the name of a public static/const property or field using Reflection and C# 3.0
So for
static class B
{
public const string Field = "mittens";
public static string Prop = "the kitten";
}
The following asserts would work (the syntax is obviously not going to work)
Assert.AreEqual(ExpressionHelper.GetName(B.Field),"Field");
Assert.AreEqual(ExpressionHelper.GetName(B.Prop),"Prop");
The important thing is for compile time errors to appear when someone changes these fields/props.
Thanks!