Skip to content

Commit f7628c0

Browse files
authored
Merge branch 'main' into feat/winui3-themelistener
2 parents e26b54c + 9c7642f commit f7628c0

File tree

7 files changed

+127
-77
lines changed

7 files changed

+127
-77
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
]
1616
},
1717
"microsoft.visualstudio.slngen.tool": {
18-
"version": "11.2.3",
18+
"version": "11.2.6",
1919
"commands": [
2020
"slngen"
2121
]
2222
}
2323
}
24-
}
24+
}

.github/workflows/build.yml

Lines changed: 111 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ jobs:
6161

6262
# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
6363
strategy:
64-
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
64+
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
6565
matrix:
66-
platform: [WinUI2, WinUI3]
67-
68-
env:
69-
# faux-ternary expression to select which platforms to build for each platform vs. duplicating step below.
70-
TARGET_PLATFORMS: ${{ matrix.platform != 'WinUI3' && 'all-wasdk' || 'all-uwp' }}
71-
TEST_PLATFORM: ${{ matrix.platform != 'WinUI3' && 'UWP' || 'WinAppSdk' }}
72-
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
66+
winui: [2, 3]
67+
multitarget: ['uwp', 'wasdk', 'wasm', 'wpf', 'linuxgtk', 'macos', 'ios', 'android']
68+
exclude:
69+
# WinUI 2 not supported on wasdk
70+
- winui: 2
71+
multitarget: wasdk
72+
# WinUI 3 not supported on uwp
73+
- winui: 3
74+
multitarget: uwp
7375

7476
# Steps represent a sequence of tasks that will be executed as part of the job
7577
steps:
@@ -109,9 +111,11 @@ jobs:
109111
run: dotnet tool restore
110112

111113
- name: Run Uno Check to Install Dependencies
114+
if: ${{ matrix.multitarget != 'wasdk' && matrix.multitarget != 'linuxgtk' && matrix.multitarget != 'wpf' }}
112115
run: >
113116
dotnet tool run uno-check
114117
--ci
118+
--target ${{ matrix.multitarget }}
115119
--fix
116120
--non-interactive
117121
--skip wsl
@@ -124,58 +128,21 @@ jobs:
124128
with:
125129
vs-version: '[17.9,)'
126130

127-
- name: Enable ${{ env.TARGET_PLATFORMS }} TargetFrameworks
128-
working-directory: ./${{ env.MULTI_TARGET_DIRECTORY }}
129-
run: powershell -version 5.1 -command "./UseTargetFrameworks.ps1 ${{ env.TARGET_PLATFORMS }}" -ErrorAction Stop
130-
131-
- name: Generate solution w/ ${{ env.TEST_PLATFORM }} Tests
131+
# Generate full solution with all projects (sample gallery heads, components, tests)
132+
- name: Generate solution with ${{ matrix.multitarget }} gallery, components and tests
132133
working-directory: ./
133-
run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -IncludeHeads ${{ env.TEST_PLATFORM }}${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }}" -ErrorAction Stop
134-
135-
- name: Enable Uno.WinUI (in WinUI3 matrix only)
136-
if: ${{ matrix.platform == 'WinUI3' }}
137-
working-directory: ./${{ env.MULTI_TARGET_DIRECTORY }}
138-
run: powershell -version 5.1 -command "./UseUnoWinUI.ps1 3" -ErrorAction Stop
139-
140-
- name: Format Date/Time of Commit for Package Version
141-
if: ${{ env.IS_RELEASE == 'false' }}
142-
run: |
143-
echo "VERSION_DATE=$(git log -1 --format=%cd --date=format:%y%m%d)" >> $env:GITHUB_ENV
144-
145-
# Semver regex: https://regex101.com/r/Ly7O1x/3/
146-
- name: Format Date/Time of Release Package Version
147-
if: ${{ env.IS_RELEASE == 'true' }}
148-
run: |
149-
$ref = "${{ github.ref }}"
150-
$ref -match "^refs/heads/rel/(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
151-
echo "VERSION_DATE=$($matches['patch'])" >> $env:GITHUB_ENV
152-
echo "VERSION_PROPERTY=$($matches['prerelease'])" >> $env:GITHUB_ENV
134+
run: powershell -version 5.1 -command "./tooling/GenerateAllSolution.ps1 -MultiTargets ${{ matrix.multitarget }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && ' -UseDiagnostics' || '' }} -WinUIMajorVersion ${{ matrix.winui }}" -ErrorAction Stop
153135

136+
# Build solution
154137
- name: MSBuild
155138
run: >
156139
msbuild.exe /restore /nowarn:MSB4011
157140
/p:Configuration=Release
158141
/m
159-
/p:DateForVersion=${{ env.VERSION_DATE }}
160-
/p:PreviewVersion=${{ env.VERSION_PROPERTY }}
161142
${{ env.ENABLE_DIAGNOSTICS == 'true' && '/bl' || '' }}
162143
/v:${{ env.MSBUILD_VERBOSITY }}
163144
CommunityToolkit.AllComponents.sln
164145
165-
# Build All Packages
166-
- name: pack experiments
167-
working-directory: ./tooling/Scripts/
168-
run: ./PackEachExperiment.ps1 -date ${{ env.VERSION_DATE }}${{ env.VERSION_PROPERTY != '' && format(' -postfix {0}', env.VERSION_PROPERTY) || '' }}
169-
170-
# Push Pull Request Packages to our DevOps Artifacts Feed (see nuget.config)
171-
- name: Push Pull Request Packages (if not fork)
172-
if: ${{ env.IS_PR == 'true' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
173-
run: |
174-
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
175-
--name PullRequests `
176-
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
177-
dotnet nuget push "**/*.nupkg" --api-key dummy --source PullRequests --skip-duplicate
178-
179146
# Run tests
180147
- name: Setup VSTest Path
181148
uses: darenm/setup-vstest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44
@@ -189,20 +156,21 @@ jobs:
189156
id: test-generator
190157
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net6.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
191158

192-
- name: Run experiment tests against ${{ env.TEST_PLATFORM }}
159+
- name: Run component tests against ${{ matrix.multitarget }}
160+
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
193161
id: test-platform
194-
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ env.TEST_PLATFORM }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ env.TEST_PLATFORM }}.trx" /Blame
162+
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame
195163

196164
- name: Create test reports
197165
run: |
198-
testspace '[${{ matrix.platform }}]./TestResults/*.trx'
199-
if: ${{ always() && (steps.test-generator.conclusion == 'success' || steps.test-platform.conclusion == 'success') }}
166+
testspace '[${{ matrix.multitarget }}]./TestResults/*.trx'
167+
if: ${{ (matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk') && (steps.test-generator.conclusion == 'success' || steps.test-platform.conclusion == 'success') }}
200168

201169
- name: Artifact - Diagnostic Logs
202170
uses: actions/upload-artifact@v4
203171
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
204172
with:
205-
name: build-logs-${{ matrix.platform }}
173+
name: build-logs-${{ matrix.multitarget }}-winui${{ matrix.winui }}
206174
path: ./**/*.*log
207175

208176
- name: Artifact - ILC Repro
@@ -224,7 +192,7 @@ jobs:
224192
uses: actions/upload-artifact@v4
225193
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
226194
with:
227-
name: CrashDumps-${{ matrix.platform }}
195+
name: CrashDumps-${{ matrix.multitarget }}-winui${{ matrix.winui }}
228196
path: '${{ github.workspace }}/CrashDumps'
229197

230198
- name: Analyze Dump
@@ -233,11 +201,84 @@ jobs:
233201
dotnet tool install --global dotnet-dump
234202
dotnet-dump analyze ${{ steps.detect-dump.outputs.DUMP_FILE }} -c "clrstack" -c "pe -lines" -c "exit"
235203
204+
package:
205+
runs-on: windows-latest
206+
needs: [build]
207+
strategy:
208+
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
209+
matrix:
210+
winui: [2, 3]
211+
212+
env:
213+
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
214+
215+
steps:
216+
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
217+
uses: actions/setup-dotnet@v4
218+
with:
219+
dotnet-version: ${{ env.DOTNET_VERSION }}
220+
221+
- name: .NET Info (if diagnostics)
222+
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
223+
run: dotnet --info
224+
225+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
226+
- name: Checkout Repository
227+
uses: actions/checkout@v4
228+
with:
229+
submodules: recursive
230+
231+
# Semver regex: https://regex101.com/r/Ly7O1x/3/
232+
- name: Format Date/Time of Release Package Version
233+
if: ${{ env.IS_RELEASE == 'true' }}
234+
run: |
235+
$ref = "${{ github.ref }}"
236+
$ref -match "^refs/heads/rel/(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
237+
echo "VERSION_DATE=$($matches['patch'])" >> $env:GITHUB_ENV
238+
echo "VERSION_PROPERTY=$($matches['prerelease'])" >> $env:GITHUB_ENV
239+
240+
- name: Format Date/Time of Commit for Package Version
241+
if: ${{ env.IS_RELEASE == 'false' }}
242+
run: |
243+
echo "VERSION_DATE=$(git log -1 --format=%cd --date=format:%y%m%d)" >> $env:GITHUB_ENV
244+
245+
- name: Restore dotnet tools
246+
run: dotnet tool restore
247+
248+
- name: Run Uno Check to Install Dependencies
249+
run: >
250+
dotnet tool run uno-check
251+
--ci
252+
--fix
253+
--non-interactive
254+
--skip wsl
255+
--skip androidemulator
256+
--skip vswinworkloads
257+
--verbose
258+
259+
- name: Add msbuild to PATH
260+
uses: microsoft/setup-msbuild@v2
261+
with:
262+
vs-version: '[17.9,)'
263+
264+
# Build and pack component nupkg
265+
- name: Build and pack component packages
266+
run: ./tooling/Build-Toolkit-Components.ps1 -MultiTargets all -WinUIMajorVersion ${{ matrix.winui }} -DateForVersion ${{ env.VERSION_DATE }} ${{ env.VERSION_PROPERTY != '' && format('-PreviewVersion "{0}"', env.VERSION_PROPERTY) || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-EnableBinlogs' || '' }} ${{ env.ENABLE_DIAGNOSTICS == 'true' && '-Verbose' || '' }} -BinlogOutput ./ -NupkgOutput ./ -Release
267+
268+
# Push Pull Request Packages to our DevOps Artifacts Feed (see nuget.config)
269+
- name: Push Pull Request Packages (if not fork)
270+
if: ${{ env.IS_PR == 'true' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
271+
run: |
272+
dotnet nuget add source https://pkgs.dev.azure.com/dotnet/CommunityToolkit/_packaging/CommunityToolkit-PullRequests/nuget/v3/index.json `
273+
--name PullRequests `
274+
--username dummy --password ${{ secrets.DEVOPS_PACKAGE_PUSH_TOKEN }}
275+
dotnet nuget push "*.nupkg" --api-key dummy --source PullRequests --skip-duplicate
276+
236277
- name: Upload Package List
237278
uses: actions/upload-artifact@v4
238279
if: ${{ env.IS_PR == 'false' }}
239280
with:
240-
name: nuget-list-${{ matrix.platform }}
281+
name: nuget-list-${{ matrix.winui }}
241282
if-no-files-found: error
242283
path: |
243284
${{ github.workspace }}/.github/workflows/SignClientFileList.txt
@@ -247,13 +288,20 @@ jobs:
247288
uses: actions/upload-artifact@v4
248289
if: ${{ env.IS_PR == 'false' || github.event.pull_request.head.repo.full_name != github.repository }}
249290
with:
250-
name: nuget-packages-${{ matrix.platform }}
291+
name: nuget-packages-winui${{ matrix.winui }}
251292
if-no-files-found: error
252293
path: |
253-
**/*.nupkg
294+
./*.nupkg
295+
296+
- name: Artifact - Diagnostic Logs
297+
uses: actions/upload-artifact@v4
298+
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
299+
with:
300+
name: build-logs-winui${{ matrix.winui }}
301+
path: ./*.*log
254302

255303
sign:
256-
needs: [build]
304+
needs: [package]
257305
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/rel/') }}
258306
runs-on: windows-latest
259307
permissions:
@@ -262,7 +310,7 @@ jobs:
262310
strategy:
263311
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them both to run to completion.
264312
matrix:
265-
platform: [WinUI2, WinUI3]
313+
winui: [2, 3]
266314

267315
steps:
268316
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
@@ -273,13 +321,13 @@ jobs:
273321
- name: Download Package List
274322
uses: actions/download-artifact@v4
275323
with:
276-
name: nuget-list-${{ matrix.platform }}
324+
name: nuget-list-${{ matrix.winui }}
277325
path: ./
278326

279-
- name: Download built packages for ${{ matrix.platform }}
327+
- name: Download built packages for WinUI ${{ matrix.winui }}
280328
uses: actions/download-artifact@v4
281329
with:
282-
name: nuget-packages-${{ matrix.platform }}
330+
name: nuget-packages-winui${{ matrix.winui }}
283331
path: ./packages
284332

285333
- name: Install Signing Tool

GenerateAllSolution.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@ECHO OFF
2-
SET "IncludeHeads=%1"
3-
IF "%IncludeHeads%"=="" SET "IncludeHeads=all"
2+
SET "MultiTargets=%1"
3+
IF "%MultiTargets%"=="" SET "MultiTargets=all"
44

5-
powershell .\tooling\GenerateAllSolution.ps1 -IncludeHeads %IncludeHeads%
5+
powershell .\tooling\GenerateAllSolution.ps1 -MultiTargets %MultiTargets%

components/Sizers/src/SizerBase.Properties.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ private static void OnOrientationPropertyChanged(DependencyObject d, DependencyP
132132
return;
133133
#endif
134134

135-
// TODO: [UNO] Only supported on certain platforms
136-
// See ProtectedCursor here: https://github.com/unoplatform/uno/blob/3fe3862b270b99dbec4d830b547942af61b1a1d9/src/Uno.UI/UI/Xaml/UIElement.cs#L1015-L1023
137-
#if WINAPPSDK && !HAS_UNO
135+
#if WINUI3
138136
// Need to wait until we're at least applying template step of loading before setting Cursor
139137
// See https://github.com/microsoft/microsoft-ui-xaml/issues/7062
140138
if (gripper._appliedTemplate &&

components/Sizers/src/SizerBase.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ protected override AutomationPeer OnCreateAutomationPeer()
100100
return new SizerAutomationPeer(this);
101101
}
102102

103-
// On Uno the ProtectedCursor isn't supported yet, so we don't need this value.
104-
#if WINAPPSDK && !HAS_UNO
103+
#if WINUI3
105104
// Used to track when we're in the OnApplyTemplateStep to change ProtectedCursor value.
106105
private bool _appliedTemplate = false;
107106
#endif
@@ -133,7 +132,7 @@ protected override void OnApplyTemplate()
133132

134133
// Trigger initial state transition based on if we're Enabled or not currently.
135134
SizerBase_IsEnabledChanged(this, null!);
136-
#if WINAPPSDK && !HAS_UNO
135+
#if WINUI3
137136
// On WinAppSDK, we'll trigger this to setup the initial ProtectedCursor value.
138137
_appliedTemplate = true;
139138
#endif

components/Triggers/src/IsNullOrEmptyStateTrigger.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,13 @@ private static bool IsNullOrEmpty(object val)
117117
}
118118

119119
// Object is not an ICollection, check for an empty IEnumerable
120-
var valEnumerable = val as IEnumerable;
121-
if (valEnumerable != null)
120+
if (val is IEnumerable valEnumerable
121+
// Workaround to regression introduced in https://github.com/unoplatform/uno/pull/16834
122+
// Track https://github.com/unoplatform/uno/issues/17311 for cleanup
123+
#if HAS_UNO
124+
&& val is not FrameworkElement
125+
#endif
126+
)
122127
{
123128
foreach (var item in valEnumerable)
124129
{

0 commit comments

Comments
 (0)