dotnet / dotnet/dotnet-api-docs

System.Linq doc snippets (\dotnet-api-docs\snippets\csharp\System.Linq

Open
#10,110 1 comment 0 reactions 0 assignees View on GitHub
area-System.Linq Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

1. the [LINQ docs C# samples](https://github.com/dotnet/dotnet-api-docs/tree/main/snippets/csharp/System.Linq) consist of 7 projects to showcase **IEnumerable** and **IQueryable**
unfortunately much code unnecessarily invokes **AsQueryable()** despite simpler **IEnumerable** method implementations existing
[thus such guidance is poor as such **AsQueryable()** overhead can be avoided]
2. should update to useful modern C# v12 semantics [Primary constructors, Collection expressions, Span, is, etc]
3. calls being made to default parameterless ctor then assigning individual properties, rather than using parameterised ctors explicitly [or better yet primary constructor]
4. current analyzers also disclose numerous Warnings/Messages, emphasising poor guidance for today's coding
5. many cases of wastefully using Any(),Count(),LongCount etc when optimal coding available (e.g. Count, Length for Collections).
6. spurious ToString() call in [OrderByIComparer()](https://github.com/dotnet/dotnet-api-docs/blob/main/snippets/csharp/System.Linq/Enumerable/AggregateTSource/enumerable.cs#L1828)

I will shortly submit a PR to explain problems & my suggestions.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.