Proposal: Support QuickInfo and GotoDefinition in LINQ query syntax #23394
Labels
Area-IDE
Feature Specification
Resolution-Fixed
The bug has been fixed and/or the requested behavior has been implemented
Milestone
Implementation started #23049 (This proposal is extracted from the discussion there. Remarks by @sharwell are incorporated)
Objective: Enhance the support for GotoDefinition and QuickInfo for LINQ query syntax by exposing the underlying transformations (QuickInfo and GotoDefinition are already working for a limited set of clauses. This proposal describes a coherent behavior for all clauses and transformations).
As a general guidance for the proposal I tried to stay close to the query expressions section of the C# spec. That means quick info should show the actual method mapping after all the transformations are completed.
Some general rules:
These clauses map directly to method calls (bold are the clauses that show quick info).
from l2 in l1
where true
group l1 by l.Item1 into g
join n in numbers on l1 equals n into g
select l1
let v=true
select v
from T l2 in l1
Degenerated methods
e.g.
from i in l
where true
select i
Quick info for
select
shows "This clause isn't mapped to an method call due to optimizations." or nothing at all. Goto definition is not available.select clause preceded by a join clause and other similar clauses
e.g.
from x1 in e1
join x2 in e2 on k1 equals k2
select v
Quick info for
select
shows "This clause isn't mapped to an method call due to optimizations." or nothing at all. Goto definition is not available.orderby clause
Quick info and goto definition are available for parameters with an corresponding
orderby
,ascending
ordescending
clause. If noascending
ordescending
clause is present thenlet clause
Quick info reveals some transformation internals here (See also Transparent identifiers below). On the one hand side this is a bad thing because it unveils some intermediate types that are not really useful for the end user. But on the other side it illustrates that the let clause is nothing but a fancy select. (I do remember searching for a
Let
extension method onEnumerable
when I usedlet
for the first time.) Quick info would lighten up what is going on under the hood.Explicit range variable types (see cases 7, 8 and 9)
Explicit range variable are translated into a call to
Cast
. The mapping to the Cast method interferes with other mappings. The following table shows how the Cast method is mapped to thein
clause in overlapping cases:from
clause is not mapped to another method and the Cast can be mappedfrom T i2 in i1
from
clause is mapped to SelectMany and thein
token is used to show the mapping to Castjoin T i2 in l2 on i1 equals i2
in
Transparent identifiers
Transparent identifiers are leaking through. While the names of the transparent identifiers are not revealed they leave traces as there are anonymous types visible in quick info and so the end user gets a glimpse at the magic that is going on. In the (slightly altered) sample from the spec:
The anonymous type a { int[] i1, int i2 } returned from SelectMany is visible in quick info on several occasions:
Implementation status
Test coverage C# Quick info
Test coverage C# Goto definition
Status VB:
No proposal, implementation and tests. Support for VB should be addressed in a follow up proposal.
The text was updated successfully, but these errors were encountered: