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

Issue: Implicitly conversion from a non-nullable value type to the nullable form of that value type is broken? #188

Closed
yyjdelete opened this issue Jul 26, 2018 · 5 comments

Comments

@yyjdelete
Copy link
Contributor

yyjdelete commented Jul 26, 2018

See https://github.com/StefH/System.Linq.Dynamic.Core/wiki/Dynamic-Expressions#conversions
Or I misused this in an not proper way?

Hit this issue with debug an query issue with efcore when eval at local, and it's able to write an reproduct case without efcore. Tested with 1.0.8.11

        public class ConsumptionWithDateLite
        {
            public DayOfWeek? DayOfWeek { get; set; }
        }

                var a1 = Enumerable.Repeat(0, 100)
                    .Select((d, i) => new DateTime(2000, 1, 1).AddDays(i))
                    .AsQueryable()
                    //.Select("new (DayOfWeek)")
                    .Select<ConsumptionWithDateLite>("new (DayOfWeek)");

                var z1 = a1.ToList();
                System.Diagnostics.Debug.Assert(!z1.Any(zx => zx.DayOfWeek == null));

Update: This get null on netcoreapp, and an System.Security.VerificationException:“操作可能会破坏运行时稳定性。”(Operation may break runtime stability) on netfx

@StefH
Copy link
Collaborator

StefH commented Jul 26, 2018

Can you please post a full project example for dotnet core / normal .net ?

@yyjdelete
Copy link
Contributor Author

@StefH
https://github.com/yyjdelete/DynamicLinqTestCast
dotnet run -f net45 or dotnet run -f netcoreapp2.1, or you can retarget to other installed TargetFrameworks.

StefH added a commit that referenced this issue Jul 26, 2018
@StefH
Copy link
Collaborator

StefH commented Jul 26, 2018

Thanks.

I'm able to reproduce and I've fixed it. Now I need to add some unit-tests.

You can already take a look here:
https://github.com/StefH/DynamicLinqTestCast/tree/test_issue_188
+
https://github.com/StefH/System.Linq.Dynamic.Core/tree/issue_188

@yyjdelete
Copy link
Contributor Author

👍

@StefH
Copy link
Collaborator

StefH commented Jul 27, 2018

I'll create a new NuGet in some time.

@StefH StefH closed this as completed Jul 27, 2018
@StefH StefH changed the title Implicitly conversion from a non-nullable value type to the nullable form of that value type is broken? Issue: Implicitly conversion from a non-nullable value type to the nullable form of that value type is broken? Jul 27, 2018
StefH added a commit that referenced this issue Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants