Skip to content
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

ParseException when using dotnet trimmer with TrimMode=full #678

Closed
tranb3r opened this issue Mar 2, 2023 · 5 comments
Closed

ParseException when using dotnet trimmer with TrimMode=full #678

tranb3r opened this issue Mar 2, 2023 · 5 comments
Assignees
Labels

Comments

@tranb3r
Copy link

tranb3r commented Mar 2, 2023

1. Description

I'm using DynamicExpressionParser.ParseLambda in a dotnet console application.
The expression I'm parsing is pretty simple, and it involves comparing an integer and a byte.
It's working just as expected, unless I'm using the dotnet trimmer in full mode, in which case it's raising a ParseException.
I've already tried to root assembly System.Linq.Dynamic.Core for the trimmer, but it doesn't fix the issue.
Could you please help me find a solution?

2. Exception

System.Linq.Dynamic.Core.Exceptions.ParseException
Operator '==' incompatible with operand types 'Byte' and 'Int32'
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.CheckAndPromoteOperands(Type, TokenId, String, Expression&, Expression&, Int32)
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseComparisonOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLogicalAndOrOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseIn()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseAndOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseOrOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseLambdaOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseNullCoalescingOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.ParseConditionalOperator()
   at System.Linq.Dynamic.Core.Parser.ExpressionParser.Parse(Type , Boolean )
   at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(Type, ParsingConfig, Boolean, ParameterExpression[] , Type, String , Object[] )
   at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda(ParsingConfig , Boolean, ParameterExpression[], Type , String, Object[] )
   at System.Linq.Dynamic.Core.DynamicExpressionParser.ParseLambda[T,TResult](ParsingConfig, Boolean, String , Object[] )
   at SldcTrimmer.LambdaExtensions.ParseLambda[T1,T2](String) in D:\Dev\Zitch\Issues\SldcTrimmer\SldcTrimmer\LambdaExtensions.cs:line 10
   at SldcTrimmer.Program.Main(String[]) in D:\Dev\Zitch\Issues\SldcTrimmer\SldcTrimmer\Program.cs:line 14

3. Fiddle or Project

Here is a repro: https://github.com/tranb3r/Issues/tree/main/SldcTrimmer
Try first launching the app from VS, in debug or release: no issue.
Then, publish the app. It will run the trimmer. Then run the published SldcTrimmer.exe: it fails.

4. Any further technical details

Here is a warning that is shown when publishing the app.
Assembly 'System.Linq.Dynamic.Core' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries.
But I have no idea how I can get more information and investigate more.

@StefH
Copy link
Collaborator

StefH commented Mar 3, 2023

Hello @tranb3r,
Thanks for the detailed description, I'll need some time to investigate. When I've a result or questions, I'll report back.

@StefH StefH self-assigned this Mar 3, 2023
@StefH StefH added the question label Mar 3, 2023
@tranb3r
Copy link
Author

tranb3r commented Jan 24, 2024

Just for information, I can workaround this exception by adding to my app these attributes when calling SLDC:

[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Linq.Dynamic.Core.Parser.SupportedOperands.IArithmeticSignatures", "System.Linq.Dynamic.Core")]
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Linq.Dynamic.Core.Parser.SupportedOperands.ILogicalSignatures", "System.Linq.Dynamic.Core")]

@StefH
Copy link
Collaborator

StefH commented Aug 21, 2024

@tranb3r
This specific error will be solved by #839, however I do not know if there are more issues.

Did you encounter any other problems while trimming?

@tranb3r
Copy link
Author

tranb3r commented Aug 26, 2024

Did you encounter any other problems while trimming?

@StefH
Thanks for the fix.
This is the only issue I encountered with System.Linq.Dynamic.Core while trimming.

@StefH StefH closed this as completed Aug 26, 2024
@tranb3r
Copy link
Author

tranb3r commented Oct 14, 2024

@StefH
I've just tested my sample with System.Linq.Dynamic.Core 1.4.6.
The issue is still here.
Could you please reopen this issue?
Thanks.

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

No branches or pull requests

2 participants