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

Linq.Queryable.FirstOrDefault doesn't work when using TrimMode=link #41392

Closed
rolfbjarne opened this issue Aug 26, 2020 · 3 comments
Closed

Linq.Queryable.FirstOrDefault doesn't work when using TrimMode=link #41392

rolfbjarne opened this issue Aug 26, 2020 · 3 comments
Labels
area-System.Linq.Expressions linkable-framework Issues associated with delivering a linker friendly framework
Milestone

Comments

@rolfbjarne
Copy link
Member

Repro:
consoleapp-99c9d68.zip

Run make linked to run with TrimMode=link, and make notlinked to run the same command, except without setting TrimMode.

$ make linked
** Executing linked app
bin/Debug/netcoreapp5.0/osx-x64/publish/myproject
❌ failed: System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Linq.EnumerableRewriter.FindEnumerableMethod(String name, ReadOnlyCollection`1 args, Type[] typeArgs)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.EnumerableExecutor`1.Execute()
   at System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute[TElement](Expression expression)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
   at App.Main() in /Users/rolf/test/dotnet/consoleapp/Program.cs:line 19

$ make notlinked
** Executing notlinked app
bin/Debug/netcoreapp5.0/osx-x64/publish/myproject
✅ succeeded: hello hello
$ dotnet --version
5.0.100-rc.1.20426.3
$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.15.6
BuildVersion:	19G73

CC @marek-safar

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Linq.Expressions untriaged New issue has not been triaged by the area owner labels Aug 26, 2020
@ghost
Copy link

ghost commented Aug 26, 2020

Tagging subscribers to this area: @cston
See info in area-owners.md if you want to be subscribed.

@marek-safar marek-safar added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 26, 2020
@marek-safar
Copy link
Contributor

/cc @eerhardt

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Aug 26, 2020
… issue in .NET

Ref: dotnet/runtime#41392

Fixes this link sdk test failure:

    LinkSdk.LinkSdkRegressionTest
        [FAIL] AsQueryable_Enumerable : System.NullReferenceException : Object reference not set to an instance of an object
            at System.Linq.EnumerableRewriter.FindEnumerableMethod(String name, ReadOnlyCollection`1 args, Type[] typeArgs)
            at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
            at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
            at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
            at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes)
            at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
            at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
            at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
            at System.Linq.EnumerableExecutor`1[[System.Linq.IGrouping`2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].Execute()
            at System.Linq.EnumerableQuery`1[[System.Linq.IGrouping`2[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Linq, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].System.Linq.IQueryProvider.Execute[IGrouping`2](Expression expression)
            at System.Linq.Queryable.FirstOrDefault[IGrouping`2](IQueryable`1 source)
            at LinkSdk.LinkSdkRegressionTest.AsQueryable_Enumerable() in /Users/rolf/work/maccore/whatever/xamarin-macios/tests/linker/ios/link sdk/LinkSdkRegressionTest.cs:line 1100
            at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
@eerhardt eerhardt added this to the 6.0.0 milestone Aug 26, 2020
@eerhardt eerhardt removed the untriaged New issue has not been triaged by the area owner label Aug 26, 2020
@eerhardt
Copy link
Member

eerhardt commented Nov 9, 2020

This was fixed in 5.0 by #42603.

@eerhardt eerhardt closed this as completed Nov 9, 2020
@eerhardt eerhardt modified the milestones: 6.0.0, 5.0.0 Nov 9, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Linq.Expressions linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

No branches or pull requests

4 participants