From 90fcc0c747ac4cefd9ea3c49d84f0a714850b758 Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Tue, 12 Jul 2022 15:12:00 +0800 Subject: [PATCH] fix _initTask --- src/Avalonia.WebView2/Avalonia.WebView2.csproj | 11 ++--------- src/Avalonia.WebView2/WebView2.cs | 12 ++++++++---- src/Directory.Packages.props | 2 +- src/WebView2.NativeAssets.Win32.nuspec | 5 +++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.WebView2/Avalonia.WebView2.csproj b/src/Avalonia.WebView2/Avalonia.WebView2.csproj index 4d2985e..14c9ca7 100644 --- a/src/Avalonia.WebView2/Avalonia.WebView2.csproj +++ b/src/Avalonia.WebView2/Avalonia.WebView2.csproj @@ -10,7 +10,7 @@ This package is necessary for Avalonia applications. To learn more about package versions checkout https://aka.ms/wv2-packageversion. To learn best practices checkout: https://aka.ms/wv2-bestpractices. Web WebView Native native package Edge avalonia avaloniaui dotnet framework core Webview2 - 1.0.1264.42-preview.220711.6 + 1.0.1264.42-preview.220712.8 true @@ -19,21 +19,14 @@ true - - DISABLE_WEBVIEW2_CORE;$(DefineConstants) - - - - - - + diff --git a/src/Avalonia.WebView2/WebView2.cs b/src/Avalonia.WebView2/WebView2.cs index 5945ef0..f28eb83 100644 --- a/src/Avalonia.WebView2/WebView2.cs +++ b/src/Avalonia.WebView2/WebView2.cs @@ -12,7 +12,7 @@ public partial class WebView2 : WebView2BaseType, IHwndHost, ISupportInitialize, public static string? VersionString { get; private set; } - static WebView2() + public static void RefreshIsSupported() { #if !DISABLE_WEBVIEW2_CORE #if !WINDOWS @@ -35,6 +35,11 @@ static WebView2() #endif } + static WebView2() + { + RefreshIsSupported(); + } + public WebView2() { if (IsInDesignMode) @@ -294,8 +299,8 @@ IntPtr IHwndHost.WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref /// public Task EnsureCoreWebView2Async(CoreWebView2Environment? environment = null, CoreWebView2ControllerOptions? controllerOptions = null) { - if (IsInDesignMode) - return Task.FromResult(0); + if (IsInDesignMode || !IsSupported) + return Task.CompletedTask; VerifyNotClosedGuard(); VerifyBrowserNotCrashedGuard(); if (!CheckAccess()) @@ -330,7 +335,6 @@ public Task EnsureCoreWebView2Async(CoreWebView2Environment? environment = null, /// All the event handlers added here need to be removed in . async Task InitCoreWebView2Async(CoreWebView2Environment? environment = null, CoreWebView2ControllerOptions? controllerOptions = null) { - if (!IsSupported) return; WebView2 sender = this; try { diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 67ad4c8..466e6be 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -9,6 +9,6 @@ - + \ No newline at end of file diff --git a/src/WebView2.NativeAssets.Win32.nuspec b/src/WebView2.NativeAssets.Win32.nuspec index 69ec599..0f12c74 100644 --- a/src/WebView2.NativeAssets.Win32.nuspec +++ b/src/WebView2.NativeAssets.Win32.nuspec @@ -3,7 +3,7 @@ WebView2.NativeAssets.Win32 WebView2.NativeAssets.Win32 - 1.0.1264.42 + 1.0.1264.43 https://github.com/AigioL © Microsoft Corporation. All rights reserved. false @@ -11,13 +11,14 @@ Microsoft Web WebView Native native package Edge Avalonia dotnet framework core Webview2 The WebView2 control enables you to embed web technologies (HTML, CSS, and JavaScript) in your native applications powered by Microsoft Edge (Chromium). -This package is necessary for Win32 C/C++, WPF, WinForms, and Avalonia applications. To learn more about package versions checkout https://aka.ms/wv2-packageversion. To learn best practices checkout: https://aka.ms/wv2-bestpractices. +This package is necessary for Console and Avalonia applications. To learn more about package versions checkout https://aka.ms/wv2-packageversion. To learn best practices checkout: https://aka.ms/wv2-bestpractices. +