You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a factory method for KeyValuePair utilizing type inference #4779
api-needs-workAPI needs work before it is approved, it is NOT ready for implementationarea-System.RuntimeenhancementProduct code improvement that does NOT require public API changes/additions
The Tuple.Create() is a generic factory method that works by type inference making it much slicker to create tuples than using the Tuple<,>-constructor.
I propose a similar implementation pattern for the KeyValuePair<,> type. Hence something a long the lines of
public static class KeyValuePair
{
public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(TKey key, TValue value)
{
return new KeyValuePair<TKey, TValue>(key, value);
}
}
api-needs-workAPI needs work before it is approved, it is NOT ready for implementationarea-System.RuntimeenhancementProduct code improvement that does NOT require public API changes/additions
Activity
RedwoodForest commentedon Dec 11, 2015
dotnet/roslyn#35 would add type inference to constructors so you wouldn't need the factory method.
joperezr commentedon Jul 1, 2020
In order to consider this we need an actual Api Proposal so we can move it forward.
kbilsted commentedon Jul 6, 2020
@joperezr thanks for getting back.
What is it you need more than the above explanation? Do I need to fill out a template? The code above is the whole code to include
joperezr commentedon Jul 6, 2020
first of all sorry it took so long to look at this, it got missed somehow. Usually ApiProposals have the following template: https://github.com/dotnet/runtime/blob/master/.github/ISSUE_TEMPLATE/02_api_proposal.md.
Here is a good set of steps we have with good examples of how a good API proposal looks like as well as what is the general process of it: https://github.com/dotnet/runtime/blob/master/docs/project/api-review-process.md#steps
Let me know if you have any questions around it.
GrabYourPitchforks commentedon Apr 15, 2021
Is this obviated by the C# target typed new feature?
stephentoub commentedon Apr 16, 2021
This API exists now:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.keyvaluepair.create?view=net-5.0