-
Notifications
You must be signed in to change notification settings - Fork 400
Closed
Labels
Description
Describe the bug
If the PropertyDescriptor
property of the context which is invoking QuantityTypeConverter<T>.ConvertFrom()
is null, it throws a NullReferenceException
.
To Reproduce
var converter = new QuantityTypeConverter<Length>();
// TypeDescriptorContext with null `PropertyDescriptor` property
ITypeDescriptorContext context = new TypeDescriptorContext();
Length length = Length.FromMeters(1);
string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string));
Expected behavior
No exception should be thrown. The conversion should be done as if there were a property with no attributes.
Additional context
In our codebase, this is happening indirectly through the System.Activities.Presentation.WorkflowDesigner.PropertyInspectorView
. Also, the ITypeDescriptorContext.PropertyDescriptor
docs explicitly state that this property "describes the given context item; otherwise, null
if there is no PropertyDescriptor responsible for the call."