This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 33d769e93602461a85b98cf60f211f4a9543ea98
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:34:40 2026 -0600
eolian_mono: a C# application can override a property now
Since 2020 it could not. 595cb754b3 made the accessors behind a
generated property internal, which keeps them out of the public surface,
and also means only this assembly could ever override one. The property
itself is not virtual, so there was no second route: from outside,
`internal override GetDuration` is CS0115 and `public override Duration`
is CS0506.
Protected says what was meant. Hidden from anyone using the class,
available to anyone deriving from it, which is the distinction internal
cannot draw. It also has to be the accessor rather than the property:
the native wrapper calls the accessor, so making the property virtual
instead would have let an override compile and never be called.
Nothing in the generated binding objects: the wrapper's cast is to the
class its NativeMethods is nested in, so protected access holds, and no
hand-written C# in the tree calls an accessor of another class. The
accessors of a @protected property are now IsFamily rather than
IsAssembly, which is closer to what @protected means in the .eo file.
EoInherit01.cs is corrected too: it said to override a public SetNumber,
which was not true.
This widens the C# API of every generated class: the accessors become
visible to, and overridable by, any subclass outside the binding.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/bin/eolian_mono/eolian/mono/function_definition.hh | 9 +++++++--
src/examples/efl_mono/EoInherit01.cs | 14 ++++++++------
src/tests/efl_mono/Eo.cs | 14 ++++++++------
src/tests/efl_mono/Inheritance.cs | 6 +++---
4 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index 975335f4eb..a5aecfcbad 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -227,14 +227,19 @@ struct function_definition_generator
});
if (it != properties.end())
{
+ // The property is the API: its accessor is hidden from users of the
+ // class, but a subclass overrides it, as the native wrapper calls the
+ // accessor and not the property.
+ std::string const accessor_scope = f.is_static ? "internal " : "protected ";
+
if (it->getter && *it->getter == f)
{
if (property_generate_wrapper_getter (*it, context))
- function_scope = "internal ";
+ function_scope = accessor_scope;
}
else
if (property_generate_wrapper_setter (*it, context))
- function_scope = "internal ";
+ function_scope = accessor_scope;
}
// Do not generate static function for concrete class
diff --git a/src/examples/efl_mono/EoInherit01.cs b/src/examples/efl_mono/EoInherit01.cs
index b9913e8693..22db93674b 100644
--- a/src/examples/efl_mono/EoInherit01.cs
+++ b/src/examples/efl_mono/EoInherit01.cs
@@ -23,7 +23,9 @@ class PlusTenNumberWrapper : Example.Numberwrapper
public bool derivedCalled = false;
- override public void SetNumber(int n)
+ // The property's accessor, not the property: Number is a plain C# property
+ // that calls this, and this is what EFL calls too.
+ protected override void SetNumber(int n)
{
// Call native EFL method
base.SetNumber(n + 10);
@@ -50,16 +52,16 @@ public class ExampleEoInherit01
WriteLine($"Override successfully called? {inheritObj.derivedCalled}!\n");
// Call C function from C# object
- int stored = inheritObj.GetNumber();
+ int stored = inheritObj.Number;
WriteLine($"Given value: {given}");
WriteLine($"Stored value: {stored}\n");
// Call C# override directly
given = 333;
- inheritObj.SetNumber(given);
+ inheritObj.Number = given;
- stored = inheritObj.GetNumber();
+ stored = inheritObj.Number;
WriteLine($"Given value: {given}");
WriteLine($"Stored value: {stored}\n");
@@ -69,8 +71,8 @@ public class ExampleEoInherit01
// Check original EFL object
var origObj = new Example.Numberwrapper();
given = 111;
- origObj.SetNumber(given);
- stored = origObj.GetNumber();
+ origObj.Number = given;
+ stored = origObj.Number;
WriteLine($"Given value: {given}");
WriteLine($"Stored value: {stored}\n");
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index f827215770..7ef1f9125d 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -736,16 +736,18 @@ class TestProtectedInterfaceMembers
{
var type = typeof(Dummy.TestObject);
- // Fully internal property
- var internal_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsAssembly);
- Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetProtectedProp"));
- Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetProtectedProp"));
+ // The accessor behind a property is protected, not internal: out of the
+ // public surface because the property is the API, still reachable by a
+ // class deriving from this one, which is what lets it be overridden.
+ var protected_methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(m => m.IsFamily);
+ Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "GetProtectedProp"));
+ Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetProtectedProp"));
// Partially protected property
var public_methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
Test.AssertNull(public_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
- Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
- Test.AssertNotNull(internal_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter"));
+ Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "GetPublicGetterPrivateSetter"));
+ Test.AssertNotNull(protected_methods.SingleOrDefault(m => m.Name == "SetPublicGetterPrivateSetter"));
var protected_properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);
var prop = protected_properties.SingleOrDefault(m => m.Name == "ProtectedProp");
diff --git a/src/tests/efl_mono/Inheritance.cs b/src/tests/efl_mono/Inheritance.cs
index 996443f569..8507c7c7b8 100644
--- a/src/tests/efl_mono/Inheritance.cs
+++ b/src/tests/efl_mono/Inheritance.cs
@@ -97,18 +97,18 @@ class TestInheritance
// through a different line of the generated wrapper.
internal class InheritProperties : Dummy.TestObject
{
- internal override int GetIntProp()
+ protected override int GetIntProp()
{
return 42;
}
- internal override void GetMultiValuedProp(out int prop1, out int prop2)
+ protected override void GetMultiValuedProp(out int prop1, out int prop2)
{
prop1 = 7;
prop2 = 9;
}
- internal override Eina.SuccessFlag GetReturnTypeGetProp(out int i)
+ protected override Eina.SuccessFlag GetReturnTypeGetProp(out int i)
{
i = 11;
return (Eina.SuccessFlag)(char)1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.