Skip to content

Protected Internal members are not visible in F# with InternalsVisibleTo #1332

@0x53A

Description

@0x53A

protected internal in C# means famorassem, e.g. the visibility is the superset of protected and internal.

Repro steps

Class in C#:

namespace A
{
    public class Class1
    {
        protected static int Protected;
        internal static int Internal;
        protected internal static int ProtectedInternal;
        public static int Public;
    }
}

I added this to the AssemblyInfo.cs

[assembly: InternalsVisibleTo("B")]
[assembly: InternalsVisibleTo("C")]

I then added two additional projects, B (C#) and C (F#).

C#
image

F#
image
(The internal member is visible, so InternalsVisibleTo works in general)

Expected behavior

I would have expected the member ProtectedInternal to be visible.

Actual behavior

Only Internal (and public ofc.) is visible

Please not that this is notjust a tooling issue - when I try to compile the project, I get this error message:

A.Class1.ProtectedInternal <- 5

error FS1097: The struct or class field 'ProtectedInternal' is not accessible from this code location

Known workarounds

I need to modify the C# project and make the member either only internal, so that InternalsVisibleTo works, or make it public.

Related information

Provide any related information

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.Ready

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions