Custom renders of nuGet Package conflict in Xamarin.forms -


i'm making app using xamarin.forms. (pcl)

i noticed serious problem of using custom renderer. came thread. https://forums.xamarin.com/discussion/54317/new-xamarin-forms-guide-custom-renderers/p2

this thread says, , experienced 1 renderer class works @ same time. means if 2 different package use same renderer, 1 of them not work. (it follows class hierarchy. subclassed class work , other stop working)

package added might break original package or mine, , real problem developer might not notice @ time.

why how works? or, not correct or did mistake?

  • example

if made custom renderer contentpage , installed package has custom renderer contentpage or page. in case, keyboardoverlap.forms.plugin does. , both renderer class overrided onapearing(). when run app. 1 renderer's onapearing fired.

of course can hand merge that. if both of them nuget package , can not modify them. (of course can use github's cause problem)

each custom renderer should have unique name. way you'll collisions if renderer overriding base class... never that, instead should inherit default , make sure call base when override.

if nuget package broken because they're overriding default, have tell them fix it.

in code you're referring to, author overriding page instead of making own keyboardoverlappage

this line causing pain!

instead should be

[assembly: exportrenderer (typeof(keyboardoverlappage), typeof(keyboardoverlaprenderer))] 

and have class in pcl

public class keyboardoverlappage : xamarin.forms.page {} 

in other words, author has poorly implemented package , should fix it. once fixed, can use wherever want functionality in place of page.

if there no custom renderer on specific platform, automagically fall default behaviour.


Comments