Page MenuHomePhabricator

C#: Create wrapper type with indexers for properties with keys
Closed, InvalidPublic

Description

C# properties using key parameters could use indexers [1] for both getting and setting the property values instead of value tuples. Value tuples should be used only when there are actual multiple values to be set/retrieved.

var someVal = obj.SomeProperty[key];
obj.SomeProperty[key] = someNewVal;

This could be done by creating a new "property wrapper type" that has only the indexers made public.

[1] https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/indexers/using-indexers

lauromoura triaged this task as Normal priority.

And for multi-value keys:

var someVal = obj.SomeProperty[(keyA, keyB)];
obj.SomeProperty[(keyA, keyB)] = someNewVal;
lauromoura moved this task from Backlog to InProgress on the efl: language bindings board.
lauromoura raised the priority of this task from Normal to High.Dec 18 2019, 2:35 PM

D10791 takes care of this?

jptiz closed this task as Invalid.Feb 10 2020, 1:07 PM
jptiz added a subscriber: jptiz.

Indexers have been reverted as not good practices for our use-cases (as stated in D11114).