Yes, if the variable was passed. In general, it will be possible to get a string representation of the expression passed to the method.
Focusing on the relevant proposal on Github. .
If the method is declared like this:
public static class Debug { public static void Assert(bool condition, [CallerArgumentExpression("condition")] string message = null); }
and is called like this:
Debug.Assert(someBoolean); Debug.Assert(array != null); Debug.Assert(array.Length == 1);
, the compiler will substitute the value of the second argument:
Debug.Assert(someBoolean, "someBoolean"); Debug.Assert(array != null, "array != null"); Debug.Assert(array.Length == 1, "array.Length == 1");