Skip to content

Documentation: limitations of type usage to accessible types is incorrectly stated #431

Open
@zspitz

Description

@zspitz

From the documentation:

Category Expression Description
Primary x.m Instance field or property access. Any public field or property can be accessed.
Primary x.m(...) Instance method invocation. The method must be public and must be declared in an accessible type.
... ... ...
Primary T.m Static field or static property access. Any public field or property can be accessed.
Primary T.m(...) Static method invocation. The method must be public and must be declared in an accessible type.

This is incorrect:

  • All instance methods are allowed, not just the instance methods on an accessible type
    public class Foo {
        public string TestMethod() => "";
    }
    // runs successfully
    var results = (new List<Foo>()).AsQueryable().Where("TestMethod() = \"\"").ToArray();
  • Like static methods, static fields or properties are only allowed on accessible types; not any public field or property can be accessed
  public static class Bar {
      public readonly static string EmptyString = "";
  }
  // fails: System.Linq.Dynamic.Core.Exceptions.ParseException: 'No property or field 'Bar' exists in type 'String''
  var results = (new List<string>()).AsQueryable().Where("it = Bar.EmptyString").ToArray();

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions