dotnet / dotnet/csharpstandard
12.17.3.1 Query expressions aren't always method invocations
- Dominant language
- C#
- Stars
- 815
- Forks
- 99
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 16
Description
Current text:
> The C# language does not specify the execution semantics of query expressions. Rather, query expressions are translated into invocations of methods that adhere to the query expression pattern (§13.17.4). Specifically, query expressions are translated into invocations of methods named Where, Select, SelectMany, Join, GroupJoin, OrderBy, OrderByDescending, ThenBy, ThenByDescending, GroupBy, and Cast.
While it's _expected_ that they would be method names, they don't have to be. Bizarre example, selecting from a type via a static property called `Select`:
``` csharp
using System;
class OddType
{
public static Func, string> Select
{
get { return ignored => "result!"; }
}
}
class Program
{
static void Main()
{
string result = from t in OddType select t * 2;
Console.WriteLine(result);
}
}
```
The compiler doesn't care about this at all. Worth tweaking the description?
(We should look for "method" everywhere within 13.17 - it comes up in a few places.)
Contributor guide
Assessment
This issue has not been assessed yet.