UWP .NET9 (#555)

* Ground work for NET9 UWP switch.

* Add launch settings for Wino.Mail

* Added new test WAP project

* fix platforms in slnx solution

* ManagePackageVersionsCentrally set default

* Fixing assets and couple issues with the new packaging project.

* Add back markdown

* Fix nuget warnings

* FIx error in WAP about build tools

* Add build.props with default language preview

* Some AOT compilation progress.

* More AOT stuff.

* Remove deprecated protocol auth activation handler.

* Fix remaining protocol handler for google auth.

* Even more AOT

* More more AOT fixes

* Fix a few more AOT warnings

* Fix signature editor AOT

* Fix composer and renderer AOT JSON

* Outlook Sync AOT

* Fixing bundle generation and package signing.

---------

Co-authored-by: Burak Kaan Köse <bkaankose@outlook.com>
This commit is contained in:
Aleh Khantsevich
2025-02-14 01:43:52 +01:00
committed by GitHub
parent e8dd8bff44
commit 2ec05ea7cc
151 changed files with 1170 additions and 1962 deletions

View File

@@ -1,10 +1,6 @@
using Wino.Core.UWP;
using Wino.Mail.ViewModels;
namespace Wino.Views.Abstract
{
public class MailListPageAbstract : BasePage<MailListPageViewModel>
{
namespace Wino.Views.Abstract;
}
}
public partial class MailListPageAbstract : BasePage<MailListPageViewModel>;

View File

@@ -4,13 +4,13 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.WinUI.Controls;
using EmailValidation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using MimeKit;
@@ -27,6 +27,7 @@ using Windows.UI.Xaml.Navigation;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models;
using Wino.Core.Domain.Models.Reader;
using Wino.Core.UWP.Extensions;
using Wino.Mail.ViewModels.Data;
@@ -215,7 +216,7 @@ namespace Wino.Views
}
}
await InvokeScriptSafeAsync($"insertImages({JsonSerializer.Serialize(imagesInformation)});");
await InvokeScriptSafeAsync($"insertImages({JsonSerializer.Serialize(imagesInformation, ComposerPageJsonContext.Default.ListImageInfo)});");
}
}
// State should be reset even when an exception occurs, otherwise the UI will be stuck in a dragging state.
@@ -227,7 +228,7 @@ namespace Wino.Views
static async Task<string> GetDataURL(StorageFile file)
{
return $"data:image/{file.FileType.Replace(".", "")};base64,{Convert.ToBase64String(await file.ReadBytesAsync())}";
return $"data:image/{file.FileType.Replace(".", "")};base64,{Convert.ToBase64String(await file.ToByteArrayAsync())}";
}
}
@@ -320,22 +321,6 @@ namespace Wino.Views
await InvokeScriptSafeAsync($"toggleToolbar('{enable}');");
}
public async Task<string> ExecuteScriptFunctionAsync(string functionName, params object[] parameters)
{
string script = functionName + "(";
for (int i = 0; i < parameters.Length; i++)
{
script += JsonSerializer.Serialize(parameters[i]);
if (i < parameters.Length - 1)
{
script += ", ";
}
}
script += ");";
return await Chromium.ExecuteScriptAsync(script);
}
private async Task<string> InvokeScriptSafeAsync(string function)
{
if (Chromium == null) return string.Empty;
@@ -404,11 +389,11 @@ namespace Wino.Views
if (string.IsNullOrEmpty(htmlBody))
{
await ExecuteScriptFunctionAsync("RenderHTML", " ");
await Chromium.ExecuteScriptFunctionAsync("RenderHTML", parameters: JsonSerializer.Serialize(" ", BasicTypesJsonContext.Default.String));
}
else
{
await ExecuteScriptFunctionAsync("RenderHTML", htmlBody);
await Chromium.ExecuteScriptFunctionAsync("RenderHTML", parameters: JsonSerializer.Serialize(htmlBody, BasicTypesJsonContext.Default.String));
}
}
@@ -419,7 +404,13 @@ namespace Wino.Views
int composerFontSize = ViewModel.PreferencesService.ComposerFontSize;
var readerFont = ViewModel.PreferencesService.ReaderFont;
int readerFontSize = ViewModel.PreferencesService.ReaderFontSize;
return await ExecuteScriptFunctionAsync("initializeJodit", fonts, composerFont, composerFontSize, readerFont, readerFontSize);
return await Chromium.ExecuteScriptFunctionAsync("initializeJodit",
false,
JsonSerializer.Serialize(fonts, BasicTypesJsonContext.Default.ListString),
JsonSerializer.Serialize(composerFont, BasicTypesJsonContext.Default.String),
JsonSerializer.Serialize(composerFontSize, BasicTypesJsonContext.Default.Int32),
JsonSerializer.Serialize(readerFont, BasicTypesJsonContext.Default.String),
JsonSerializer.Serialize(readerFontSize, BasicTypesJsonContext.Default.Int32));
}
private void DisposeWebView2()
@@ -468,7 +459,7 @@ namespace Wino.Views
{
var editorContent = await InvokeScriptSafeAsync("GetHTMLContent();");
return JsonSerializer.Deserialize<string>(editorContent);
return JsonSerializer.Deserialize(editorContent, BasicTypesJsonContext.Default.String);
});
var underlyingThemeService = App.Current.Services.GetService<IUnderlyingThemeService>();
@@ -492,7 +483,7 @@ namespace Wino.Views
private void ScriptMessageReceived(CoreWebView2 sender, CoreWebView2WebMessageReceivedEventArgs args)
{
var change = JsonSerializer.Deserialize<WebViewMessage>(args.WebMessageAsJson);
var change = JsonSerializer.Deserialize(args.WebMessageAsJson, DomainModelsJsonContext.Default.WebViewMessage);
if (change.Type == "bold")
{
@@ -698,4 +689,7 @@ namespace Wino.Views
finally { deferral.Complete(); }
}
}
[JsonSerializable(typeof(List<ImageInfo>))]
public partial class ComposerPageJsonContext: JsonSerializerContext;
}

View File

@@ -12,7 +12,6 @@
xmlns:enums="using:Wino.Core.Domain.Enums"
xmlns:helpers="using:Wino.Helpers"
xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:ic="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:listview="using:Wino.Controls.Advanced"
xmlns:local="using:Wino.Behaviors"
@@ -219,9 +218,9 @@
Text="{x:Bind ViewModel.SearchQuery, Mode=TwoWay}"
TextChanged="SearchBar_TextChanged">
<i:Interaction.Behaviors>
<ic:EventTriggerBehavior EventName="QuerySubmitted">
<ic:InvokeCommandAction Command="{x:Bind ViewModel.PerformSearchCommand}" />
</ic:EventTriggerBehavior>
<i:EventTriggerBehavior EventName="QuerySubmitted">
<i:InvokeCommandAction Command="{x:Bind ViewModel.PerformSearchCommand}" />
</i:EventTriggerBehavior>
</i:Interaction.Behaviors>
</AutoSuggestBox>
</Grid>

View File

@@ -11,7 +11,9 @@ using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;
using Wino.Core.Domain;
using Wino.Core.Domain.Interfaces;
using Wino.Core.UWP.Extensions;
using Wino.Mail.ViewModels.Data;
using Wino.Messaging.Client.Mails;
using Wino.Messaging.Client.Shell;
@@ -65,22 +67,6 @@ namespace Wino.Views
return string.Empty;
}
public async Task<string> ExecuteScriptFunctionAsync(string functionName, params object[] parameters)
{
string script = functionName + "(";
for (int i = 0; i < parameters.Length; i++)
{
script += JsonSerializer.Serialize(parameters[i]);
if (i < parameters.Length - 1)
{
script += ", ";
}
}
script += ");";
return isChromiumDisposed ? string.Empty : await Chromium.ExecuteScriptAsync(script);
}
private async Task RenderInternalAsync(string htmlBody)
{
isRenderingInProgress = true;
@@ -92,12 +78,14 @@ namespace Wino.Views
if (string.IsNullOrEmpty(htmlBody))
{
await ExecuteScriptFunctionAsync("RenderHTML", " ");
await Chromium.ExecuteScriptFunctionAsync("RenderHTML", isChromiumDisposed, JsonSerializer.Serialize(" ", BasicTypesJsonContext.Default.String));
}
else
{
var shouldLinkifyText = ViewModel.CurrentRenderModel?.MailRenderingOptions?.RenderPlaintextLinks ?? true;
await ExecuteScriptFunctionAsync("RenderHTML", htmlBody, shouldLinkifyText);
await Chromium.ExecuteScriptFunctionAsync("RenderHTML", isChromiumDisposed,
JsonSerializer.Serialize(htmlBody, BasicTypesJsonContext.Default.String),
JsonSerializer.Serialize(shouldLinkifyText, BasicTypesJsonContext.Default.Boolean));
}
isRenderingInProgress = false;
@@ -133,8 +121,6 @@ namespace Wino.Views
{
base.OnNavigatedFrom(e);
WeakReferenceMessenger.Default.Send(new CancelRenderingContentRequested());
// Disposing the page.
// Make sure the WebView2 is disposed properly.
@@ -263,7 +249,7 @@ namespace Wino.Views
private async Task UpdateReaderFontPropertiesAsync()
{
await ExecuteScriptFunctionAsync("ChangeFontSize", _preferencesService.ReaderFontSize);
await Chromium.ExecuteScriptFunctionAsync("ChangeFontSize", isChromiumDisposed, JsonSerializer.Serialize(_preferencesService.ReaderFontSize, BasicTypesJsonContext.Default.Int32));
// Prepare font family name with fallback to sans-serif by default.
var fontName = _preferencesService.ReaderFont;
@@ -271,7 +257,7 @@ namespace Wino.Views
// If font family name is not supported by the browser, fallback to sans-serif.
fontName += ", sans-serif";
await ExecuteScriptFunctionAsync("ChangeFontFamily", fontName);
await Chromium.ExecuteScriptFunctionAsync("ChangeFontFamily", isChromiumDisposed, JsonSerializer.Serialize(fontName, BasicTypesJsonContext.Default.String));
}
void IRecipient<ApplicationThemeChanged>.Receive(ApplicationThemeChanged message)

View File

@@ -1,17 +1,16 @@
using CommunityToolkit.Labs.WinUI.MarkdownTextBlock;
using Wino.Views.Abstract;
namespace Wino.Views
namespace Wino.Views;
public sealed partial class WelcomePage : WelcomePageAbstract
{
public sealed partial class WelcomePage : WelcomePageAbstract
private readonly MarkdownConfig _config;
public WelcomePage()
{
private readonly MarkdownConfig _config;
InitializeComponent();
public WelcomePage()
{
InitializeComponent();
_config = new MarkdownConfig();
}
_config = new MarkdownConfig();
}
}