mercredi 29 juin 2016

Using nameof to get name of current method

Have browsed, searched and hoped but cannot find a straight answer.

Is there anyway in C# 6.0 to get the current method name using nameof withouth specifying the method name?

I am adding my test results to a dictionary like this:

Results.Add(nameof(Process_AddingTwoConsents_ThreeExpectedRowsAreWrittenToStream), result);

I would prefer if I would not have to specify the method name explicitly so I can copy+paste the line, a non-working example:

Results.Add(nameof(this.GetExecutingMethod()), result);

If possible I do not want to use Reflection.





Aucun commentaire:

Enregistrer un commentaire