title: Obtaining original variable name from within an extension method
body: <p>We are currently working on a logging solution and have implemented an extension method call 'Log'. When writing to the log file, we would ideally like to write the original variable name (rather than the variable name used in the extension method). </p>
  
  <p>What we are currently having to do for this is:</p>
  
  <pre><code>public void DoSomeWork()
  {
      String testString = "Hey look I'm a string!";
      testString.Log("testString value");
  }
  </code></pre>
  
  <p>With the extention method:</p>
  
  <pre><code>public static String Log(this String valueToStore, String name)
  {
      // The logging code which uses the 'name' parameter
  }
  </code></pre>
  
  <p>The issue here is that it becomes difficult to read on longer lines of code and looks clustered. What would be ideal is this:</p>
  
  <pre><code>public void DoSomeWork()
  {
      String testString = "Hey look I'm a string!";
      testString.Log();
  }
  </code></pre>
  
  <p>With the extension method:</p>
  
  <pre><code>public static String Log(this String valueToStore)
  {
      // The logging code which is able to retrieve the 
      // value 'testString' from the 'valueToStore' value
  }
  </code></pre>
  
  <p>Is this at all possible by using Reflection? I'm aware of the <code>nameof</code>option, but that only returns the string 'valueToStore' when used in the extension method.</p>