Skip to content

Commit 31d57d8

Browse files
authored
Merge branch 'main' into Color-Helper
2 parents 7581b38 + 55b92b8 commit 31d57d8

File tree

16 files changed

+427
-261
lines changed

16 files changed

+427
-261
lines changed

.github/workflows/build.yml

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
merge_group:
1818

1919
env:
20-
DOTNET_VERSION: ${{ '9.0.x' }}
20+
DOTNET_VERSION: '9.0.310' # Only used by jobs that cannot access global.json (no checkout/artifact-only jobs)
2121
ENABLE_DIAGNOSTICS: true
2222
MSBUILD_VERBOSITY: normal
2323
#COREHOST_TRACE: 1
@@ -36,17 +36,17 @@ jobs:
3636

3737
# Steps represent a sequence of tasks that will be executed as part of the job
3838
steps:
39-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
40-
uses: actions/setup-dotnet@v4
41-
with:
42-
dotnet-version: ${{ env.DOTNET_VERSION }}
43-
4439
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
4540
- name: Checkout Repository
4641
uses: actions/checkout@v4
4742
with:
4843
submodules: recursive
4944

45+
- name: Install .NET SDK
46+
uses: actions/setup-dotnet@v4
47+
with:
48+
global-json-file: global.json
49+
5050
# Restore Tools from Manifest list in the Repository
5151
- name: Restore dotnet tools
5252
run: dotnet tool restore
@@ -59,6 +59,9 @@ jobs:
5959
needs: [Xaml-Style-Check]
6060
runs-on: windows-2022
6161

62+
env:
63+
PROCDUMP_PATH: ${{ github.workspace }}
64+
6265
# See https://docs.github.com/actions/using-jobs/using-a-matrix-for-your-jobs
6366
strategy:
6467
fail-fast: false # prevent one matrix pipeline from being cancelled if one fails, we want them all to run to completion.
@@ -82,29 +85,27 @@ jobs:
8285
maximum-size: 32GB
8386
disk-root: "C:"
8487

85-
- name: Enable User-Mode Dumps collecting
86-
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '' }}
87-
shell: powershell
88-
run: |
89-
New-Item '${{ github.workspace }}\CrashDumps' -Type Directory
90-
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps' -Name 'DumpFolder' -Type ExpandString -Value '${{ github.workspace }}\CrashDumps'
91-
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps' -Name 'DumpCount' -Type DWord -Value '10'
92-
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps' -Name 'DumpType' -Type DWord -Value '2'
88+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
89+
- name: Checkout Repository
90+
uses: actions/checkout@v4
91+
with:
92+
submodules: recursive
9393

94-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
94+
- name: Install .NET SDK
9595
uses: actions/setup-dotnet@v4
9696
with:
97-
dotnet-version: ${{ env.DOTNET_VERSION }}
97+
global-json-file: global.json
9898

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

103-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
104-
- name: Checkout Repository
105-
uses: actions/checkout@v4
106-
with:
107-
submodules: recursive
103+
- name: Install procdump
104+
if: ${{ env.ENABLE_DIAGNOSTICS == 'true' }}
105+
shell: pwsh
106+
run: |
107+
Invoke-WebRequest -Uri https://download.sysinternals.com/files/Procdump.zip -OutFile Procdump.zip
108+
Expand-Archive -Path Procdump.zip -DestinationPath ${{ env.PROCDUMP_PATH }}
108109
109110
# Restore Tools from Manifest list in the Repository
110111
- name: Restore dotnet tools
@@ -157,10 +158,17 @@ jobs:
157158
id: test-generator
158159
run: vstest.console.exe ./tooling/CommunityToolkit.Tooling.SampleGen.Tests/bin/Release/net8.0/CommunityToolkit.Tooling.SampleGen.Tests.dll /logger:"trx;LogFileName=SourceGenerators.trx"
159160

161+
- name: Start Procdump monitoring for first-chance exceptions
162+
if: ${{ (matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk') && env.ENABLE_DIAGNOSTICS == 'true' }}
163+
shell: pwsh
164+
run: |
165+
$procdumpArgs = @("-accepteula", "-e", "1", "-w", "CommunityToolkit.Tests.${{ matrix.multitarget }}.exe", "-ma", "${{ env.PROCDUMP_PATH }}")
166+
Start-Process -FilePath "${{ env.PROCDUMP_PATH }}/procdump64.exe" -ArgumentList $procdumpArgs -NoNewWindow
167+
160168
- name: Run component tests against ${{ matrix.multitarget }}
161169
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
162170
id: test-platform
163-
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame
171+
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame:"CollectDump;DumpType=Full;CollectHangDump;TestTimeout=30m;HangDumpType=Full" /Diag:"${{ github.workspace }}/vstest-diagnostic-log.txt"
164172

165173
- name: Create test reports
166174
run: |
@@ -178,7 +186,7 @@ jobs:
178186
uses: actions/upload-artifact@v4
179187
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
180188
with:
181-
name: ilc-repro
189+
name: ilc-repro-${{ matrix.multitarget }}-winui${{ matrix.winui }}
182190
path: ./*.zip
183191

184192
# https://github.com/dorny/paths-filter#custom-processing-of-changed-files
@@ -187,14 +195,21 @@ jobs:
187195
if: always()
188196
working-directory: ${{ github.workspace }}
189197
run: |
190-
echo "DUMP_FILE=$(Get-ChildItem .\CrashDumps\*.dmp -ErrorAction SilentlyContinue)" >> $env:GITHUB_OUTPUT
198+
echo "DUMP_FILE=$(Get-ChildItem ${{ env.PROCDUMP_PATH }}/**/*.dmp -ErrorAction SilentlyContinue)" >> $env:GITHUB_OUTPUT
191199
192-
- name: Artifact - WER crash dumps
200+
- name: Artifact - Process Dumps
193201
uses: actions/upload-artifact@v4
194202
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
195203
with:
196204
name: CrashDumps-${{ matrix.multitarget }}-winui${{ matrix.winui }}
197-
path: '${{ github.workspace }}/CrashDumps'
205+
path: ${{ env.PROCDUMP_PATH }}/**/*.dmp
206+
207+
- name: Artifact - vstest-diagnostic-log
208+
uses: actions/upload-artifact@v4
209+
if: always()
210+
with:
211+
name: 'vstest-diagnostic-log-${{ matrix.multitarget }}-winui${{ matrix.winui }}.txt'
212+
path: '${{ github.workspace }}/vstest-diagnostic-log.txt'
198213

199214
- name: Analyze Dump
200215
if: ${{ steps.detect-dump.outputs.DUMP_FILE != '' && (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
@@ -214,21 +229,21 @@ jobs:
214229
VERSION_PROPERTY: ${{ github.ref == 'refs/heads/main' && format('build.{0}', github.run_number) || format('pull-{0}.{1}', github.event.number, github.run_number) }}
215230

216231
steps:
217-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
232+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
233+
- name: Checkout Repository
234+
uses: actions/checkout@v4
235+
with:
236+
submodules: recursive
237+
238+
- name: Install .NET SDK
218239
uses: actions/setup-dotnet@v4
219240
with:
220-
dotnet-version: ${{ env.DOTNET_VERSION }}
241+
global-json-file: global.json
221242

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

226-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
227-
- name: Checkout Repository
228-
uses: actions/checkout@v4
229-
with:
230-
submodules: recursive
231-
232247
# Semver regex: https://regex101.com/r/Ly7O1x/3/
233248
- name: Format Date/Time of Release Package Version
234249
if: ${{ env.IS_RELEASE == 'true' }}
@@ -325,7 +340,7 @@ jobs:
325340
winui: [2, 3]
326341

327342
steps:
328-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
343+
- name: Install .NET SDK
329344
uses: actions/setup-dotnet@v4
330345
with:
331346
dotnet-version: ${{ env.DOTNET_VERSION }}
@@ -390,7 +405,7 @@ jobs:
390405
winui: [2, 3]
391406

392407
steps:
393-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
408+
- name: Install .NET SDK
394409
uses: actions/setup-dotnet@v4
395410
with:
396411
dotnet-version: ${{ env.DOTNET_VERSION }}
@@ -413,21 +428,21 @@ jobs:
413428
runs-on: ubuntu-latest
414429

415430
steps:
416-
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
431+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
432+
- name: Checkout Repository
433+
uses: actions/checkout@v4
434+
with:
435+
submodules: recursive
436+
437+
- name: Install .NET SDK
417438
uses: actions/setup-dotnet@v4
418439
with:
419-
dotnet-version: ${{ env.DOTNET_VERSION }}
440+
global-json-file: global.json
420441

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

425-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
426-
- name: Checkout Repository
427-
uses: actions/checkout@v4
428-
with:
429-
submodules: recursive
430-
431446
# Restore Tools from Manifest list in the Repository
432447
- name: Restore dotnet tools
433448
run: dotnet tool restore
@@ -459,3 +474,4 @@ jobs:
459474
with:
460475
name: linux-logs
461476
path: ./**/*.*log
477+

components/ColorPicker/tests/ExampleColorPickerTestClass.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,22 @@ await EnqueueAsync(() =>
9797

9898
// If you want to load other content not within a XAML page using the UIThreadTestMethod above.
9999
// Then you can do that using the Load/UnloadTestContentAsync methods.
100-
[TestMethod]
100+
[UIThreadTestMethod]
101101
public async Task ComplexAsyncLoadUIExampleTest()
102102
{
103-
await EnqueueAsync(async () =>
104-
{
105-
var component = new ColorPicker();
106-
Assert.IsNotNull(component);
107-
Assert.IsFalse(component.IsLoaded);
103+
var component = new ColorPicker();
104+
Assert.IsNotNull(component);
105+
Assert.IsFalse(component.IsLoaded);
108106

109-
await LoadTestContentAsync(component);
107+
await LoadTestContentAsync(component);
108+
await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { });
110109

111-
Assert.IsTrue(component.IsLoaded);
110+
Assert.IsTrue(component.IsLoaded);
112111

113-
await UnloadTestContentAsync(component);
112+
await UnloadTestContentAsync(component);
113+
await CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() => { });
114114

115-
Assert.IsFalse(component.IsLoaded);
116-
});
115+
Assert.IsFalse(component.IsLoaded);
117116
}
118117

119118
// You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well:

components/Extensions/src/Shadows/AttachedShadowBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ protected internal virtual void OnElementContextInitialized(AttachedShadowElemen
161161
/// <param name="context">The <see cref="AttachedShadowElementContext"/> that is being uninitialized.</param>
162162
protected internal virtual void OnElementContextUninitialized(AttachedShadowElementContext context)
163163
{
164-
context.ClearAndDisposeResources();
165164
ElementCompositionPreview.SetElementChildVisual(context.Element, null!);
165+
context.ClearAndDisposeResources();
166166
}
167167

168168
/// <inheritdoc/>

components/Extensions/src/Shadows/AttachedShadowElementContext.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ private void Uninitialize()
135135

136136
IsInitialized = false;
137137

138+
if (Element != null)
139+
{
140+
ElementCompositionPreview.SetElementChildVisual(Element, null!);
141+
Element.SizeChanged -= OnElementSizeChanged;
142+
}
143+
138144
Parent.OnElementContextUninitialized(this);
139145

140146
if (SpriteVisual != null)
@@ -148,12 +154,6 @@ private void Uninitialize()
148154
Shadow.Dispose();
149155
}
150156

151-
if (Element != null)
152-
{
153-
ElementCompositionPreview.SetElementChildVisual(Element, null!);
154-
Element.SizeChanged -= OnElementSizeChanged;
155-
}
156-
157157
SpriteVisual = null;
158158
Shadow = null;
159159
ElementVisual = null;

components/Segmented/samples/SegmentedBasicSample.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
22
<Page x:Class="SegmentedExperiment.Samples.SegmentedBasicSample"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -14,6 +14,7 @@
1414
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}"
1515
Text="Icon + content" />
1616
<controls:Segmented HorizontalAlignment="{x:Bind local:SegmentedBasicSample.ConvertStringToHorizontalAlignment(Alignment), Mode=OneWay}"
17+
Orientation="{x:Bind local:SegmentedBasicSample.ConvertStringToOrientation(OrientationMode), Mode=OneWay}"
1718
SelectedIndex="0"
1819
SelectionMode="{x:Bind local:SegmentedBasicSample.ConvertStringToSelectionMode(SelectionMode), Mode=OneWay}">
1920
<controls:SegmentedItem Content="Item 1"
@@ -30,6 +31,7 @@
3031
Style="{StaticResource BodyStrongTextBlockStyle}"
3132
Text="Icon only" />
3233
<controls:Segmented HorizontalAlignment="{x:Bind local:SegmentedBasicSample.ConvertStringToHorizontalAlignment(Alignment), Mode=OneWay}"
34+
Orientation="{x:Bind local:SegmentedBasicSample.ConvertStringToOrientation(OrientationMode), Mode=OneWay}"
3335
SelectedIndex="2"
3436
SelectionMode="{x:Bind local:SegmentedBasicSample.ConvertStringToSelectionMode(SelectionMode), Mode=OneWay}">
3537
<controls:SegmentedItem Icon="{ui:FontIcon Glyph=&#xE8BF;}"

components/Segmented/samples/SegmentedBasicSample.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace SegmentedExperiment.Samples;
1111
/// </summary>
1212
[ToolkitSampleMultiChoiceOption("SelectionMode", "Single", "Multiple", Title = "Selection mode")]
1313
[ToolkitSampleMultiChoiceOption("Alignment", "Left", "Center", "Right", "Stretch", Title = "Horizontal alignment")]
14+
[ToolkitSampleMultiChoiceOption("OrientationMode", "Horizontal", "Vertical", Title = "Orientation")]
1415

1516
[ToolkitSample(id: nameof(SegmentedBasicSample), "Basics", description: $"A sample for showing how to create and use a {nameof(Segmented)} custom control.")]
1617
public sealed partial class SegmentedBasicSample : Page
@@ -36,5 +37,12 @@ public SegmentedBasicSample()
3637
"Stretch" => HorizontalAlignment.Stretch,
3738
_ => throw new System.NotImplementedException(),
3839
};
40+
41+
public static Orientation ConvertStringToOrientation(string orientation) => orientation switch
42+
{
43+
"Horizontal" => Orientation.Horizontal,
44+
"Vertical" => Orientation.Vertical,
45+
_ => throw new System.NotImplementedException(),
46+
};
3947
}
4048

components/Segmented/samples/SegmentedStylesSample.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
22
<Page x:Class="SegmentedExperiment.Samples.SegmentedStylesSample"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -19,7 +19,8 @@
1919
Spacing="8">
2020
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}"
2121
Text="PivotSegmentedStyle" />
22-
<controls:Segmented SelectedIndex="1"
22+
<controls:Segmented Orientation="{x:Bind local:SegmentedStylesSample.ConvertStringToOrientation(OrientationMode), Mode=OneWay}"
23+
SelectedIndex="1"
2324
SelectionMode="{x:Bind local:SegmentedStylesSample.ConvertStringToSelectionMode(SelectionMode), Mode=OneWay}"
2425
Style="{StaticResource PivotSegmentedStyle}">
2526
<controls:SegmentedItem>Item 1</controls:SegmentedItem>
@@ -31,7 +32,8 @@
3132
<TextBlock Margin="0,24,0,0"
3233
Style="{StaticResource BodyStrongTextBlockStyle}"
3334
Text="ButtonSegmentedStyle" />
34-
<controls:Segmented SelectedIndex="0"
35+
<controls:Segmented Orientation="{x:Bind local:SegmentedStylesSample.ConvertStringToOrientation(OrientationMode), Mode=OneWay}"
36+
SelectedIndex="0"
3537
SelectionMode="{x:Bind local:SegmentedStylesSample.ConvertStringToSelectionMode(SelectionMode), Mode=OneWay}"
3638
Style="{StaticResource ButtonSegmentedStyle}">
3739
<controls:SegmentedItem Content="Day"

components/Segmented/samples/SegmentedStylesSample.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace SegmentedExperiment.Samples;
88
/// An sample that shows how the Segmented control has multiple built-in styles.
99
/// </summary>
1010
[ToolkitSampleMultiChoiceOption("SelectionMode", "Single", "Multiple", Title = "Selection mode")]
11+
[ToolkitSampleMultiChoiceOption("OrientationMode", "Horizontal", "Vertical", Title = "Orientation")]
1112

1213
[ToolkitSample(id: nameof(SegmentedStylesSample), "Additional styles", description: "A sample on how to use different built-in styles.")]
1314
public sealed partial class SegmentedStylesSample : Page
@@ -22,4 +23,11 @@ public SegmentedStylesSample()
2223
"Multiple" => ListViewSelectionMode.Multiple,
2324
_ => throw new System.NotImplementedException(),
2425
};
26+
27+
public static Orientation ConvertStringToOrientation(string orientation) => orientation switch
28+
{
29+
"Horizontal" => Orientation.Horizontal,
30+
"Vertical" => Orientation.Vertical,
31+
_ => throw new System.NotImplementedException(),
32+
};
2533
}

0 commit comments

Comments
 (0)