Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Currently in order to use the DependencyService, you must implement your custom interface, and the only way to register it with the DependencyService is via the "[assembly: Dependency(typeof(Class))]" annotation.
This prevents defining the real implementation class for all platforms within the PCL and a mock implementation class within my unit test project. This is helpful for interfaces that are not platform specific, but I would like to use the DependencyService to provide a mock implementation during unit tests.
Currently in order to achieve this, I would have to copy the implementation class for every platform even if it is the same and export it from each platform dll. I would much rather define the implementation class once in the PCL, and then register the real implementation in my PCL App.xaml.cs and then provide and register a mock implementation in my unit test project.
You can register using the static helper and not the attribute.
Completely missed that. Thanks!