Skip to content
Permalink
Browse files

feature: Add warning when running .NET Standard (#2186)

* Add warning when running .NET Standard

#2164

* Add reference to installation instructions

Co-Authored-By: Artyom <worldbeater-dev@yandex.ru>
  • Loading branch information...
2 people authored and RLittlesII committed Oct 1, 2019
1 parent aac1e6a commit 76f6833958cbad0bf44fc06434157777a3df6846
Showing with 20 additions and 1 deletion.
  1. +20 −1 src/ReactiveUI/RxApp.cs
@@ -65,6 +65,7 @@ public static class RxApp
[ThreadStatic]
private static ISuspensionHost _unitTestSuspensionHost;
private static ISuspensionHost _suspensionHost;
private static bool _hasSchedulerBeenChecked;

/// <summary>
/// Initializes static members of the <see cref="RxApp"/> class.
@@ -135,7 +136,25 @@ static RxApp()
/// </summary>
public static IScheduler MainThreadScheduler
{
get => _unitTestMainThreadScheduler ?? _mainThreadScheduler;
get
{
if (_unitTestMainThreadScheduler != null)
{
return _unitTestMainThreadScheduler;
}

// If Scheduler is DefaultScheduler, user is likely using .NET Standard
if (!_hasSchedulerBeenChecked && _mainThreadScheduler == Scheduler.Default)
{
_hasSchedulerBeenChecked = true;
LogHost.Default.Warn("It seems you are running .NET Standard, but there is no host package installed!\n");
LogHost.Default.Warn("You will need to install the specific host package for your platform (ReactiveUI.WPF, ReactiveUI.Blazor, ...)\n");
LogHost.Default.Warn("You can install the needed package via NuGet, see https://reactiveui.net/docs/getting-started/installation/");
}

return _mainThreadScheduler;
}

set
{
// N.B. The ThreadStatic dance here is for the unit test case -

0 comments on commit 76f6833

Please sign in to comment.
You can’t perform that action at this time.