icsharpcode / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
2.09k stars 773 forks source link

C# CC not working after LINQ orderby clause #583

Open siegfriedpammer opened 10 years ago

siegfriedpammer commented 10 years ago

see http://community.sharpdevelop.net/forums/t/21879.aspx

following example program: using System; using System.Linq;

namespace Test
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var result = from a in args where a.Length > 0 orderby a.Length select a;

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

. pressing a after orderby opens CC, but the list does not contain a.

Rpinski commented 10 years ago

Analysis so far: CSharpCompletionEngineBase.ParseStub(): parser.Parse() returns a proper syntax tree in case of "where" or "select":

class Stub
{
    public static void Main (string[] args)
    {
        Console.WriteLine ("Hello World!");
        var result = from a in args
        where a.Length > 0
        orderby a.Length > 0
        select aa;
    }
}

But in case of "orderby" a tree with only the method head (but not the body) seems to be returned:

class Stub
{
    public static void Main (string[] args);
}