title: How to prevent an abstract class with public derived classes from being inherited in other assemblies?
body: <p>I want to write something like the following:</p>
  
  <pre><code>    internal class InternalData
      {
      }
  
      public class PublicData
      {
      }
  
      abstract internal class Base {
          internal Base() { }
  
          private static InternalData CreateInternalDataFromPublicData(PublicData publicData)
          {
              throw new NotImplementedException();
          }
  
          abstract protected void DoProcess(InternalData internalData);
  
          public void Process(PublicData publicData)
          {
              InternalData internalData = CreateInternalDataFromPublicData(publicData);
              DoProcess(internalData);
          }
      }
  
      public sealed class Derived : Base
      {
          protected override void DoProcess(InternalData internalData)
          {
              throw new NotImplementedException();
          }
      }
  </code></pre>
  
  <p>That is, <code>Base</code> contains some internal logic and is not intended to be inherited by classes outside of my assembly; and <code>Derived</code> is accessible from the outside.
  <code>InternalData</code> also contains some internal logic and, as it would (and should) never be used from the outside, i also want to make it internal.</p>
  
  <p>Of course the code above won't compile as the <code>Base</code> should not be less accessible than <code>Derived</code>. I can set the <code>Base</code> to be <code>public</code>, that's fine, but it leads to another problem.
  If <code>Base</code> is public, then there could possibly be some <code>ExternalDerived : Base</code> in some other assembly. But <code>Base.DoProcess</code> accepts an <code>InternalData</code> as its argument, so that <code>ExternalDerived</code> cannot implement it (as it doesn't know about the <code>InternalData</code>).
  Internal parameterless <code>Base</code> constructor prevents creation of any <code>ExternalDerived</code> instances, and thus nobody will implement <code>ExternalDerived.DoProcess</code> and no <code>InternalData</code> public exposure is needed, but the compiler doesn't know it.</p>
  
  <p>How can i rewrite the code above so that there will be an abstract <code>DoProcess(InternalData)</code> method and so that <code>InternalData</code> class will be internal?</p>