Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded to net7.0, updated deps, enabled all WASM optimizations #117

Merged
merged 32 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7a7686c
Upgraded to net7.0, updated all dependencies, enabled all WASM optimi…
Arlodotexe Jul 20, 2023
450c379
Bump Uno, fix missing Uno.UI.RemoteControl version
Arlodotexe Jul 20, 2023
7202f14
Restore default enable TargetFrameworks
Arlodotexe Jul 20, 2023
0c7fbc5
Use net6 where appropriate
Arlodotexe Jul 20, 2023
fc5b9bc
Added MultiTarget missing TFM error messages. Aligned UseTargetFramew…
Arlodotexe Jul 20, 2023
a314f2a
Restore default enabled TFMs
Arlodotexe Jul 20, 2023
792cc4d
Enable JIT when using Interpreter
Arlodotexe Jul 20, 2023
4bb8811
Downgraded EnsureNoEnabledMultiTargetsWithMissingTfms to Warning
Arlodotexe Jul 20, 2023
69920cc
Update editorconfig
Arlodotexe Jul 20, 2023
0d073f9
Enable 'netstandard' MultiTarget tfm by default
Arlodotexe Jul 20, 2023
33af1ce
Update uno.check to latest version (required for android30.0)
Arlodotexe Jul 20, 2023
59e689d
Use android30 and macos, remove maccatalyst
Arlodotexe Jul 20, 2023
e1ac3ca
Set CA2213 to 'None'
Arlodotexe Jul 21, 2023
65fb517
Use Interpreter on WASM
Arlodotexe Jul 21, 2023
d942529
Remove os version from Android TFM
Arlodotexe Jul 21, 2023
f5aae02
Suppress CA1060
Arlodotexe Jul 21, 2023
ddf9cbb
Fixed TitleBar build errors on Uno / WinUI 3
Arlodotexe Jul 22, 2023
9faa351
Update uno-check
Arlodotexe Jul 24, 2023
91c42a2
Use stable Uno 4.x version
Arlodotexe Aug 1, 2023
6c958ed
Add parameter notes
Arlodotexe Aug 1, 2023
cf47b67
Bump Uno.Wasm.Bootstrap
Arlodotexe Aug 1, 2023
1fe7460
Added portable SharedArrayBuffer workaround to single-sample componen…
Arlodotexe Aug 2, 2023
9e186fd
Renamed NetCoreCommonTargetFramework and NetStandardCommonTargetFram…
Arlodotexe Aug 2, 2023
6b08232
Merge branch 'targets/upgrade/net7' of https://github.com/CommunityTo…
Arlodotexe Aug 3, 2023
026ca8c
Merge branch 'main' into targets/upgrade/net7
Arlodotexe Aug 9, 2023
0e3e4c4
Switch to maccatalyst
Arlodotexe Aug 14, 2023
989cebd
Fix for net7.0-maccatalyst, use dotnet 7.0.100
Arlodotexe Aug 14, 2023
2f8caf5
Additional net7 mobile error suppression
Arlodotexe Aug 14, 2023
9f18b05
More error suppression for net7 mobile
Arlodotexe Aug 14, 2023
0a36c62
Update Pack Script to accept extra argument for build properties
michael-hawker Aug 15, 2023
faeaab9
Use net7.0-android33.0 instead of net7.0-android
Arlodotexe Aug 16, 2023
fc7bd95
Cleanup CheckEnabledMultiTargetsWithMissingTfms
Arlodotexe Aug 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"uno.check": {
"version": "1.10.0",
"version": "1.13.0",
"commands": [
"uno-check"
]
Expand Down
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ dotnet_diagnostic.CA2200.severity = warning
dotnet_diagnostic.CA2202.severity = warning
dotnet_diagnostic.CA2207.severity = warning
dotnet_diagnostic.CA2212.severity = warning
dotnet_diagnostic.CA2213.severity = warning
dotnet_diagnostic.CA2214.severity = warning
dotnet_diagnostic.CA2216.severity = warning
dotnet_diagnostic.CA2220.severity = warning
Expand Down Expand Up @@ -435,3 +434,6 @@ dotnet_diagnostic.IDE0073.severity = warning

# Uno platform exposes IDisposable on Storyboard publicly when it should be internal. Ignore this.
dotnet_code_quality.CA1001.excluded_type_names_with_derived_types = T:Windows.UI.Xaml.Media.Animation.Storyboard

# Member owns disposable field
dotnet_diagnostic.CA2213.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// See the LICENSE file in the project root for more information.

#if WINDOWS_WINAPPSDK
#pragma warning disable CA1060

using System.Runtime.InteropServices;
using WinRT.Interop;
using Microsoft.UI;
using Microsoft.UI.Windowing;

namespace CommunityToolkit.App.Shared.Controls;

#pragma warning disable CA1060 // Move pinvokes to native methods class
public partial class TitleBar : Control
{
[DllImport("Shcore.dll", SetLastError = true)]
Expand Down Expand Up @@ -42,5 +43,5 @@ private double GetScaleAdjustment()
return scaleFactorPercent / 100.0;
}
}
#endif
#pragma warning restore CA1060
#endif
4 changes: 4 additions & 0 deletions CommunityToolkit.App.Shared/LinkerConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<!-- This is required by JSon.NET and any expression.Compile caller -->
<type fullname="System.Linq.Expressions*" />
</assembly>

<assembly fullname="WebAssembly.Bindings" />
<assembly fullname="rive" />
<assembly fullname="RiveSharp" />
</linker>
19 changes: 10 additions & 9 deletions MultiTarget/AvailableTargetFrameworks.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
<UwpTargetFramework>uap10.0.17763</UwpTargetFramework>
<WinAppSdkTargetFramework>net6.0-windows10.0.19041.0</WinAppSdkTargetFramework>

<WasmHeadTargetFramework>net5.0</WasmHeadTargetFramework>
<LinuxHeadTargetFramework>net5.0</LinuxHeadTargetFramework>
<WpfHeadTargetFramework>netcoreapp3.1</WpfHeadTargetFramework>
<WasmHeadTargetFramework>net7.0</WasmHeadTargetFramework>
<LinuxHeadTargetFramework>net7.0</LinuxHeadTargetFramework>
<WpfHeadTargetFramework>net7.0</WpfHeadTargetFramework>

<AndroidLibTargetFramework>monoandroid12.0</AndroidLibTargetFramework>
<MacOSLibTargetFramework>xamarinmac20</MacOSLibTargetFramework>
<iOSLibTargetFramework>xamarinios10</iOSLibTargetFramework>
<AndroidLibTargetFramework>net7.0-android</AndroidLibTargetFramework>
<MacOSLibTargetFramework>net7.0-macos</MacOSLibTargetFramework>
<iOSLibTargetFramework>net7.0-ios</iOSLibTargetFramework>

<!-- Used for comparison to current TargetFramework -->
<LinuxLibTargetFramework>netstandard2.0</LinuxLibTargetFramework>
<WasmLibTargetFramework>netstandard2.0</WasmLibTargetFramework>
<WpfLibTargetFramework>netstandard2.0</WpfLibTargetFramework>
<LinuxLibTargetFramework>net7.0</LinuxLibTargetFramework>
<WasmLibTargetFramework>net7.0</WasmLibTargetFramework>
<WpfLibTargetFramework>net7.0</WpfLibTargetFramework>

<!-- Used for defining TargetFramework under platforms that need it -->
<NetStandardCommonTargetFramework>netstandard2.0</NetStandardCommonTargetFramework>
<NetCoreCommonTargetFramework>net7.0</NetCoreCommonTargetFramework>
Arlodotexe marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>
</Project>
17 changes: 7 additions & 10 deletions MultiTarget/EnabledTargetFrameworks.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
<UwpTargetFramework>uap10.0.17763</UwpTargetFramework>
<WinAppSdkTargetFramework>net6.0-windows10.0.19041.0</WinAppSdkTargetFramework>

<WasmHeadTargetFramework>net5.0</WasmHeadTargetFramework>
<LinuxHeadTargetFramework>net5.0</LinuxHeadTargetFramework>
<WpfHeadTargetFramework>netcoreapp3.1</WpfHeadTargetFramework>




<WasmHeadTargetFramework>net7.0</WasmHeadTargetFramework>
<LinuxHeadTargetFramework>net7.0</LinuxHeadTargetFramework>
<WpfHeadTargetFramework>net7.0</WpfHeadTargetFramework>

<!-- Used for comparison to current TargetFramework -->
<LinuxLibTargetFramework>netstandard2.0</LinuxLibTargetFramework>
<WasmLibTargetFramework>netstandard2.0</WasmLibTargetFramework>
<WpfLibTargetFramework>netstandard2.0</WpfLibTargetFramework>
<LinuxLibTargetFramework>net7.0</LinuxLibTargetFramework>
<WasmLibTargetFramework>net7.0</WasmLibTargetFramework>
<WpfLibTargetFramework>net7.0</WpfLibTargetFramework>

<!-- Used for defining TargetFramework under platforms that need it -->
<NetStandardCommonTargetFramework>netstandard2.0</NetStandardCommonTargetFramework>
<NetCoreCommonTargetFramework>net7.0</NetCoreCommonTargetFramework>
</PropertyGroup>
</Project>
21 changes: 18 additions & 3 deletions MultiTarget/MultiTargetToTargetFramework.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<Project>
<Project InitialTargets="EnsureNoEnabledMultiTargetsWithMissingTfms">
<Target Name="EnsureNoEnabledMultiTargetsWithMissingTfms">
<Warning Condition="$(MultiTarget.Contains('uwp')) == 'true' AND '$(UwpTargetFramework)' == ''" Text="Attempted to build a project with a uwp MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />
Arlodotexe marked this conversation as resolved.
Show resolved Hide resolved

<Warning Condition="$(MultiTarget.Contains('wasdk')) == 'true' AND '$(WinAppSdkTargetFramework)' == ''" Text="Attempted to build a project with a wasdk MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />

<Warning Condition="$(MultiTarget.Contains('wasm')) == 'true' AND '$(NetCoreCommonTargetFramework)' == ''" Text="Attempted to build a project with a wasm MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />

<Warning Condition="$(MultiTarget.Contains('macos')) == 'true' AND '$(NetCoreCommonTargetFramework)' == ''" Text="Attempted to build a project with a macos MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />

<Warning Condition="$(MultiTarget.Contains('ios')) == 'true' AND '$(NetCoreCommonTargetFramework)' == ''" Text="Attempted to build an project with an ios MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />

<Warning Condition="$(MultiTarget.Contains('android')) == 'true' AND '$(NetCoreCommonTargetFramework)' == ''" Text="Attempted to build a project with an android MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />

Arlodotexe marked this conversation as resolved.
Show resolved Hide resolved
<Warning Condition="$(MultiTarget.Contains('netstandard')) == 'true' AND '$(NetStandardCommonTargetFramework)' == ''" Text="Attempted to build a project with a netstandard MultiTarget, but the corresponding TargetFramework is not enabled. To build this TFM, please use ./tooling/MultiTarget/UseTargetFrameworks.ps1 to enable this TFM, then regenerate your solution and try again." />
</Target>
<PropertyGroup>
<!--
MultiTarget is a custom property that indicates which target a project is designed to be built for / run on.
Expand All @@ -9,9 +24,9 @@

<!--
TargetFrameworks for WasmLibTargetFramework, WpfLibTargetFramework, and LinuxLibTargetFramework all use the same value.
Duplicate values can't be removed during the evaluation phase without breaking things, so we use the value directly.
Duplicate values can't be removed during the evaluation phase without breaking things, so we use a single value for all that need it.
-->
<TargetFrameworks Condition="$(MultiTarget.Contains('wasm')) == 'true' OR $(MultiTarget.Contains('wpf')) == 'true' OR $(MultiTarget.Contains('linuxgtk')) == 'true'">$(TargetFrameworks);$(NetStandardCommonTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="$(MultiTarget.Contains('wasm')) == 'true' OR $(MultiTarget.Contains('wpf')) == 'true' OR $(MultiTarget.Contains('linuxgtk')) == 'true'">$(TargetFrameworks);$(NetCoreCommonTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="$(MultiTarget.Contains('macos')) == 'true'">$(TargetFrameworks);$(MacOSLibTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="$(MultiTarget.Contains('ios')) == 'true'">$(TargetFrameworks);$(iOSLibTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="$(MultiTarget.Contains('android')) == 'true'">$(TargetFrameworks);$(AndroidLibTargetFramework)</TargetFrameworks>
Expand Down
14 changes: 9 additions & 5 deletions MultiTarget/PackageReferences/Uno.props
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
<Project>
<PropertyGroup>
<CommonUnoPackageVersion>4.9.45</CommonUnoPackageVersion>
Arlodotexe marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<!-- This file is modified by UseUnoWinUI.ps1 to switch between WinUI 2 and 3 under Uno Platform -->
<!-- All Uno-based project heads and MultiTarget-enabled library projects need to reference this file, while native (UWP/WinAppSdk) heads don't. -->
<ItemGroup Condition="'$(IsUno)' == 'true'">
<PackageReference Include="Uno.UI" Version="4.9.26" />
<PackageReference Include="Uno.UI" Version="$(CommonUnoPackageVersion)" />
</ItemGroup>

<PropertyGroup Condition="'$(IsUno)' == 'true'">
<UnoUIUseRoslynSourceGenerators>true</UnoUIUseRoslynSourceGenerators>
</PropertyGroup>

<ItemGroup Condition="'$(IsWasm)' == 'true' OR '$(IsWpf)' == 'true' OR '$(IsGtk)' == 'true'">
<PackageReference Include="Uno.UI.RemoteControl" Version="4.9.26" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.RemoteControl" Version="$(CommonUnoPackageVersion)" Condition="'$(Configuration)'=='Debug'" />
</ItemGroup>

<ItemGroup Condition="'$(IsGtkHead)' == 'true'">
<PackageReference Include="Uno.UI.Skia.Gtk" Version="4.9.26" />
<PackageReference Include="Uno.UI.Skia.Gtk" Version="$(CommonUnoPackageVersion)" />
</ItemGroup>

<ItemGroup Condition="'$(IsWpfHead)' == 'true'">
<PackageReference Include="Uno.UI.Skia.Wpf" Version="4.9.26" />
<PackageReference Include="Uno.UI.Skia.Wpf" Version="$(CommonUnoPackageVersion)" />
</ItemGroup>

<PropertyGroup Condition="'$(IsWpfHead)' == 'true'">
Expand All @@ -35,6 +39,6 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsWasmHead)' == 'true'">
<PackageReference Include="Uno.UI.WebAssembly" Version="4.9.26" />
<PackageReference Include="Uno.UI.WebAssembly" Version="$(CommonUnoPackageVersion)" />
</ItemGroup>
</Project>
18 changes: 9 additions & 9 deletions MultiTarget/UseTargetFrameworks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

Note: Projects which rely on target platforms that are excluded will be unable to build.
.PARAMETER targets
List of targets to set as TFM platforms to build for. This can also be 'all', 'all-uwp', or blank.
When run as blank, teh defaults (uwp, winappsdk, wasm) will be used.
List of targets to set as TFM platforms to build for. Possible values match those provided to the <MultiTarget> MSBuild property, as well as 'all', 'all-uwp', or blank.
When run as blank, the defaults (uwp, winappsdk, wasm) will be used.
'all' and 'all-uwp' shouldn't be used with other targets or each other.
.PARAMETER allowGitChanges
Enabling this flag will allow changes to the props file to be checked into source control.
Expand All @@ -23,15 +23,15 @@
#>
Param (
[Parameter(HelpMessage = "The target frameworks to enable.")]
[ValidateSet('all', 'all-uwp', 'wasm', 'uwp', 'winappsdk', 'wpf', 'gtk', 'macos', 'ios', 'droid', 'netstandard')]
[ValidateSet('all', 'all-uwp', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
Arlodotexe marked this conversation as resolved.
Show resolved Hide resolved
[string[]]$targets = @('uwp', 'winappsdk', 'wasm') # default settings
)

$UwpTfm = "UwpTargetFramework";
$WinAppSdkTfm = "WinAppSdkTargetFramework";
$WasmTfm = "NetStandardCommonTargetFramework";
$WpfTfm = "NetStandardCommonTargetFramework";
$GtkTfm = "NetStandardCommonTargetFramework";
$WasmTfm = "NetCoreCommonTargetFramework";
$WpfTfm = "NetCoreCommonTargetFramework";
$GtkTfm = "NetCoreCommonTargetFramework";
$macOSTfm = "MacOSLibTargetFramework";
$iOSTfm = "iOSLibTargetFramework";
$DroidTfm = "AndroidLibTargetFramework";
Expand Down Expand Up @@ -69,15 +69,15 @@ if ($targets.Contains("uwp")) {
$desiredTfmValues += $UwpTfm;
}

if ($targets.Contains("winappsdk")) {
if ($targets.Contains("wasdk")) {
$desiredTfmValues += $WinAppSdkTfm;
}

if ($targets.Contains("wpf")) {
$desiredTfmValues += $WpfTfm;
}

if ($targets.Contains("gtk")) {
if ($targets.Contains("linuxgtk")) {
$desiredTfmValues += $GtkTfm;
}

Expand All @@ -89,7 +89,7 @@ if ($targets.Contains("ios")) {
$desiredTfmValues += $iOSTfm;
}

if ($targets.Contains("droid")) {
if ($targets.Contains("android")) {
$desiredTfmValues += $DroidTfm;
}

Expand Down
5 changes: 5 additions & 0 deletions MultiTarget/WinUI.Extra.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(IsUno)' == 'true'">
<!-- Xaml Trimming: https://platform.uno/docs/articles/features/resources-trimming.html -->
<UnoXamlResourcesTrimming>true</UnoXamlResourcesTrimming>
</PropertyGroup>

<PropertyGroup>
<!-- These suppressions are for references between generated assemblies and that VS can keep in the Error List once resolved -->
<NoWarn>$(NoWarn);WMC1006;CS8034;</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// From https://dev.to/stefnotch/enabling-coop-coep-without-touching-the-server-2d3n

self.addEventListener("install", function () {
self.skipWaiting();
});

self.addEventListener("activate", (event) => {
event.waitUntil(self.clients.claim());
});

self.addEventListener("fetch", function (event) {
if (event.request.cache === "only-if-cached" && event.request.mode !== "same-origin") {
return;
}

event.respondWith(
fetch(event.request)
.then(function (response) {
// It seems like we only need to set the headers for index.html
// If you want to be on the safe side, comment this out
// if (!response.url.includes("index.html")) return response;

const newHeaders = new Headers(response.headers);
newHeaders.set("Cross-Origin-Embedder-Policy", "credentialless");
newHeaders.set("Cross-Origin-Opener-Policy", "same-origin");

const moddedResponse = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});

return moddedResponse;
})
.catch(function (e) {
console.error(e);
})
);
});
38 changes: 38 additions & 0 deletions ProjectHeads/AllComponents/Wasm/wwwroot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />

<!--
Only needed if multithreading is enabled.
Required for using SharedArrayBuffer
-->
<script type="text/javascript" src="scripts/EnableSharedArrayBuffer.js"></script>
<script type="text/javascript" src="./require.js"></script>
<script type="module" src="./uno-bootstrap.js"></script>
$(ADDITIONAL_CSS)
$(ADDITIONAL_HEAD)
</head>
<body>
<div id="uno-body" class="container-fluid uno-body">
<div class="uno-loader"
loading-position="bottom"
loading-alert="none">

<!-- Logo: change src to customize the logo -->
<img class="logo"
src=""
title="Uno is loading your application" />

<progress></progress>
<span class="alert"></span>
</div>
</div>
<noscript>
<p>This application requires Javascript and WebAssembly to be enabled.</p>
</noscript>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// From https://dev.to/stefnotch/enabling-coop-coep-without-touching-the-server-2d3n

if ("serviceWorker" in navigator) {
// Register service worker
navigator.serviceWorker.register(new URL("SharedArrayBufferServiceWorker.js", window.location.href)).then(
function (registration) {
console.log("COOP/COEP Service Worker registered", registration.scope);
// If the registration is active, but it's not controlling the page
if (registration.active && !navigator.serviceWorker.controller) {
window.location.reload();
}
},
function (err) {
console.log("COOP/COEP Service Worker failed to register", err);
}
);
} else {
console.warn("Cannot register a service worker");
}
Loading
Loading