title: How to implement synchronous Task-returning method without warning CS1998?
body: <p>Take for example the following interface:</p>
  
  <pre><code>interface IOracle
  {
      Task&lt;string&gt; GetAnswerAsync(string question);
  }
  </code></pre>
  
  <p>Some implementations of this interface might use <code>async</code>/<code>await</code>. Others might not need to. For example, consider this simple toy implementation.</p>
  
  <pre><code>class SimpleOracle
  {
      public Dictionary&lt;string, string&gt; Lookup { get; set; }
  
      // Warning CS1998: This async method lacks 'await' operators
      // and will run synchonously.
      public async Task&lt;string&gt; GetAnswerAsync(string question)
      {
          string answer = Lookup[question];
          return answer;
      }
  }
  </code></pre>
  
  <p>The compiler warning CS1998 of course makes sense. The usual suggestion is to <a href="https://stackoverflow.com/q/13243975/1828879">remove the <code>async</code> keyword and use <code>Task.FromResult</code></a>, but it misses a subtle issue.  What if the code throws an exception? Then that code transform changes the behavior of the method: the <code>async</code> version will wrap any exception in a <code>Task</code>; the non-<code>async</code> version will not, without an explict <code>try</code>-<code>catch</code>.</p>
  
  <p>Leaving the <code>async</code> keyword works exactly as I want, but it produces a compiler warning, and I don't think suppressing those is wise.</p>
  
  <p>How should I refactor my method implementation to not produce a compiler warning while also wrapping all exceptions with <code>Task</code> as any other <code>async</code> method would?</p>