title: nodiscard attribute in C#
body: <p>I'm searching for a way to make it illegal for the user of a method to ignore the returned object/value of a method. In C++, this is possible with the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0068r0.pdf" rel="noreferrer"><code>[[nodiscard]]</code></a> attribute. However, I couldn't find a similar attribute in C#. Is there a standard implementation of such an attribute or a convention on how to achieve this behaviour?</p>
  
  <p>As an example why this may be useful (and where exceptions are <em>not</em> an appropriate way is:</p>
  
  <pre><code>public void foo()
  {
      if (condition)
      {
          DoSomeFinalThing();
          return;
      }
      if (othercondition)
      {
          DoSomeOtherFinalThing();
          // whoops, forgot to return here. Common mistake...
      }
      DefaultAction();
  }
  </code></pre>
  
  <p>Yes, this could also be done with <code>else</code>, but I really dislike a deep nesting in my code.</p>