title: Method that does conditional return of method calling it?
body: <p>Ok this might be a bit of hack but bear with me :)  The background is that i'm tired of methods that that some if-statement to that messes up indention for the whole method, like:</p>
  
  <pre><code>public SomeClass DoStuff(string inputStr)
  {
    SomeClass result =null;
    if (IsOpenFilter(inputStr))
    {
      ....
    }
  
    return result;
  }
  </code></pre>
  
  <p>So I was thinking , wouldn't it be neat if I could do something like this instead:</p>
  
  <pre><code>public SomeClass DoStuff(string inputStr)
  {
    Require(IsOpenFilter(inputStr),null);
  
  
    ....
  
    return result;
  }
  </code></pre>
  
  <p>This case might be covered by code contracts in some form, if so please correct me :)</p>
  
  <p>The idea is that if the statement does not evaluates to true it would return null. If there wasn't a return type for the method it would simply be:       Require(IsOpenFilter(inputStr));</p>
  
  <p>So I guess there's two questions, can this be done somehow? I'm stumped on how to do a conditional return from calling a method.</p>
  
  <p>The other question is, is this a good idea? It's a bit weird to monkeypatch the language like this but I'd rather like the way the code reads. I would be even cleaner if it could be put into an attribute above the method: [Require(IsOpenFilter(inputStr))]</p>