Page MenuHomePhabricator

csharp: Skip non-public members from interfaces
ClosedPublic

Authored by lauromoura on Aug 30 2019, 9:01 AM.

Details

Summary

Eolian allows non-public members in interfaces and mixins (usually
@protected). As both kinds are converted to C# interfaces, this
causes problem as non-public members are forbidden in C# interfaces.

This commit changes eolian_mono by removing those members from the C#
interfaces. If a generated class implements the interface, the method is
generated as if it were a protected member of the class directly.

For mixed properties like Efl.Io.Reader.CanRead { get; set @protected; },
the interface has only the public getter and the the implementing class has both
the public getter and the protected setter.

With this, C# devs won't be able to directly implement protected Eo
methods from interfaces. (But this really does not make sense from the
C# point of view).

ref T7494

Diff Detail

Repository
rEFL core/efl
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
lauromoura created this revision.Aug 30 2019, 9:01 AM
lauromoura requested review of this revision.Aug 30 2019, 9:01 AM

Replace direct GetPart usage by getting it through reflection.

lauromoura edited the summary of this revision. (Show Details)Aug 30 2019, 12:37 PM
segfaultxavi requested changes to this revision.Sep 2 2019, 1:16 AM

protected methods have been removed from interfaces, but they wrapper properties still exist. They should be removed too, right?

Also, when protected methods from an interface are added to a class, they appear as public. Shouldn't they be protected?
I'm talking about virtual public bool GetEnable(); in efl_ui_panel.eo.cs. This method in inherited from @property enable @protected in efl_ui_focus_layer.eo.

This revision now requires changes to proceed.Sep 2 2019, 1:16 AM

protected methods have been removed from interfaces, but they wrapper properties still exist. They should be removed too, right?

Nice catch. Will remove them and add a reflection test on the Dummy.TestIface using reflection to make sure they do not appear.

Also, when protected methods from an interface are added to a class, they appear as public. Shouldn't they be protected?
I'm talking about virtual public bool GetEnable(); in efl_ui_panel.eo.cs. This method in inherited from @property enable @protected in efl_ui_focus_layer.eo.

Yeah, they should be protected.

lauromoura updated this revision to Diff 24730.Sep 3 2019, 6:44 PM

Update by fixing property accessor generation.

Added a test with partially protected property (public get, protected set) to Dummy.Test_IFace

lauromoura edited the summary of this revision. (Show Details)Sep 3 2019, 6:46 PM
lauromoura updated this revision to Diff 24732.Sep 3 2019, 7:12 PM

Fix code skipping doc reference conversion for property accessors.

Not it seems good to go :)

segfaultxavi resigned from this revision.Sep 4 2019, 3:25 AM

I have no further complains, everything looks fine to me. Somebody else review the implementation!

YOhoho accepted this revision.Sep 4 2019, 3:31 AM

Looks good to me. thank you for this patch.

This revision is now accepted and ready to land.Sep 4 2019, 3:31 AM
lauromoura planned changes to this revision.Sep 5 2019, 3:46 PM

Need to change this after D9752 lands.

lauromoura updated this revision to Diff 24818.Sep 6 2019, 8:47 AM

Update after applying D9752.

Needed to add a method that expands the class own functions with the non public interfaces methods that it would have to implement.

This is needed to property registrer the wrappers in these methods while keeping the size reduction of the mentioned patch.

This revision is now accepted and ready to land.Sep 6 2019, 8:47 AM
YOhoho accepted this revision.Sep 9 2019, 10:29 PM
This revision was automatically updated to reflect the committed changes.