From bb4b1daa5cfc26c74e9dc6587e59bdb9fe5ca42b Mon Sep 17 00:00:00 2001 From: Frederik Prijck Date: Tue, 5 Dec 2023 07:25:16 +0100 Subject: [PATCH] Drop support for WebView for WPF and Winforms and default to WebView2 (#308) --- nuget/Auth0.OidcClient.WPF.nuspec | 4 ++-- nuget/Auth0.OidcClient.WinForms.nuspec | 4 ++-- .../Auth0.OidcClient.WPF.csproj | 4 +--- src/Auth0.OidcClient.WPF/WebViewBrowser.cs | 16 ++-------------- .../Auth0.OidcClient.WinForms.csproj | 4 +--- src/Auth0.OidcClient.WinForms/WebViewBrowser.cs | 16 ++-------------- 6 files changed, 10 insertions(+), 38 deletions(-) diff --git a/nuget/Auth0.OidcClient.WPF.nuspec b/nuget/Auth0.OidcClient.WPF.nuspec index 105b3ff8..62e7a35a 100644 --- a/nuget/Auth0.OidcClient.WPF.nuspec +++ b/nuget/Auth0.OidcClient.WPF.nuspec @@ -127,11 +127,11 @@ - + - + diff --git a/nuget/Auth0.OidcClient.WinForms.nuspec b/nuget/Auth0.OidcClient.WinForms.nuspec index 6f67164c..d7faf9f8 100644 --- a/nuget/Auth0.OidcClient.WinForms.nuspec +++ b/nuget/Auth0.OidcClient.WinForms.nuspec @@ -120,11 +120,11 @@ - + - + diff --git a/src/Auth0.OidcClient.WPF/Auth0.OidcClient.WPF.csproj b/src/Auth0.OidcClient.WPF/Auth0.OidcClient.WPF.csproj index 6bd023f2..5173e8b1 100644 --- a/src/Auth0.OidcClient.WPF/Auth0.OidcClient.WPF.csproj +++ b/src/Auth0.OidcClient.WPF/Auth0.OidcClient.WPF.csproj @@ -31,9 +31,7 @@ - - 6.1.2 - + diff --git a/src/Auth0.OidcClient.WPF/WebViewBrowser.cs b/src/Auth0.OidcClient.WPF/WebViewBrowser.cs index b9a77409..ff6cd8cd 100644 --- a/src/Auth0.OidcClient.WPF/WebViewBrowser.cs +++ b/src/Auth0.OidcClient.WPF/WebViewBrowser.cs @@ -1,9 +1,5 @@ using IdentityModel.OidcClient.Browser; -#if NET6_0 -using WebViewCompatible = Microsoft.Web.WebView2.Wpf.WebView2; -#else -using Microsoft.Toolkit.Wpf.UI.Controls; -#endif +using Microsoft.Web.WebView2.Wpf; using System; using System.Threading; using System.Threading.Tasks; @@ -54,16 +50,12 @@ public async Task InvokeAsync(BrowserOptions options, Cancellatio var window = _windowFactory(); #pragma warning disable 618 - var webView = new WebViewCompatible(); + var webView = new WebView2(); window.Content = webView; webView.NavigationStarting += (sender, e) => { -#if NET6_0 if (e.Uri.StartsWith(options.EndUrl)) -#else - if (e.Uri.AbsoluteUri.StartsWith(options.EndUrl)) -#endif { tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.Success, Response = e.Uri.ToString() }); if (_shouldCloseWindow) @@ -82,12 +74,8 @@ public async Task InvokeAsync(BrowserOptions options, Cancellatio window.Show(); -#if NET6_0 await webView.EnsureCoreWebView2Async(); webView.CoreWebView2.Navigate(options.StartUrl); -#else - webView.Navigate(options.StartUrl); -#endif return await tcs.Task; } diff --git a/src/Auth0.OidcClient.WinForms/Auth0.OidcClient.WinForms.csproj b/src/Auth0.OidcClient.WinForms/Auth0.OidcClient.WinForms.csproj index c4e88149..3abfb09e 100644 --- a/src/Auth0.OidcClient.WinForms/Auth0.OidcClient.WinForms.csproj +++ b/src/Auth0.OidcClient.WinForms/Auth0.OidcClient.WinForms.csproj @@ -31,9 +31,7 @@ - - 6.1.2 - + diff --git a/src/Auth0.OidcClient.WinForms/WebViewBrowser.cs b/src/Auth0.OidcClient.WinForms/WebViewBrowser.cs index bc654290..0c42b65a 100644 --- a/src/Auth0.OidcClient.WinForms/WebViewBrowser.cs +++ b/src/Auth0.OidcClient.WinForms/WebViewBrowser.cs @@ -1,9 +1,5 @@ using IdentityModel.OidcClient.Browser; -#if NET6_0 -using WebViewCompatible = Microsoft.Web.WebView2.WinForms.WebView2; -#else -using Microsoft.Toolkit.Forms.UI.Controls; -#endif +using Microsoft.Web.WebView2.WinForms; using System; using System.Threading; using System.Threading.Tasks; @@ -52,15 +48,11 @@ public async Task InvokeAsync(BrowserOptions options, Cancellatio var window = _formFactory(); #pragma warning disable 618 - var webView = new WebViewCompatible { Dock = DockStyle.Fill }; + var webView = new WebView2 { Dock = DockStyle.Fill }; webView.NavigationStarting += (sender, e) => { -#if NET6_0 if (e.Uri.StartsWith(options.EndUrl)) -#else - if (e.Uri.AbsoluteUri.StartsWith(options.EndUrl)) -#endif { tcs.SetResult(new BrowserResult { ResultType = BrowserResultType.Success, Response = e.Uri.ToString() }); window.Close(); @@ -77,12 +69,8 @@ public async Task InvokeAsync(BrowserOptions options, Cancellatio window.Show(); -#if NET6_0 await webView.EnsureCoreWebView2Async(); webView.CoreWebView2.Navigate(options.StartUrl); -#else - webView.Navigate(options.StartUrl); -#endif return await tcs.Task; }