@@ -960,6 +960,12 @@ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, o
960960 public Dictionary < string , object > Properties { get { return _properties ; } }
961961
962962 public string NonDynamicProperty { get ; set ; }
963+
964+ protected string NonDynamicProtectedProperty { get ; set ; } = "Default value" ;
965+
966+ protected static string NonDynamicProtectedStaticProperty { get ; set ; } = "Default value" ;
967+
968+ protected string NonDynamicProtectedField = "Default value" ;
963969 }
964970
965971 public class TestPerson : IComparable , IComparable < TestPerson >
@@ -1265,6 +1271,37 @@ def SetValue(self, fixture):
12651271 }
12661272 }
12671273
1274+ [ TestCase ( "NonDynamicProtectedProperty" ) ]
1275+ [ TestCase ( "NonDynamicProtectedField" ) ]
1276+ [ TestCase ( "NonDynamicProtectedStaticProperty" ) ]
1277+ public void TestSetPublicNonDynamicObjectProtectedPropertyToActualPropertyWorks ( string attributeName )
1278+ {
1279+ var expected = "Non Dynamic Protected Property" ;
1280+ dynamic model = PyModule . FromString ( "module" , $@ "
1281+ from clr import AddReference
1282+ AddReference(""Python.EmbeddingTest"")
1283+ AddReference(""System"")
1284+
1285+ from datetime import datetime
1286+ import System
1287+ from Python.EmbeddingTest import *
1288+
1289+ class RandomTestDynamicClass(TestPropertyAccess.DynamicFixture):
1290+ def SetValue(self):
1291+ self.{ attributeName } = ""{ expected } ""
1292+ " ) . GetAttr ( "RandomTestDynamicClass" ) . Invoke ( ) ;
1293+
1294+ using ( Py . GIL ( ) )
1295+ {
1296+ Assert . AreNotEqual ( expected , model . GetAttr ( attributeName ) . As < string > ( ) ) ;
1297+
1298+ model . SetValue ( ) ;
1299+
1300+ Assert . AreEqual ( expected , model . GetAttr ( attributeName ) . As < string > ( ) ) ;
1301+ Assert . IsFalse ( model . Properties . ContainsKey ( attributeName ) . As < bool > ( ) ) ;
1302+ }
1303+ }
1304+
12681305 [ Explicit ]
12691306 [ TestCase ( true , TestName = "CSharpGetPropertyPerformance" ) ]
12701307 [ TestCase ( false , TestName = "PythonGetPropertyPerformance" ) ]
0 commit comments