Skip to content

C# does not diagnose InternalsVisibleTo between strong and weak named assembly #26722

@gafter

Description

@gafter

A strong named and weak named assembly cannot be related by InternalsVisibleTo at runtime. For error recovery, the C# compiler permits the access. However, it only produces an error in some very specific scenarios; in most scenarios it produces no diagnostic, but generates code that will fail a runtime access check in the verifier.

VB doesn't have this problem because it doesn't permit the access for error recovery purposes as C# does.

It isn't clear if we can fix this, because you typically don't use the verifier to check the access. In that case the access may "just work" at runtime. Therefore fixing it may break some programs.

See this comment in InternalsVisibleToAndStrongNameTests.cs:

            // TODO: During emit time we should produce an error that says that a strong-named assembly cannot reference
            // TODO: a weak-named assembly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions