Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Bait and switch Plugins? #49

Open
Cheesebaron opened this issue Jan 14, 2016 · 10 comments
Open

Bait and switch Plugins? #49

Cheesebaron opened this issue Jan 14, 2016 · 10 comments

Comments

@Cheesebaron
Copy link
Member

Would love to not have to have Bootstrap files for each plugins, in a similar fashion that Refit, Splat, ModernHttpClient does.

How to do this is described here:
http://log.paulbetts.org/the-bait-and-switch-pcl-trick/

In short it would mean that Assembly Name, Version and Method structure should be the same in the PCL part of the plugin and the platform part.

So as an example if we take the PictureChooser Plugin the structure would be something like:

PictureChooser.nuspec  
    portable-net45+win+wpa81+wp80/
        MvvmCross.PictureChooser.dll     // PCL Version
    net45/
        MvvmCross.PictureChooser.dll     // WPF Bitmap Loader
    Xamarin.iOS10/
        MvvmCross.PictureChooser.dll     // UIKit Bitmap Loader
    MonoAndroid/
        MvvmCross.PictureChooser.dll     // Android Bitmap Loader
    ... more here ...

So the PCL would contain a class like this:

public class Derp
{
    public void Herp(string derrr)
    {
        throw new NotImplementedException();
    }
}

And a Platform specific one:

public class Derp
{
    public void Herp(string derrr)
    {
        Console.WriteLine(derrr); // or maybe something more platform specific
    }
}

So the PCL version is just a stupid Facade for the platform specific one, then on invocation the correct one will be chosen.

Ideas, thoughts, yay or nay?

@martijn00
Copy link
Contributor

Yes!!!

@Dexyon
Copy link
Contributor

Dexyon commented Jan 14, 2016

Agree!

@Cheesebaron
Copy link
Member Author

Well, we would probably still need Bootstrap files if the Plugins need to be registered in the IoC for DI. But could also just be invoked directly if wanted.

@lothrop
Copy link
Contributor

lothrop commented Jan 14, 2016

This would only make sense if the plugin doesn't have any code that belongs inside a PCL.

@Cheesebaron
Copy link
Member Author

Care to elaborate @lothrop?

From my understanding any class that is not a facade inside of the PCL should still work just fine as long as there isn't an class and method named exactly the same in the platform specific dll.

@lothrop
Copy link
Contributor

lothrop commented Jan 14, 2016

Ah, gotcha, I was thinking the PCL wouldn't be used at all and we'd have to link the common code in using a shared project.

@ggirard07
Copy link
Contributor

If bait and switch is used then please try to not update/change assemblies versions for the rest of their lives otherwise it could become tricky to manage with NuGet adding some bindingredirect to the app.config file.
https://bugzilla.xamarin.com/show_bug.cgi?id=22670

@smstuebe
Copy link

smstuebe commented May 2, 2016

So this is similar to the https://github.com/jamesmontemagno/Xamarin.Plugins. Does it make sense to maintain two different branches of plugins. Or would it make more sense to combine forces at least for trivial plugins that do not use mvx functionality?!

@Cheesebaron
Copy link
Member Author

We have talked to @jamesmontemagno about this and I think moving forward we would contribute our plugins after they have been converted to match the template he uses. Then in MvvmCross just describe how to use those plugins with our IoC.

@smstuebe
Copy link

smstuebe commented May 2, 2016

Ye that is exactly what I thought.Good to hear. With my Fingerprint- and our BLE plugin we are going the same way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

6 participants