[Proposal][Generic] Inference item type in collection #76516
Unanswered
MickaelThumerel
asked this question in
Ideas
Replies: 1 comment
-
Proposal for language goes to https://github.com/dotnet/csharplang/discussions . This repo is for compiler implementation. There are already proposals to improve type inference like dotnet/csharplang#7467 . |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Proposition: Allow collection item type decomposition during inference
In C# to improve readability generic value are often automatically detected by the system "Inference of type"
Example:
A Method:
Usage:
Issues:
In the following example you find a 2 generics parameters one in the collection type the other represent the item in this collection.
The problem is that if type's interference doesn't solved all the parameter then you need to write manually all of them.
Resulting :
It's heavy to ready.
A solution exist, using kind of placeholder parameter to ensure the resolution:
Resulting of a usage :
Could introduce miss comprehension and possible bug to have a null value inject this way.
Proposition:
Enhance inference to be able to decompose SIMPLE identified .net type like, IEnumerable, IReadOnlyCollection, IReadOnlyDictionary, Span ...
Resulting:
Beta Was this translation helpful? Give feedback.
All reactions