aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs')
-rw-r--r--csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs15
1 files changed, 5 insertions, 10 deletions
diff --git a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
index d51ee526..22020acf 100644
--- a/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs
@@ -86,8 +86,7 @@ namespace Google.Protobuf.Reflection
/// in a particular message.
/// </summary>
/// <value>
- /// The accessor used for reflective access, or <c>null</c> if reflection is not
- /// supported by this descriptor.
+ /// The accessor used for reflective access.
/// </value>
public OneofAccessor Accessor { get { return accessor; } }
@@ -106,19 +105,15 @@ namespace Google.Protobuf.Reflection
private OneofAccessor CreateAccessor(string clrName)
{
- if (containingType.GeneratedType == null || clrName == null)
- {
- return null;
- }
- var caseProperty = containingType.GeneratedType.GetProperty(clrName + "Case");
+ var caseProperty = containingType.ClrType.GetProperty(clrName + "Case");
if (caseProperty == null)
{
- throw new DescriptorValidationException(this, "Property " + clrName + "Case not found in " + containingType.GeneratedType);
+ throw new DescriptorValidationException(this, $"Property {clrName}Case not found in {containingType.ClrType}");
}
- var clearMethod = containingType.GeneratedType.GetMethod("Clear" + clrName);
+ var clearMethod = containingType.ClrType.GetMethod("Clear" + clrName);
if (clearMethod == null)
{
- throw new DescriptorValidationException(this, "Method Clear" + clrName + " not found in " + containingType.GeneratedType);
+ throw new DescriptorValidationException(this, $"Method Clear{clrName} not found in {containingType.ClrType}");
}
return new OneofAccessor(caseProperty, clearMethod, this);