title: Is there a way to have CodeDom put using statements before the namespace
body: <p>The msdn documentation says add namespaces imports to the CodeNamespace.Imports collection. This puts them inside the namespace (which makes sense, since your adding them to the namespace)</p>
  
  <pre><code>namespace Foo
  {
    using Bar;
  
    //Code
  }
  </code></pre>
  
  <p>However the rest of our code base has using statements outside the namespace:</p>
  
  <pre><code>using Bar;
  
  namespace Foo
  {
    //Code
  }
  </code></pre>
  
  <p>Is there a clean way to get CodeDom to emit the second version?</p>
  
  <p>Edit: the code to produce the first example looks something like this:</p>
  
  <pre><code>CodeNamespace ns = new CodeNamespace("Foo");
  ns.Imports.Add(new CodenamespaceImport("Bar"));
  CodeCompileUnit cu = new CodeCompileUnit();
  cu.Namespaces.Add(ns);
  new CSharpCodeProvider().GenerateCodeFromCompileUnit(cu, Console.Out, null);
  </code></pre>