Skip to content

Commit a1f220f

Browse files
authored
Merge branch 'main' into Ryken100/attached-shadow-fix-2
2 parents 5b452a4 + 29b741b commit a1f220f

File tree

2 files changed

+56
-69
lines changed

2 files changed

+56
-69
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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,15 +85,6 @@ 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'
93-
9488
- name: Install .NET SDK v${{ env.DOTNET_VERSION }}
9589
uses: actions/setup-dotnet@v4
9690
with:
@@ -106,6 +100,13 @@ jobs:
106100
with:
107101
submodules: recursive
108102

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 }}
109+
109110
# Restore Tools from Manifest list in the Repository
110111
- name: Restore dotnet tools
111112
run: dotnet tool restore
@@ -160,7 +161,7 @@ jobs:
160161
- name: Run component tests against ${{ matrix.multitarget }}
161162
if: ${{ matrix.multitarget == 'uwp' || matrix.multitarget == 'wasdk' }}
162163
id: test-platform
163-
run: vstest.console.exe ./tooling/**/CommunityToolkit.Tests.${{ matrix.multitarget }}.build.appxrecipe /Framework:FrameworkUap10 /logger:"trx;LogFileName=${{ matrix.multitarget }}.trx" /Blame
164+
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"
164165

165166
- name: Create test reports
166167
run: |
@@ -178,7 +179,7 @@ jobs:
178179
uses: actions/upload-artifact@v4
179180
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
180181
with:
181-
name: ilc-repro
182+
name: ilc-repro-${{ matrix.multitarget }}-winui${{ matrix.winui }}
182183
path: ./*.zip
183184

184185
# https://github.com/dorny/paths-filter#custom-processing-of-changed-files
@@ -187,14 +188,21 @@ jobs:
187188
if: always()
188189
working-directory: ${{ github.workspace }}
189190
run: |
190-
echo "DUMP_FILE=$(Get-ChildItem .\CrashDumps\*.dmp -ErrorAction SilentlyContinue)" >> $env:GITHUB_OUTPUT
191+
echo "DUMP_FILE=$(Get-ChildItem ${{ env.PROCDUMP_PATH }}/**/*.dmp -ErrorAction SilentlyContinue)" >> $env:GITHUB_OUTPUT
191192
192-
- name: Artifact - WER crash dumps
193+
- name: Artifact - Process Dumps
193194
uses: actions/upload-artifact@v4
194195
if: ${{ (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}
195196
with:
196197
name: CrashDumps-${{ matrix.multitarget }}-winui${{ matrix.winui }}
197-
path: '${{ github.workspace }}/CrashDumps'
198+
path: ${{ env.PROCDUMP_PATH }}/**/*.dmp
199+
200+
- name: Artifact - vstest-diagnostic-log
201+
uses: actions/upload-artifact@v4
202+
if: always()
203+
with:
204+
name: 'vstest-diagnostic-log-${{ matrix.multitarget }}-winui${{ matrix.winui }}.txt'
205+
path: '${{ github.workspace }}/vstest-diagnostic-log.txt'
198206

199207
- name: Analyze Dump
200208
if: ${{ steps.detect-dump.outputs.DUMP_FILE != '' && (env.ENABLE_DIAGNOSTICS == 'true' || env.COREHOST_TRACE != '') && always() }}

components/Segmented/src/Segmented/Segmented.cs

Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ public Segmented()
3030

3131
/// <inheritdoc/>
3232
protected override bool IsItemItsOwnContainerOverride(object item)
33-
{
34-
return item is SegmentedItem;
35-
}
33+
=> item is SegmentedItem;
3634

3735
/// <inheritdoc/>
3836
protected override void OnApplyTemplate()
3937
{
4038
base.OnApplyTemplate();
39+
4140
if (!_hasLoaded)
4241
{
4342
SelectedIndex = -1;
4443
SelectedIndex = _internalSelectedIndex;
4544
_hasLoaded = true;
4645
}
46+
4747
PreviewKeyDown -= Segmented_PreviewKeyDown;
4848
PreviewKeyDown += Segmented_PreviewKeyDown;
4949
}
@@ -52,82 +52,61 @@ protected override void OnApplyTemplate()
5252
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
5353
{
5454
base.PrepareContainerForItemOverride(element, item);
55+
5556
if (element is SegmentedItem segmentedItem)
5657
{
57-
segmentedItem.Loaded += SegmentedItem_Loaded;
58+
segmentedItem.UpdateOrientation(Orientation);
5859
}
5960
}
6061

6162
private void Segmented_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
6263
{
63-
switch (e.Key)
64+
var dir = e.Key switch
6465
{
65-
case VirtualKey.Left: e.Handled = MoveFocus(MoveDirection.Previous); break;
66-
case VirtualKey.Right: e.Handled = MoveFocus(MoveDirection.Next); break;
67-
}
68-
}
66+
#if !HAS_UNO
67+
// Invert left/right when the flow direction is right to left
68+
VirtualKey.Left when FlowDirection is FlowDirection.RightToLeft => 1,
69+
VirtualKey.Right when FlowDirection is FlowDirection.RightToLeft => -1,
70+
#endif
6971

70-
private void SegmentedItem_Loaded(object sender, RoutedEventArgs e)
71-
{
72-
if (sender is SegmentedItem segmentedItem)
73-
{
74-
segmentedItem.Loaded -= SegmentedItem_Loaded;
75-
}
76-
}
72+
// Decrement if left/up or increment if right/up
73+
VirtualKey.Left or VirtualKey.Up => -1,
74+
VirtualKey.Right or VirtualKey.Down => 1,
7775

78-
/// <inheritdoc/>
79-
protected override void OnItemsChanged(object e)
80-
{
81-
base.OnItemsChanged(e);
82-
}
76+
// Otherwise don't adjust
77+
_ => 0,
78+
};
8379

84-
private enum MoveDirection
85-
{
86-
Next,
87-
Previous
80+
if (dir is not 0)
81+
{
82+
e.Handled = MoveFocus(dir);
83+
}
8884
}
8985

9086
/// <summary>
9187
/// Adjust the selected item and range based on keyboard input.
9288
/// This is used to override the ListView behaviors for up/down arrow manipulation vs left/right for a horizontal control
9389
/// </summary>
94-
/// <param name="direction">direction to move the selection</param>
90+
/// <param name="adjustment">The signed number of indicies to shift the focus.</param>
9591
/// <returns>True if the focus was moved, false otherwise</returns>
96-
private bool MoveFocus(MoveDirection direction)
92+
private bool MoveFocus(int adjustment)
9793
{
98-
bool retVal = false;
9994
var currentContainerItem = GetCurrentContainerItem();
95+
if (currentContainerItem is null)
96+
return false;
10097

101-
if (currentContainerItem != null)
102-
{
103-
var currentItem = ItemFromContainer(currentContainerItem);
104-
var previousIndex = Items.IndexOf(currentItem);
105-
var index = previousIndex;
98+
var currentItem = ItemFromContainer(currentContainerItem);
99+
var previousIndex = Items.IndexOf(currentItem);
106100

107-
if (direction == MoveDirection.Previous)
108-
{
109-
if (previousIndex > 0)
110-
{
111-
index -= 1;
112-
}
113-
}
114-
else if (direction == MoveDirection.Next)
115-
{
116-
if (previousIndex < Items.Count - 1)
117-
{
118-
index += 1;
119-
}
120-
}
101+
// Apply the adjustment, with a clamp
102+
var index = Math.Clamp(previousIndex + adjustment, 0, Items.Count);
121103

122-
// Only do stuff if the index is actually changing
123-
if (index != previousIndex && ContainerFromIndex(index) is SegmentedItem newItem)
124-
{
125-
newItem.Focus(FocusState.Keyboard);
126-
retVal = true;
127-
}
128-
}
104+
// Only do stuff if the index is actually changing
105+
if (index == previousIndex || ContainerFromIndex(index) is not SegmentedItem newItem)
106+
return false;
129107

130-
return retVal;
108+
newItem.Focus(FocusState.Keyboard);
109+
return true;
131110
}
132111

133112
private SegmentedItem? GetCurrentContainerItem()

0 commit comments

Comments
 (0)