dotnet / dotnet/csharpstandard

`foreach` expansions, value collections.

Open
#1,720 5 comments 0 reactions 0 assignees View on GitHub
status: needs triaging
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

This is a followup to the issue transferred to dotnet/roslyn#84307

This does uncover questions on how we should describe `foreach`, and how we specify the behavior of identity conversions:

- [ ] Identity conversions and creating a copy: In v3, the language for an identity conversion did not prohibit copying the target. In v5 that language was added, seemingly to prohibit copying a struct. Initial analysis indicates this prohibition is correct. Is there any text on conversions that could be interpreted as allowing a copy for an identity conversion?
- [ ] Should the description of `foreach` make it clear that a value based collection could be mutated? Is that necessary in the normative language?
- [ ] Should we return to 2 expansions of `foreach`? One where the collection type has the necessary public members, and one where the collection type explicitly implements the expected interfaces?

There are a number of forward looking comments here: https://github.com/dotnet/roslyn/issues/84307#issuecomment-4812388292 When we reach the versions where `ref struct` types are allowed to implement some interfaces, we'll need to address some of them.

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked dotnet/roslyn#84307 issue and its referenced forward-looking comments, then compare the current standard wording for foreach expansions and identity conversions. Done means the listed semantic questions are resolved and the affected normative language is updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.