Abstractions to simplify retrieving platform information in .NET
Switch branches/tags
Clone or download

README.md


Sentry.PlatformAbstractions

Travis AppVeyor

This is a work in progress.

The idea here is to simplify the .NET SDK by leaving the messy #ifdefs, platform specific code (operating system, runtime, etc) out into its own library. It also helps by allowing us to share code between the new .NET SDK and the current .NET SDK.

Most of the platform information used by the SDK goes to Sentry's Context Interface. When implementing this on SharpRaven it was clear that to get reliable information is not as trivial as it seems. This repo is an attempt to create a package which will provide reliable information in different types of apps.

Examples

For details, check the example project.

Runtime information

If you are interested in the runtime information, with .NET Standard 1.5 onwards you can use: RuntimeInformation.FrameworkDescription, which will give you a single string

For example, .NET Core 2.0.6 on Linux returns: .NET Core 4.6.0.0. Besides not telling you what was actually installed on the machine, to get the version number you would need to parse the string.

The following table compares the results of that API call to what this library returns:

Target OS RuntimeInformation.FrameworkDescription This library returns an object
.NET Framework 4.7.2 Windows .NET Framework 4.7.3101.0 Name: .NET Framework
Version: 4.7.2
.NET Core 1.1.7 macOS .NET Core 4.6.26201.01 Name: .NET Core
Version: 1.1.7
.NET Core 1.1.8 Linux .NET Core 4.6.26328.01 Name: .NET Core
Version: 1.1.8
.NET Core 2.0.6 macOS .NET Core 4.6.0.0 Name: .NET Core
Version: 2.0.6
.NET Core 2.0.6 Linux .NET Core 4.6.0.0 Name: .NET Core
Version: 2.0.6
Mono 5.10.1.47 macOS 5.10.1.47 (2017-12/8eb8f7d5e74
Fri Apr 13 20:18:12 EDT 2018)
Name: Mono
Version: Mono 5.10.1.47
Mono 5.12.0.226 Linux 5.12.0.226 (tarball Thu May 3 09:48:32 UTC 2018) Name: Mono
Version: 5.12.0.226

It also includes extension methods to Runtime:

  • IsMono()
  • IsNetCore()
  • IsNetFx()

Supported frameworks

This library supports:

  • .NET Framework 3.5 and later
  • .NET Standard 1.5 and later

Building

Install .NET Core

.NET Core 2.0.x and 1.1.x SDKs.

Windows

.NET Framework, 4.7.1 or later

.\build.ps1

Linux and macOS

Install Mono 5.12 or later

./build.sh

Resources