Skip to content

Dynamic queries cannot access internal properties even with InternalsVisibleTo #943

Open

Description

@pirumar

Describe the bug

When using dynamic queries in System.Linq.Dynamic.Core, I am not able to access internal properties of my entity classes.
Even though I added [assembly: InternalsVisibleTo("DynamicLinqTest")] (or the corresponding consuming assembly name), the dynamic parser still throws an error that the property does not exist.


To Reproduce

Steps to reproduce the behavior:

  1. Create a class with an internal property:
    public class MyEntity { internal string InternalProp { get; set; } = "test"; }
  2. Add InternalsVisibleTo to the assembly:
    [assembly: InternalsVisibleTo("DynamicLinqTest")]
  3. Try to query dynamically:
    var query = entities.AsQueryable().Where("InternalProp == \"test\"");
  4. Observe that it fails with:
    No property or field 'InternalProp' exists in type 'MyEntity'

Expected behavior

Dynamic query parser should respect InternalsVisibleTo and allow access to internal properties if visibility has been granted.

Additional context

  • Reflection-based access from the same assembly works fine.
  • The limitation seems to come from the binding logic inside Dynamic.Core not considering internal properties, even with InternalsVisibleTo applied.

Would it be possible to support this scenario, or at least provide an option to enable it?

Activity

  1. pirumar commented on Sep 9, 2025

    @pirumar
    Author

    I added this support, but I can't send it by creating a branch due to permissions.

    Image Image
  2. StefH commented on Sep 9, 2025

    @StefH
    Collaborator

    You need to fork this repository.
    Create a new branch.
    And create a Pull Request from your forked branch to this project.

  3. pirumar commented on Sep 9, 2025

    @pirumar
    Author

    @StefH Sorry, I was distracted, I created the PR correctly.
    Add AllowAccessToNonPublicMembers property to ParsingConfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions