aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2015-08-06 14:29:34 +0100
committerGravatar Jon Skeet <jonskeet@google.com>2015-08-08 07:25:28 +0100
commit6f300442bc0e5eced5f48820bcd5f24fce9e3867 (patch)
tree26b97843db46795208b7da0568b0d23ec3fc1f8e /csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
parentcac45313235bd11b08e0803453a2ec5a7d4b652a (diff)
Tidying up - fix a bunch of TODOs and remove outdated ones.
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs')
-rw-r--r--csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs12
1 files changed, 5 insertions, 7 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
index 851efc26..de92fbc1 100644
--- a/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
@@ -46,8 +46,8 @@ namespace Google.Protobuf.Reflection
// and proto2 vs proto3 for non-message types, as proto3 doesn't support "full" presence detection or default
// values.
- private readonly Action<object, object> setValueDelegate;
- private readonly Action<object> clearDelegate;
+ private readonly Action<IMessage, object> setValueDelegate;
+ private readonly Action<IMessage> clearDelegate;
internal SingleFieldAccessor(PropertyInfo property, FieldDescriptor descriptor) : base(property, descriptor)
{
@@ -55,12 +55,10 @@ namespace Google.Protobuf.Reflection
{
throw new ArgumentException("Not all required properties/methods available");
}
- setValueDelegate = ReflectionUtil.CreateActionObjectObject(property.GetSetMethod());
+ setValueDelegate = ReflectionUtil.CreateActionIMessageObject(property.GetSetMethod());
var clrType = property.PropertyType;
- // TODO: What should clear on a oneof member do? Clear the oneof?
-
// TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.)
object defaultValue =
typeof(IMessage).IsAssignableFrom(clrType) ? null
@@ -70,12 +68,12 @@ namespace Google.Protobuf.Reflection
clearDelegate = message => SetValue(message, defaultValue);
}
- public override void Clear(object message)
+ public override void Clear(IMessage message)
{
clearDelegate(message);
}
- public override void SetValue(object message, object value)
+ public override void SetValue(IMessage message, object value)
{
setValueDelegate(message, value);
}