Introduction
This repository contains the device detection engines for the .NET implementation of the Pipeline API.
The specification is also available on GitHub and is recommended reading if you wish to understand the concepts and design of this API.
Dependencies
Visual Studio 2022 or later is recommended. Although Visual Studio Code can be used for working with most of the projects.
The core device detection projects are written in C and C++. The Pipeline engines are written in C# and target .NET Standard 2.0.3. Example and test projects mostly target .NET 6.0 though in some cases, projects are available targeting other frameworks.
For runtime dependencies, see our dependencies page. The tested versions page shows the .NET versions that we currently test against. The software may run fine against other versions, but additional caution should be applied.
Data
The API can either use our cloud service to get its data or it can use a local (on-premise) copy of the data.
Cloud
You will require a resource key to use the Cloud API. You can create resource keys using our configurator, see our documentation on how to use this.
On-Premise
In order to perform device detection on-premise, you will need to use a 51Degrees data file. This repository includes a free, 'lite' file in the 'device-detection-data' sub-module that has a significantly reduced set of properties. To obtain a file with a more complete set of device properties see the 51Degrees website. If you want to use the lite file, you will need to install GitLFS.
On Linux:
Then, navigate to 'FiftyOne.DeviceDetection/device-detection-cxx/device-detection-data' and execute:
Solutions and projects
- FiftyOne.DeviceDetection - Device detection engines and related projects.
- FiftyOne.DeviceDetection.Hash - .NET implementation of the device detection hash engine.
- FiftyOne.DeviceDetection.Shared - Shared classes used by the device detection engines.
- FiftyOne.DeviceDetection - Contains device detection engine builders.
- FiftyOne.DeviceDetection.Cloud - A .NET engine which retrieves device detection results by consuming the 51Degrees cloud service. This can be swapped out with either the hash or pattern engines seamlessly.
Installation
Nuget
The easiest way to install is to use NuGet to add the reference to the package:
Build from Source
Device detection on-premise uses a native binary. (i.e. compiled from C code to target a specific platform/architecture) The NuGet package contains several binaries for common platforms. However, in some cases, you'll need to build the native binaries yourself for your target platform. This section explains how to do this.
Pre-requisites
- Install C build tools:
- Windows:
- You will need either Visual Studio 2022 or the C++ Build Tools installed.
- Minimum platform toolset version is
v143
- Minimum Windows SDK version is
10.0.18362.0
- Minimum platform toolset version is
- You will need either Visual Studio 2022 or the C++ Build Tools installed.
- Linux/MacOS:
sudo apt-get install g++ make libatomic1
- Windows:
- If you have not already done so, pull the git submodules that contain the native code:
git submodule update --init --recursive
Visual studio should now be able to build the native binaries as part of it's normal build process.
Examples
Examples can be found in device-detection-dotnet-examples repository
Tests
Tests can be found in the Tests/
folder. These can all be run from within Visual Studio or by using the dotnet test
command line tool.
Some tests require additional resources in order to run. These will either fail or return an 'inconclusive' result if these resources are not provided.
- Some tests require an 'Enterprise' data file. This can be obtained by purchasing a license.
- Once available, the full path to this data file must be specified in the
DEVICEDETECTIONDATAFILE
environment variable.
- Once available, the full path to this data file must be specified in the
- Tests using the cloud service require resource keys with specific properties to be provided using environment variables:
- The
SUPER_RESOURCE_KEY
environment variable should be populated with a key that includes all properties. A license is required in order to access some properties.
- The
Project documentation
For complete documentation on the Pipeline API and associated engines, see the 51Degrees documentation site.