Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 62 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,26 @@ jobs:
with:
global-json-file: tooling/global.json

- name: Install .NET workloads
run: dotnet workload install wasm-tools

- name: .NET Info (if diagnostics)
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
run: dotnet --info

- name: Copy props files to root
shell: pwsh
working-directory: ./
run: copy ./tooling/.github/workflows/config/* ./
run: |
copy ./tooling/.github/workflows/config/* ./
copy ./tooling/global.json ./

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

- name: Add project heads to ProjectTemplate
working-directory: ./${{ env.PROJECT_DIRECTORY }}
run: ${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1 -componentPath ${{ github.workspace }}/${{ env.PROJECT_DIRECTORY }}${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}
run: ${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1 -IncludeUnoSdkHead -componentPath ${{ github.workspace }}/${{ env.PROJECT_DIRECTORY }}${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}

# Build and use template for creating new experiments
- name: Build ProjectTemplate
Expand All @@ -145,6 +150,9 @@ jobs:
# WinUI 2 not supported on wasdk
- winui: 2
multitarget: wasdk
# WinUI 2 not supported on wasm (Uno 6.x dropped Uno.UI)
- winui: 2
multitarget: wasm
# WinUI 3 not supported on uwp
- winui: 3
multitarget: uwp
Expand Down Expand Up @@ -177,6 +185,10 @@ jobs:
with:
global-json-file: tooling/global.json

- name: Install .NET workloads
if: ${{ matrix.multitarget == 'wasm' }}
run: dotnet workload install wasm-tools

- name: .NET Info (if diagnostics)
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
run: dotnet --info
Expand All @@ -186,6 +198,7 @@ jobs:
working-directory: ./
run: |
copy ./tooling/.github/workflows/config/* ./
copy ./tooling/global.json ./
mkdir ./.config
copy ./tooling/.config/dotnet-tools.json ./.config/dotnet-tools.json
mkdir ./components
Expand All @@ -209,12 +222,29 @@ jobs:

- name: Add project heads to ${{ env.TEST_PROJECT_NAME }}
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }}
run: ${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1 -MultiTargets ${{ matrix.multitarget }} -winui ${{ matrix.winui }} -componentPath "${{ github.workspace }}/${{ env.TEST_PROJECT_DIRECTORY }}${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}"
run: >-
${{ github.workspace }}/${{ env.HEADS_DIRECTORY }}/GenerateSingleSampleHeads.ps1
-MultiTargets ${{ matrix.multitarget }}
-winui ${{ matrix.winui }}
-componentPath "${{ github.workspace }}/${{ env.TEST_PROJECT_DIRECTORY }}"
${{ matrix.multitarget == 'wasm' && ' -IncludeUnoSdkHead' || '' }}
${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}

- name: MSBuild
if: ${{ matrix.multitarget != 'wasm' }}
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }}
run: msbuild.exe ${{ env.TEST_PROJECT_NAME }}.sln /restore /nowarn:MSB4011 -p:Configuration=Release

- name: Build Uno head (browserwasm)
if: ${{ matrix.multitarget == 'wasm' }}
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }}
run: dotnet build heads/Uno/${{ env.TEST_PROJECT_NAME }}.Uno.csproj -f net9.0-browserwasm -p:Configuration=Release

- name: Build Uno head (desktop)
if: ${{ matrix.multitarget == 'wasm' }}
working-directory: ./${{ env.TEST_PROJECT_DIRECTORY }}
run: dotnet build heads/Uno/${{ env.TEST_PROJECT_NAME }}.Uno.csproj -f net9.0-desktop -p:Configuration=Release

# Run tests
- name: Setup VSTest Path
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44
Expand All @@ -241,10 +271,11 @@ jobs:
name: new-experiment-logs
path: ./**/*.*log

wasm-linux:
runs-on: ubuntu-latest
uno-linux:
runs-on: windows-2022
env:
HEADS_DIRECTORY: tooling/ProjectHeads
PROJECT_DIRECTORY: tooling/ProjectTemplate
TEST_PROJECT_NAME: CiTestExp

steps:
Expand All @@ -259,6 +290,9 @@ jobs:
with:
global-json-file: tooling/global.json

- name: Install .NET workloads
run: dotnet workload install android ios maui wasm-tools

- name: .NET Info (if diagnostics)
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
run: dotnet --info
Expand All @@ -268,10 +302,14 @@ jobs:
working-directory: ./
run: |
copy ./tooling/.github/workflows/config/* ./
copy ./tooling/global.json ./
mkdir ./.config
copy ./tooling/.config/dotnet-tools.json ./.config/dotnet-tools.json
mkdir ./components

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

# Restore Tools from Manifest list in the Repository
- name: Restore dotnet tools
working-directory: ./
Expand All @@ -289,20 +327,34 @@ jobs:
- name: Generate solution
shell: pwsh
working-directory: ./
run: ./tooling/GenerateAllSolution.ps1${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -MultiTargets wasm
run: ./tooling/GenerateAllSolution.ps1 -IncludeUnoSdkHead${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -MultiTargets wasm

- name: dotnet build
shell: pwsh
working-directory: ./
run: ./tooling/Build-Toolkit-Components.ps1 -Release -MultiTargets wasm ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -BinlogOutput ./ -EnableBinLogs' || '' }}

# TODO: Do we want to run tests here? Can we do that on linux easily?

- name: Build Uno head (browserwasm)
shell: pwsh
working-directory: ./
run: >-
dotnet build
tooling/ProjectHeads/AllComponents/Uno/CommunityToolkit.App.Uno.csproj
-f net9.0-browserwasm
-p:Configuration=Release

- name: Build Uno head (desktop)
shell: pwsh
working-directory: ./
run: >-
dotnet build
tooling/ProjectHeads/AllComponents/Uno/CommunityToolkit.App.Uno.csproj
-f net9.0-desktop
-p:Configuration=Release

- name: Artifact - Diagnostic Logs
uses: actions/upload-artifact@v4
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
with:
name: linux-logs
path: ./**/*.*log


14 changes: 7 additions & 7 deletions Build-Toolkit-Components.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
Date: 2/19/2024
#>
Param (
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')]
[Alias("mt")]
[string[]]$MultiTargets = @('uwp', 'wasm', 'wasdk'), # default settings
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]

[ValidateSet('wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$ExcludeMultiTargets = @(), # default settings

[Alias("c")]
Expand Down Expand Up @@ -97,19 +97,19 @@ Param (


if ($MultiTargets -eq 'all') {
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')
}

if ($null -eq $ExcludeMultiTargets)
{
$ExcludeMultiTargets = @()
}

# Both uwp and wasdk share a targetframework. Both cannot be enabled at once.
# If both are supplied, remove one based on WinUIMajorVersion.
# WinUI 2 only builds native UWP (Uno.UI dropped in Uno 6).
# WinUI 3 excludes UWP. Both uwp and wasdk share a targetframework and cannot be enabled at once.
if ($WinUIMajorVersion -eq 2)
{
$ExcludeMultiTargets = $ExcludeMultiTargets + 'wasdk'
$ExcludeMultiTargets = $ExcludeMultiTargets + 'wasdk' + 'wasm' + 'macos' + 'ios' + 'android'
}

if ($WinUIMajorVersion -eq 3)
Expand Down
29 changes: 13 additions & 16 deletions Build-Toolkit-Gallery.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Specifies the MultiTarget TFM(s) to include for building the components. The default value is 'all'.

.PARAMETER ExcludeMultiTargets
Specifies the MultiTarget TFM(s) to exclude for building the components. The default value excludes targets that require additional tooling or workloads to build: 'wpf', 'linuxgtk', 'macos', 'ios', and 'android'. Run uno-check to install the required workloads.
Specifies the MultiTarget TFM(s) to exclude for building the components. The default value excludes targets that require additional tooling or workloads to build. Run uno-check to install the required workloads.

.PARAMETER Heads
The heads to include in the build. Default is 'Uwp', 'Wasdk', 'Wasm'.
Expand Down Expand Up @@ -46,11 +46,11 @@
Date: 2/19/2024
#>
Param (
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]
[ValidateSet('all', 'wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')]
[Alias("mt")]
[string[]]$MultiTargets = @('uwp', 'wasdk', 'wasm'), # default settings
[ValidateSet('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')]

[ValidateSet('wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')]
[string[]]$ExcludeMultiTargets = @(), # default settings

[ValidateSet('all', 'Uwp', 'Wasdk', 'Wasm', 'Tests.Uwp', 'Tests.Wasdk')]
Expand Down Expand Up @@ -87,22 +87,19 @@ if ($null -eq $ExcludeMultiTargets)
$ExcludeMultiTargets = @()
}

# Both uwp and wasdk share a targetframework. Both cannot be enabled at once.
# If both are supplied, remove one based on WinUIMajorVersion.
if ($MultiTargets.Contains('uwp') -and $MultiTargets.Contains('wasdk'))
# WinUI 2 only builds native UWP (Uno.UI dropped in Uno 6).
# WinUI 3 excludes UWP. Both uwp and wasdk share a targetframework and cannot be enabled at once.
if ($WinUIMajorVersion -eq 2)
{
if ($WinUIMajorVersion -eq 2)
{
$ExcludeMultiTargets = $ExcludeMultiTargets + 'wasdk'
}
else
{
$ExcludeMultiTargets = $ExcludeMultiTargets + 'uwp'
}
$ExcludeMultiTargets = $ExcludeMultiTargets + 'wasdk' + 'wasm' + 'macos' + 'ios' + 'android'
}
else
{
$ExcludeMultiTargets = $ExcludeMultiTargets + 'uwp'
}

if ($MultiTargets -eq 'all') {
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'wpf', 'linuxgtk', 'macos', 'ios', 'android', 'netstandard')
$MultiTargets = @('wasm', 'uwp', 'wasdk', 'macos', 'ios', 'android', 'netstandard')
}

if ($ExcludeMultiTargets) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,80 +16,11 @@
#endif
#endif

#if HAS_UNO_WASM
using Markdig;
using Uno.Foundation.Interop;
using Uno.UI.Runtime.WebAssembly;
#endif

namespace CommunityToolkit.App.Shared.Renderers;

/// <summary>
/// Provide an abstraction around the Toolkit MarkdownTextBlock for both UWP and WinUI 3 in the same namespace (until 8.0) as well as a polyfill for WebAssembly/WASM.
/// </summary>
#if HAS_UNO_WASM
[HtmlElement("div")]
public partial class MarkdownTextBlock : TextBlock
{
public MarkdownTextBlock()
{
Loaded += this.MarkdownTextBlock_Loaded;
}

protected override void OnTextChanged(string oldValue, string newValue)
{
if (IsLoaded)
{
UpdateText(newValue);
}
}

private void MarkdownTextBlock_Loaded(object sender, RoutedEventArgs e)
{
this.RegisterHtmlEventHandler("resize", HtmlElementResized);

UpdateText(Text);
}

#nullable enable
private void HtmlElementResized(object? sender, EventArgs e)
{
this.InvalidateMeasure();
}

private void UpdateText(string markdown)
{
// TODO: Check color hasn't changed since last time.
var color = (Foreground as SolidColorBrush)?.Color;
if (color != null)
{
this.SetCssStyle(("color", $"#{color!.ToString()!.Substring(3)}"), ("font-family", "Segoe UI"));
}
else
{
this.SetCssStyle("fontFamily", "Segoe UI");
}

this.SetCssClass("fluent-hyperlink-style");

this.SetHtmlContent(Markdown.ToHtml(markdown));

this.InvalidateMeasure();
}

protected override Size MeasureOverride(Size availableSize)
{
var size = this.MeasureHtmlView(availableSize, true);

return size;
}

//// Polyfill dummy for event callback
#pragma warning disable CS0067 // Unused on purpose for polyfill
public event EventHandler<LinkClickedEventArgs>? LinkClicked;
#pragma warning restore CS0067 // Unused on purpose for polyfill
}
#else
public partial class MarkdownTextBlock : ToolkitMTB
{
#if !HAS_UNO
Expand All @@ -105,7 +36,6 @@ public MarkdownTextBlock()
#pragma warning restore CS0067 // Unused on purpose for polyfill
#endif
}
#endif

#if HAS_UNO
//// Polyfill dummy for event callback
Expand Down
Loading
Loading