Page MenuHomePhabricator

csharp: Property Indexer implementation

Authored by felipealmeida on Dec 3 2019, 5:39 PM.



Use Indexers to use brackets, eg [i], syntax.

Keys now can be used as following:

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

And for multiple keys:

var someVal = obj.SomeProperty[(key1, key2)];
obj.SomeProperty[(key1, key2)] = someNewVal;


Diff Detail

rEFL core/efl
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
felipealmeida created this revision.Dec 3 2019, 5:39 PM
felipealmeida requested review of this revision.Dec 3 2019, 5:39 PM

Removed wrong code in patch

This looks pretty cool! Thanks!

jptiz added a comment.EditedDec 4 2019, 12:20 PM

I've got the following compilation error:

src/bindings/mono/efl_core_env.eo.cs(157,31): error CS0542: `Efl.Core.Env.Env': member names cannot be the same as their enclosing type

Also, while talking to @lauromoura, we've come to the idea of using Efl.Core.Env itself as an indexer (instead of having a property), so:

var env = new Env();
var name = env.Env["Name"];

Would become:

var env = new Env();
var name = env["Name"];

How about that?

I've pushed a branch to devs/lauromoura/D10791-indexers with some fixes after rebasing. They will be either merged here or sent as a separate diff.


Shouldn't this declare the indexer set/get so users implementing this class can override it? (Like the concrete one does).

public interface MyIface
	public int this[int x] { get; set;}
lauromoura commandeered this revision.Dec 17 2019, 4:22 PM
lauromoura edited reviewers, added: felipealmeida; removed: lauromoura.
lauromoura updated this revision to Diff 27607.Dec 17 2019, 4:25 PM
  • csharp: Blacklist Efl.Core.Env.Env.
  • csharp: Formatting: remove spaces after '('.
  • csharp: Add missing #include <assert.h>.
  • csharp: Blacklist array properties.
  • csharp: Blacklist all indexed properties from mixins in order to compile.
  • csharp: Fix references to properties.
  • csharp: Use a single list for the rejects.
  • csharp: Unify indexer naming and update visibility
lauromoura updated this revision to Diff 27608.Dec 17 2019, 4:35 PM

Small update (interface declaration must not use full namespaced name)

lauromoura updated this revision to Diff 27629.Dec 18 2019, 6:26 AM

Rebase after test files changed upstream and brought back the setter_only/get_set tests.

felipealmeida commandeered this revision.Dec 19 2019, 5:34 PM
felipealmeida edited reviewers, added: lauromoura; removed: felipealmeida.

Added more tests, workaround mono bug

woohyun accepted this revision.Dec 22 2019, 9:30 PM
This revision is now accepted and ready to land.Dec 22 2019, 9:30 PM
This revision was automatically updated to reflect the committed changes.
YOhoho added a subscriber: YOhoho.Dec 23 2019, 11:13 PM

Since this patch Efl.Ui.CollectionView.PositionManager { set; } and Efl.Ui.Collection.PositionManager { set; } aren't generated..

There's a CA about set only properties.