Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

FAQ | Essentials

James Montemagno edited this page Dec 7, 2018 · 3 revisions

Here are some common questions about Essentials:

How much will Essentials increase my app size? What if I only want a few of the features?

Essentials is an extremely small library and provides access to core platform APIs. We built Essentials to be Linker Safe, which means if you only use ONE feature that is the ONLY feature that will be added to your app. The rest will be linked away and even works with Link All Assemblies.

Where are the interfaces?

Some developers prefer an interface based programming model for dependency injection and testing of code. Xamarin.Essentials does not offer any interfaces and delivers straight API access via direct classes and static properties/methods. There are many reasons that Xamarin.Essentials is architected this way that include performance, simplicity, and ease of use. We also consider Xamarin.Essentials a core API of the platform just like System classes, HttpClient, and our platform bindings.

Additionally, we found most developers create their own interfaces even when using a library that have interfaces. They do this so they have control over the APIs they actually use, which may be a very small percentage of the overall APIs in the library. Creating your own IXamarinEssentials and exposing only the methods and properties you would like to use gives you more flexibility as Xamarin.Essentials grows and adds additional APIs. Using this type of architecture will enable you to both have dependency injection and work with unit testing.

When running Xamarin.Essentials APIs on platforms that aren't supported you can check the following:

if(DeviceInfo.Platform == DevicePlatform.Unknown)
    return;

Does Xamarin.Essentials replace plugins?

Plugins offer a wide variety of cross-platform APIs for developers to use in their applications. Plugins will still continue to grow and flourish as they can offer a wider range of APIs and handle unique scenarios that Xamarin.Essentials may not offer including additional platform support or add features unique to a single platform.

Clone this wiki locally