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

SA1141 warns about ValueTuple.Create in expression trees #3305

Closed
bash opened this issue Feb 23, 2021 · 0 comments · Fixed by #3306
Closed

SA1141 warns about ValueTuple.Create in expression trees #3305

bash opened this issue Feb 23, 2021 · 0 comments · Fixed by #3306
Assignees

Comments

@bash
Copy link

bash commented Feb 23, 2021

LINQ expression trees do not support tuple literals. One workaround is to use ValueTuple.Create in these expression trees but SA1141 disallows that.

My proposed solution is for SA1141 to ignore ValueTuple.Create in expression trees.

Example with error because of restrictions by the C# compiler:

using System;
using System.Linq.Expressions;

Expression<Func<(int, int)>> foo = () => (10, 20);
//                                       ^^^^^^^^ CS8143: An expression tree may not contain a tuple literal.

Example with error because of SA1141:

using System;
using System.Linq.Expressions;

Expression<Func<(int, int)>> foo = () => ValueTuple.Create(10, 20);
//                                       ^^^^^^^^^^^^^^^^^^^^^^^^^ SA1141: Use tuple syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants