Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the latest language features to ‘System.Threading.Channels’ #47040

Open
NiubilityOptimus opened this issue Feb 23, 2025 · 4 comments
Open
Assignees
Labels
untriaged Request triage from a team member

Comments

@NiubilityOptimus
Copy link

Even in .NET 9.0, it is still not possible to create var channel = Channel.CreateUnbounded<a ref struct>();. The 13.0 syntax already has where T : allows ref struct.

Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Feb 23, 2025
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@NiubilityOptimus
Copy link
Author

NiubilityOptimus commented Feb 23, 2025 via email

@KalleOlaviNiemitalo
Copy link
Contributor

KalleOlaviNiemitalo commented Feb 23, 2025

This does not look feasible. If T is e.g. Span<int>, then it can point to a stackalloc int[1] in the stack of a thread, and if such a value is written to the channel and later read back from there, then the stack frame may have been freed already. If Channel<T>, ChannelWriter<T>, etc. were ref struct types themselves, then the C# compiler could perhaps detect this ref-safety violation; but they are class types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants