Browse Source

Fix for GetProperty(string, Type[]) incompatible with Silverlight

csharptest 13 years ago
parent
commit
3cf3315370

+ 3 - 3
src/ProtocolBuffers/FieldAccess/RepeatedPrimitiveAccessor.cs

@@ -66,9 +66,9 @@ namespace Google.ProtocolBuffers.FieldAccess
 
 
         internal RepeatedPrimitiveAccessor(string name)
         internal RepeatedPrimitiveAccessor(string name)
         {
         {
-            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name + "List", ReflectionUtil.EmptyTypes);
-            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name + "List", ReflectionUtil.EmptyTypes);
-            PropertyInfo countProperty = typeof(TMessage).GetProperty(name + "Count", ReflectionUtil.EmptyTypes);
+            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name + "List");
+            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name + "List");
+            PropertyInfo countProperty = typeof(TMessage).GetProperty(name + "Count");
             MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, EmptyTypes);
             MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, EmptyTypes);
             getElementMethod = typeof(TMessage).GetMethod("Get" + name, new Type[] {typeof(int)});
             getElementMethod = typeof(TMessage).GetMethod("Get" + name, new Type[] {typeof(int)});
             clrType = getElementMethod.ReturnType;
             clrType = getElementMethod.ReturnType;

+ 4 - 8
src/ProtocolBuffers/FieldAccess/SinglePrimitiveAccessor.cs

@@ -58,14 +58,10 @@ namespace Google.ProtocolBuffers.FieldAccess
 
 
         internal SinglePrimitiveAccessor(string name)
         internal SinglePrimitiveAccessor(string name)
         {
         {
-            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name, ReflectionUtil.EmptyTypes);
-            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name, ReflectionUtil.EmptyTypes);
-            if (builderProperty == null)
-            {
-                builderProperty = typeof(TBuilder).GetProperty(name, ReflectionUtil.EmptyTypes);
-            }
-            PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name, ReflectionUtil.EmptyTypes);
-            MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name, ReflectionUtil.EmptyTypes);
+            PropertyInfo messageProperty = typeof(TMessage).GetProperty(name, null, ReflectionUtil.EmptyTypes);
+            PropertyInfo builderProperty = typeof(TBuilder).GetProperty(name, null, ReflectionUtil.EmptyTypes);
+            PropertyInfo hasProperty = typeof(TMessage).GetProperty("Has" + name);
+            MethodInfo clearMethod = typeof(TBuilder).GetMethod("Clear" + name);
             if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null)
             if (messageProperty == null || builderProperty == null || hasProperty == null || clearMethod == null)
             {
             {
                 throw new ArgumentException("Not all required properties/methods available");
                 throw new ArgumentException("Not all required properties/methods available");