title: Why do extension methods not work with namespace aliasing?
body: <p>This may be an ignorant question, but I'm unsure why I can not use namespace aliasing and extension methods together.</p>
  
  <p>The following example works just fine:</p>
  
  <p><strong>Program.cs</strong></p>
  
  <pre><code>using System;
  using ExtensionMethodTest.Domain;
  
  namespace ExtensionMethodTest
  {
      class Program
      {
          static void Main(string[] args)
          {
              var m = new Domain.MyClass();
              var result = m.UpperCaseName();
          }
      }
  }
  </code></pre>
  
  <p><strong>MyClass.cs</strong></p>
  
  <pre><code>using System;
  
  namespace ExtensionMethodTest.Domain
  {
      public class MyClass
      {
          public string Name { get; set; }
      }
  }
  </code></pre>
  
  <p><strong>MyClassExtensions.cs</strong></p>
  
  <pre><code>using System;
  
  namespace ExtensionMethodTest.Domain
  {
      public static class MyClassExtensions
      {
          public static string UpperCaseName (this MyClass myClass)
          {
              return myClass.Name.ToUpper();
          }
      }
  }
  </code></pre>
  
  <p>However, when I alias domain as follows in Program.cs:</p>
  
  <pre><code>using Domain = ExtensionMethodTest.Domain;
  </code></pre>
  
  <p>The extension method no longer works..</p>
  
  <p>This can be rather frustrating when I'm dealing with converting various domain objects to contract objects (let's say I have 4 domain assemblies and 4 contract assemblies) for use in a web service. Using aliasing would be very handy as I could alias as follows and continue to use the various extension methods (such as ToContract, etc.):</p>
  
  <pre><code>using BillingContracts = Namespace.Billing.Contracts;
  using IssuingContracts = Namespace.Issuing.Contracts;
  </code></pre>
  
  <p>etc...</p>
  
  <p>I look forward to the answer.. I'm sure it's straight forward, but I, for the life of me, can't figure out why it doesn't work.</p>
  
  <p>Thanks!</p>