Skip to content

Dynamic queries cannot access internal properties even with InternalsVisibleTo #943

@pirumar

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?

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