dotnet / dotnet/csharpstandard
LINQ: Select Clause
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
In [11.18.3.6 Select clauses](https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#111836-select-clauses) the spec says that
```csharp
from c in customers.Where(c => c.City == "London")
select c
```
is translated to
```csharp
(customers).Where(c => c.City == "London")
```
But the current reference implementation translates it to (ignoring delegate caching and extension method expansion):
```csharp
customers.Where(c => c.City == "London").Select(c => c)
```
-> The `Select` call is not omitted
Only for queries like:
```csharp
from c in customers
where c.City == "London"
select c
```
the `Select` call is omitted.
Is this a spec or roslyn bug?
---
To make it work, compilers would need to analyze invocation expressions and "expand" the original Linq query first - which is not done in roslyn.
Contributor guide
Assessment
This issue has not been assessed yet.