protected internal

Is there any particular reason why there is no protected internal access modifier

Robert



Answer this question

protected internal

  • Armin Zamani

    There is no particular reason except that domain-domain (meta-meta) model and code-generator are relatively old - they're being reworked in one of the following releases of DSL Tools and in current builds set of access modifiers includes "protected internal" as well. So basically this is a bug in the current implementation.

    Here's the updated list of access modifiers (on a member) from new domain-domain model schema definition:

    Public
    Assembly
    Private
    Family
    FamilyOrAssembly
    FamilyAndAssembly

    (this will probably be filtered for C# as it doesn't support FamilyAndAssembly one).

    Regards,



  • rpress

    C# supports FamilyOrAssembly which corresponds to "protected internal". C# does not support FamilyAndAssembly modifier (besides IL, C++ is the only language I know which supports it). I.e.:

    C#:
    Public -> public
    Assembly -> internal
    Private -> private
    Family -> protected
    FamilyOrAssembly -> protected internal
    FamilyAndAssembly -> ups...

    C++:
    Public -> public:
    Assembly -> public private:
    Private -> private:
    Family -> protected:
    FamilyOrAssembly -> public protected:
    FamilyAndAssembly -> protected private:

    With regards to DSL Tools - we will support all modifiers supported by CLR at the domain-domain model level and from UI (DSL designer) you will be able to use all modifiers supported by the target language (C# in our case). So to sum up - protected internal will be supported for C#.

    In general, you can place any available access modifier on a class (public/internal in C#) and then place any modifiers on its members - i.e. have an internal class with protected member is fine - none will be visible outside of you assembly.

    Regards,



  • Ron123456789

    I'm not quite sure what you mean Dmitriy. Are you saying that "protected internal" will not be made part of the C# language

    I presume that "protected internal" referrs to FamilyAndAssembly, or

    I need the protected internal access modifier for a class having a protected field. The type of this field cannot be declared internal because of the protected access modifier. One solution is to make the class public and then use the desired access modifier on fields, proporties and functions. The class will then be exposed externally by will not contain anything. A public interface could also be use.

    I really don't like any of the above solutions, but while the "protected internal" access modifier is missing, it seems like the way to do it.


  • protected internal