Author: gbayon
Date: Sun Oct 22 09:53:18 2006
New Revision: 466855

URL: http://svn.apache.org/viewvc?view=rev&rev=466855
Log:
- Corrected MethodAccessException in emitted code, reported by Finn Nielsen

Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertySetAccessor.cs

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs?view=diff&rev=466855&r1=466854&r2=466855
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
 Sun Oct 22 09:53:18 2006
@@ -235,6 +235,24 @@
         }
 
 #if dotnet2
+
+        /// <summary>
+        /// Test getter access to Public Generic Property
+        /// </summary>
+        [Test]
+        public void TestPublicGetterOnGenericProperty2()
+        {
+            IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(SpecialReference<Account>), "Value");
+
+            SpecialReference<Account> referenceAccount = new 
SpecialReference<Account>();
+            Account account = new Account(5);
+            referenceAccount.Value = account;
+
+            Account acc = accessorGet.Get(referenceAccount) as Account;
+            Assert.AreEqual(referenceAccount.Value, acc);
+            Assert.AreEqual(referenceAccount.Value.Id, acc.Id);
+        }
+        
         /// <summary>
         /// Test getter access to Public Generic Property
         /// </summary>
@@ -272,6 +290,22 @@
         }
 
         /// <summary>
+        /// Test setter access to Public Generic Property
+        /// </summary>
+        [Test]
+        public void TestPublicSetterOnGenericVariable2()
+        {
+            ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(SpecialReference<Account>), "Value");
+
+            SpecialReference<Account> referenceAccount = new 
SpecialReference<Account>();
+            Account account = new Account(5);
+            accessorSet.Set(referenceAccount, account);
+
+            Assert.AreEqual(account, referenceAccount.Value);
+            Assert.AreEqual(account.Id, referenceAccount.Value.Id);
+        }
+
+        /// <summary>
         /// Test getter access to private Generic Property
         /// </summary>
         [Test]
@@ -290,6 +324,23 @@
         }
 
         /// <summary>
+        /// Test getter access to private Generic Property
+        /// </summary>
+        [Test]
+        public void TestPrivateGetterOnGenericProperty2()
+        {
+            IGetAccessor accessorGet = 
factoryGet.CreateGetAccessor(typeof(SpecialReference<Account>), "_value");
+
+            SpecialReference<Account> referenceAccount = new 
SpecialReference<Account>();
+            Account account = new Account(5);
+            referenceAccount.Value = account;
+
+            Account acc = accessorGet.Get(referenceAccount) as Account;
+            Assert.AreEqual(referenceAccount.Value, acc);
+            Assert.AreEqual(referenceAccount.Value.Id, acc.Id);
+        }
+        
+        /// <summary>
         /// Test setter access to Public Generic Property
         /// </summary>
         [Test]
@@ -305,6 +356,22 @@
 
             Assert.AreEqual(son.ReferenceAccount, referenceAccount);
             Assert.AreEqual(son.ReferenceAccount.Value.Id, 
referenceAccount.Value.Id);
+        }
+
+        /// <summary>
+        /// Test setter access to Public Generic Property
+        /// </summary>
+        [Test]
+        public void TestPrivateSetterOnGenericVariable2()
+        {
+            ISetAccessor accessorSet = 
factorySet.CreateSetAccessor(typeof(SpecialReference<Account>), "_value");
+
+            SpecialReference<Account> referenceAccount = new 
SpecialReference<Account>();
+            Account account = new Account(5);
+            accessorSet.Set(referenceAccount, account);
+
+            Assert.AreEqual(account, referenceAccount.Value);
+            Assert.AreEqual(account.Id, referenceAccount.Value.Id);
         }
 #endif
     }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs?view=diff&rev=466855&r1=466854&r2=466855
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertyGetAccessor.cs
 Sun Oct 22 09:53:18 2006
@@ -85,7 +85,7 @@
 
                        if (propertyInfo.CanRead)
                                {
-                                       DynamicMethod dynamicMethod = new 
DynamicMethod("GetImplementation", typeof(object), new Type[] { typeof(object) 
}, this.GetType().Module, false);
+                                       DynamicMethod dynamicMethod = new 
DynamicMethod("GetImplementation", typeof(object), new Type[] { typeof(object) 
}, this.GetType().Module, true);
                                        ILGenerator ilgen = 
dynamicMethod.GetILGenerator();
 
                     // Emit the IL for get access. 

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertySetAccessor.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertySetAccessor.cs?view=diff&rev=466855&r1=466854&r2=466855
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertySetAccessor.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common/Utilities/Objects/Members/DelegatePropertySetAccessor.cs
 Sun Oct 22 09:53:18 2006
@@ -52,7 +52,7 @@
         private Type _targetType = null;
 
                 /// <summary>
-        /// Initializes a new instance of the <see 
cref="T:DelegatePropertySetAccessor"/> class
+        /// Initializes a new instance of the <see 
cref="DelegatePropertySetAccessor"/> class
         /// for set property access via DynamicMethod.
         /// </summary>
         /// <param name="targetObjectType">Type of the target object.</param>
@@ -86,7 +86,7 @@
 
                                if (propertyInfo.CanWrite)
                                {
-                                       DynamicMethod dynamicMethod = new 
DynamicMethod("SetImplementation", null, new Type[] { typeof(object), 
typeof(object) }, this.GetType().Module, false);
+                                       DynamicMethod dynamicMethod = new 
DynamicMethod("SetImplementation", null, new Type[] { typeof(object), 
typeof(object) }, this.GetType().Module, true);
                                        ILGenerator ilgen = 
dynamicMethod.GetILGenerator();
                     
                     // Emit the IL for set access. 


Reply via email to