[CSHARP-4077] Support Range (..) operator Created: 24/Feb/22 Updated: 24/Feb/22 Resolved: 24/Feb/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | LINQ3 |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Unknown |
| Reporter: | James Kovacs | Assignee: | James Kovacs |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
C#8 introduced support for ranges using ... For example:
The array bounds can also be computed:
We would have to support new overloads for collection methods that take Range parameters. More details on the syntax can be found here: |
| Comments |
| Comment by James Kovacs [ 24/Feb/22 ] | ||
|
Turns out the C# compiler does not permit the Index and Range operators in expression trees. Including x.SomeArray[^1] or x.SomeArray[1..^1] in a LINQ expression results in the following compiler errors. The same errors occur if you assign the expression to Expression<T>. Unfortunately this syntax is not permitted even using C# 10 and .NET 6.
|