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

Perplexing decompiled expression #135

Open
bradmarder opened this issue Nov 27, 2018 · 0 comments
Open

Perplexing decompiled expression #135

bradmarder opened this issue Nov 27, 2018 · 0 comments

Comments

@bradmarder
Copy link

bradmarder commented Nov 27, 2018

I don't quite understand what is going on with the following decompiled expression.

this => IIF(this.HasBar, this.Posts.Any(x => True), (this.HasBaz AndAlso this.Posts.Any((x => True ?? x => True))))

More specifically, this part is perplexing. this.Posts.Any((x => True ?? x => True))
I'm assuming it should only be this.Posts.Any(x => True)
My basis for this assumption is if you change the || to just |, then it works fine.

When using that expression in conjunction with EFCore/Remotion.LINQ, those libraries fail to parse the expression and throw an exception. I don't know where the actual problem lies. Any help would be appreciated.

Here is the code.

using System;
using System.Collections.Generic;
using System.Linq;
using DelegateDecompiler;

namespace DecompileBug
{
    class Program
    {
        static void Main(string[] args)
        {
            var hasFoo = typeof(Blog)
                .GetProperties()
                .Single(x => x.Name == nameof(Blog.HasFoo))
                .GetMethod
                .Decompile()
                .ToString();

            Console.WriteLine(hasFoo);
            Console.ReadLine();
        }
    }
    public class Post { }
    public class Blog
    {
        public bool HasBar { get; }
        public bool HasBaz { get; }

        public IEnumerable<Post> Posts { get; }

        [Computed]
        public bool HasFoo =>
            (HasBar || HasBaz)
            && Posts.Any(x => true);
    }
}
magicmoux pushed a commit to magicmoux/DelegateDecompiler that referenced this issue Jan 6, 2019
Force DecompilerTestBase to visit decompiled expressions
@magicmoux magicmoux mentioned this issue Jan 6, 2019
magicmoux pushed a commit to magicmoux/DelegateDecompiler that referenced this issue Jun 18, 2019
hazzik added a commit that referenced this issue Aug 9, 2019
hazzik added a commit that referenced this issue Aug 9, 2019
hazzik added a commit that referenced this issue Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant