Some properties are bound like obj in the json file to allow implicit conversion just like we would do in XAML.
E.g. Image.Source can be set as a string or as an ImageSource.
Or GridRowDefinition can be either "*" or GridLength.Star
Same with View.Margin
But when using such types, IntelliSense only shows that the property is obj.
Developers don't know about the implicit conversions (if they didn't check the samples) and must look into the documentation of Xamarin.Forms to know what type exactly is allowed.
Wouldn't changing those obj to discriminated unions be better?
It would make typing explicit to developers, while allowing the compiler to check if there's nothing funny going on.
And cherry on top, converters would output warnings if we're missing a case (which is not the case currently with type matching)
What do you think?
I think F# should have type-tagged union types (string|ImageSource) (erased to obj). I am hoping we can add those in F# 5.0, partly driven by exactly this question
That would be great!
Is it something that will come in the foreseeable future (e.g. ~6 months)?
Or should we do something in the meantime and replace later once out?
I think it will take longer,. maybe a year to see through to all relevant tooling. I feel using "obj" is likely ok for now, as people nearly always do view elements via cut-and-paste snippets, but I know it's not ideal.
Closing due to #341
Most helpful comment
I think F# should have type-tagged union types
(string|ImageSource)(erased toobj). I am hoping we can add those in F# 5.0, partly driven by exactly this question