Add ValueConversionAttribute
sa-he opened this issue · comments
Is it possible to add the ValueConversionAttribute
to the converters? AFAIK it is only available in net full framework and netcore so compiler-ifs would be required.
I could send a pull request if you agree.
Ok. Can you maybe prepare a minimal PR so I can see how you’d add it - and how you’d use it? Is there a concrete use-case for these annotations? You cannot add it to generic classes, right?
No, generic types cannot be used in attributes. This is why I suggest to add the attribute to all child classes instead of base classes.
Use-case?
A. It helps consumers of the lib to understand the input and outcome of the converter.
B. We have developed the idea of cascading converters (#12) in a less intrusive way. Meaning that existing converters do not need to have a reference to a 'PreviousConverter'. This implementation relies on the ValueConversionAttribute and is used like this:
<conv:ValueConverterGroup x:Key="Int32ToInvertedVisibility"> <!-- Add any IValueConverter that is decorated with ValueConvertionAttribute --> <conv:Int32ToBoolean /> <conv:BoolInverter /> <conv:BooleanToVisibility /> </conv:ValueConverterGroup>
I would provide a PR if you are intrested. Otherwise adding the ValueConvertionAttribute to your converters allows us to place them inside our ValueConverterGroup
.