Commit bf4f6c54 authored by Sydney Acksman's avatar Sydney Acksman

Make extension reflection helper use GetOrRegisterExtension

parent 9163a6f1
......@@ -97,6 +97,20 @@ namespace Google.Protobuf.Reflection
Assert.AreEqual(message.GetExtension(OptionalBoolExtension), Proto2.TestAllExtensions.Descriptor.FindFieldByNumber(OptionalBoolExtension.FieldNumber).Accessor.GetValue(message));
}
[Test]
public void GetRepeatedExtensionValue()
{
// check to make sure repeated accessor uses GetOrRegister
var message = new Proto2.TestAllExtensions();
Assert.IsNull(message.GetExtension(RepeatedBoolExtension));
Assert.IsNotNull(Proto2.TestAllExtensions.Descriptor.FindFieldByNumber(RepeatedBoolExtension.FieldNumber).Accessor.GetValue(message));
Assert.IsNotNull(message.GetExtension(RepeatedBoolExtension));
message.ClearExtension(RepeatedBoolExtension);
Assert.IsNull(message.GetExtension(RepeatedBoolExtension));
}
[Test]
public void Clear()
{
......
......@@ -230,7 +230,7 @@ namespace Google.Protobuf.Reflection
}
else if (extension is RepeatedExtension<T1, T3>)
{
return extensionMessage.GetExtension(extension as RepeatedExtension<T1, T3>);
return extensionMessage.GetOrRegisterExtension(extension as RepeatedExtension<T1, T3>);
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment