-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: new() expression cannot handle complex types #206
Comments
Will be proposing a PR when I find some time, just posting here for the record. |
StefH
changed the title
new() expression cannot handle complex types
Issue: new() expression cannot handle complex types
Oct 16, 2018
Thanks for the PR. Can you also add a new unit-test to test this specific issue? |
Tests fail; related to the test DTO classes, these should be normal classes, not nested in a test class. |
NuGet 1.0.9 is added. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, the new() expression can be used to instantiate know types, such as:
query = query.select("new MyNamespace.MyClass(value1 as prop1, value2 as prop2)");
ExpressionParser.cs is not able to properly handle complex types, such as generics or classes nested inside other classes, i.e.
query = query.select("new MyNamespace.MyClass+MySubClass(value1 as prop1, value2 as prop2)");
The parser is properly extracting the full namespace and class name, it just fails to properly detect the type in it's FindType() method. I really don't understand why the implementation of such a method is so convoluted, but following the current philosophy of the method, this is the patch that will allow new() to parse nested class names:
To properly support generics though some extra work needs to be done, as it will only consider dot and plus as valid tokens in a class name:
while (_textParser.CurrentToken.Id == TokenId.Dot || _textParser.CurrentToken.Id == TokenId.Plus)
The text was updated successfully, but these errors were encountered: