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

Intellisense not suggest properties of type in Lambda Expression #39468

Closed
vsfeedback opened this issue Oct 23, 2019 · 2 comments · Fixed by #39479
Closed

Intellisense not suggest properties of type in Lambda Expression #39468

vsfeedback opened this issue Oct 23, 2019 · 2 comments · Fixed by #39479
Labels
Area-Compilers Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com
Milestone

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


The scenario of the problem is as follows:
I have 3 projects in one solution:
Project 1. EFDAL (C #)
Project 2. EFDAL. Test (C #)
Project 3. EFDALVB (VB)

In the EFDAL project (C #) I have the classes: articulo, marca.

From projects 2 and 3 reference to the EFDAL project.

In project 3 (VB), intellisense does not suggest the properties of the type of entity that is queried in the Lambda expression of the . Include method.
Include <T, TProperty> (IQueryable <T>, Expression <Func <T, TProperty >>)

According to the tests I found that the problem occurs in projects of type Visual Basic. In C# if the intellisense works correctly.

Example C #
var currentArticulo = (from m in DC.articulos.Include(t =&gt; t.marca) where m.codigo == &quot;6463&quot; select m). First();

The property t.marca is suggested correctly

Example VB
Dim currentArt = (From m In DC.articulos.Include(Function(t) t.marca) Where m.codigo = &quot;6463&quot; Select m)

The property t.marca is NOT suggested

I attached video (.gif) and SourceCode.zip with the evidence.

Thank you


Original Comments

Visual Studio Feedback System on 10/17/2019, 10:59 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Visual Studio Feedback System on 10/21/2019, 10:17 AM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.


Original Solutions

(no solutions)

@ivanbasov
Copy link
Contributor

Actually, I do not like both behaviors: C# and VB. They do differently but both with issues. Below are code samples based on the EntityFramework sample provided by the customer in VS Feedback. Each for them (C# and VB) had 4 overloads. Semantic model returns just a single candidate symbol for each: VB - for a string parameter and C# for the custom class parameter.

Imports System.Linq.Expressions

Namespace VBTest
    Public Class SomeItem
        Public A As String
        Public B As Integer
    End Class

    Class SomeCollection(Of T)
        Inherits List(Of T)
        Public Overridable Function Include(path As String) As SomeCollection(Of T)
            Return Nothing
        End Function
    End Class

    Class Extensions
        Public Shared Function Include(Of T, TProperty)(ByVal source As IList(Of T), path As Expression(Of Func(Of T, TProperty))) As IList(Of T)
            Return Nothing
        End Function

        Public Shared Function Include(ByVal source As IList, path As String) As IList
            Return Nothing
        End Function

        Public Shared Function Include(Of T)(ByVal source As IList(Of T), path As String) As IList(Of T)
            Return Nothing
        End Function
    End Class

    Class Program
        Sub M(c As SomeCollection(Of SomeItem))
            Dim a = From m In c.Include(Function(t) t.$$);
        End Sub
    End Class
End Namespace

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ClassLibrary16
{
    class SomeItem
    {
        public string A;
        public int B;
    }
    class SomeCollection<T> : List<T>//, IQueryable<T>
    {
        public SomeCollection(Expression expression, IQueryProvider provider)
        {
            Expression = expression;
            Provider = provider;
        }

        public Expression Expression { get; }

        public Type ElementType => typeof(SomeItem);

        public IQueryProvider Provider { get; }

        public virtual SomeCollection<T> Include(string path) => null;
    }

    static class Extensions
    {
        public static IList<T> Include<T, TProperty>(this IList<T> source, Expression<Func<T, TProperty>> path)
            => null;

        public static IList Include(this IList source, string path) => null;

        public static IList<T> Include<T>(this IList<T> source, string path) => null;
    }

    class Program 
    {
        void M(SomeCollection<SomeItem> c)
        {
            var a = from m in c.Include(t => t.$$);
        }
    }
}

@ivanbasov
Copy link
Contributor

It seems that the problem is with ranking candidate symbols for the specific overloads in the semantic model: it leaves 1 symbol of 4 candidates and the choice is not obvious. Working with @AlekseyTs on original investigations in VB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug Developer Community The issue was originally reported on https://developercommunity.visualstudio.com
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants