From 73274ed61fd30b748fbdb65776f1b309427f66d2 Mon Sep 17 00:00:00 2001 From: Rafael Gomez Date: Tue, 1 Oct 2019 22:37:21 +0200 Subject: [PATCH 1/2] Add warning when running .NET Standard #2164 --- src/ReactiveUI/RxApp.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ReactiveUI/RxApp.cs b/src/ReactiveUI/RxApp.cs index 49e8809895..9524be56f0 100644 --- a/src/ReactiveUI/RxApp.cs +++ b/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; /// /// Initializes static members of the class. @@ -135,7 +136,25 @@ static RxApp() /// 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"); + } + + return _mainThreadScheduler; + } + set { // N.B. The ThreadStatic dance here is for the unit test case - From 47b673c60dd4808f928cc937556b433154eee144 Mon Sep 17 00:00:00 2001 From: Rafael Gomez Date: Tue, 1 Oct 2019 23:50:52 +0200 Subject: [PATCH 2/2] Add reference to installation instructions Co-Authored-By: Artyom --- src/ReactiveUI/RxApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactiveUI/RxApp.cs b/src/ReactiveUI/RxApp.cs index 9524be56f0..335f42bd7f 100644 --- a/src/ReactiveUI/RxApp.cs +++ b/src/ReactiveUI/RxApp.cs @@ -149,7 +149,7 @@ public static IScheduler MainThreadScheduler _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"); + LogHost.Default.Warn("You can install the needed package via NuGet, see https://reactiveui.net/docs/getting-started/installation/"); } return _mainThreadScheduler;