Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial class spanning assemblies

In my framework project I have a class that represents tabs in a content management system. In some framewrok implementations it is desirable to extend this class with defintions of tabs that are specific to that implementation. I had though to do this by changing the CmsTabs class to be partial, like this:

namespace Framework
{
/// <summary>
/// Class containing common CMS Tab names
/// </summary>
public static partial class CmsTab
{
    /// <summary>
    /// Information Tab
    /// </summary>
    public const string Information = "Information";

And then creating a class with the same name and namespace in the assembly that implements the framework.

However, when I build the framework assembly, the CmsTabs class appears no longer to be partial - it's members are hidden in the implementing assembly when I add the partial class to that. When disassembled in Reflector, I get this:

public class CmsTab
{...

Is there something I need to do to make it retain its partial status, assuming that it is possible to do what I am trying to do.

Thanks.

like image 684
Jason Avatar asked Dec 20 '10 15:12

Jason


1 Answers

You can't have a partial class span assemblies:

All partial-type definitions meant to be parts of the same type must be defined in the same assembly and the same module (.exe or .dll file). Partial definitions cannot span multiple modules.

MSDN On Partial Classes

like image 112
kemiller2002 Avatar answered Oct 06 '22 01:10

kemiller2002