title: .net - Howto analyze how many different code paths are in a method
body: <p>Is there a (preferred free) tool that can analyze how many different combinations are possible in a method? I am currently refactoring a method that has many many if/switch statments and I am curious how many possible different execution ways this method had.</p>
  
  <p>Let's say I have a simple method:</p>
  
  <pre><code>public void DoSomething(bool flag1, int value)
  {
  
      if (flag1)
      {
          if (value &gt; 0)
          {
              Console.WriteLine("Flag1 &amp; value &gt; 0");
              return;
          }
          else
          {
              Console.WriteLine("Flag1 &amp; value &lt;= 0");
              return;
          }
      }
      elseif (value &gt; 0 and value &lt; 10)
      {
          Console.WriteLine("Flag1 is false and value between 0 &amp; 10");
          return;
      }
  
      if (value &lt; 0)
      {
          Console.WriteLine("Flag1 = false &amp; value &lt;= 0");
          return;
      }
      elseif(value = 0)
      {
          Console.WriteLine("Flag1 = false &amp; value &gt;= 10");
          return;
      }
  
      Console.WriteLine("nothing else matched");
  
  }
  </code></pre>
  
  <p>there should be 6 possible ways in which the this method could be executed.
  I know there are tools out there that can calculate this number for me (I believe Visual Studio Ultimate can do this but unfortunately I only own a Professional version).</p>
  
  <p>Maybe someone knows a good tool, that can do this.</p>