Skip to content

Commit 1f0f880

Browse files
Ahamed-AliHarishKumarSF4517jfversluisanandhan-rajagopalCopilot
authored
[iOS] Fixed the TargetInvocationException Occurs When Selecting Header/Footer After Changing ItemsLayout in CV2 (#28890)
* [Testing] Fix for flaky UITests in CI that occasionally fail - 7 (#28764) * improve stability to flaky tests * Updated changes * Update CarouselViewUITests.LoopNoFreeze.cs * Update EntryClearButtonColorShouldMatchTextColor.png * Update CommunityToolkit.Maui reference in sample content template (#28510) * Update CommunityToolkit.Maui & Mvvm reference in template * Fix MAUI Toolkit breaking changes * Debump MVVM Toolkit * Update MauiApp.1.csproj * Update package version in MauiApp.1.csproj * Add framework-specific validation flags and update package version * Swap TextValidationBehavior Flags for frameworks * [Testing] Fix for flaky UITests in CI that occasionally fail - 6 (#28747) * Fixed flaky tests related to entry control * Update src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25473.cs Co-authored-by: Copilot <[email protected]> * Update src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue25473.cs Co-authored-by: Copilot <[email protected]> * fixed 19500 test * reverted the common changes * Fix typo in Issue19500.cs comments --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Shane Neuville <[email protected]> * Update dependencies from https://github.com/dotnet/xharness build 20250403.2 (#28819) Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 9.0.0-prerelease.25167.9 -> To Version 9.0.0-prerelease.25203.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update Issue19509.cs (#28807) * Resave mac tabbedpage images (#28803) * Fixed ListView leak caused by not disposed ContextActionsCell (#28702) * Fixed something that looks like copy/paste error * Fixed memory leak caused by not disposed ContextActionsCell * [Testing] Fix for flaky UITests in CI that occasionally fail - 8 (#28828) * improve stability to flaky test * Update Issue7678.cs * Fixed the TargetInvocationException Occurs When Selecting Header/Footer After Changing ItemsLayout in CV2 * Included the test case and sample for the fix * Added the test case for footer --------- Co-authored-by: HarishKumarSF4517 <[email protected]> Co-authored-by: Gerald Versluis <[email protected]> Co-authored-by: Anandhan Rajagopal <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Shane Neuville <[email protected]> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Vitaly Knyazev <[email protected]>
1 parent 4c19a52 commit 1f0f880

31 files changed

+169
-48
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"rollForward": false
2525
},
2626
"microsoft.dotnet.xharness.cli": {
27-
"version": "9.0.0-prerelease.25167.9",
27+
"version": "9.0.0-prerelease.25203.2",
2828
"commands": [
2929
"xharness"
3030
],

eng/Version.Details.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Dependencies>
22
<ProductDependencies>
3-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.25167.9">
3+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.25203.2">
44
<Uri>https://github.com/dotnet/xharness</Uri>
5-
<Sha>8fa551353a0b2c90afb82c507f23afdf966d57c5</Sha>
5+
<Sha>1088108e794db714c8a0a74d94da70199a7bc62c</Sha>
66
</Dependency>
7-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.25167.9">
7+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.25203.2">
88
<Uri>https://github.com/dotnet/xharness</Uri>
9-
<Sha>8fa551353a0b2c90afb82c507f23afdf966d57c5</Sha>
9+
<Sha>1088108e794db714c8a0a74d94da70199a7bc62c</Sha>
1010
</Dependency>
11-
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.25167.9">
11+
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.25203.2">
1212
<Uri>https://github.com/dotnet/xharness</Uri>
13-
<Sha>8fa551353a0b2c90afb82c507f23afdf966d57c5</Sha>
13+
<Sha>1088108e794db714c8a0a74d94da70199a7bc62c</Sha>
1414
</Dependency>
1515
</ProductDependencies>
1616
<ToolsetDependencies>

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
<_HarfBuzzSharpVersion>8.3.0.1</_HarfBuzzSharpVersion>
126126
<_SkiaSharpNativeAssetsVersion>0.0.0-commit.e57e2a11dac4ccc72bea52939dede49816842005.1728</_SkiaSharpNativeAssetsVersion>
127127
<MicrosoftTemplateEngineTasksVersion>7.0.120</MicrosoftTemplateEngineTasksVersion>
128-
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.25167.9</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
129-
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.25167.9</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
130-
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.25167.9</MicrosoftDotNetXHarnessCLIVersion>
128+
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.25203.2</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
129+
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.25203.2</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
130+
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.25203.2</MicrosoftDotNetXHarnessCLIVersion>
131131
<TizenUIExtensionsVersion>0.9.2</TizenUIExtensionsVersion>
132132
<SvgSkiaPackageVersion>2.0.0.4</SvgSkiaPackageVersion>
133133
<FizzlerPackageVersion>1.3.0</FizzlerPackageVersion>

src/Controls/src/Core/Compatibility/Handlers/ListView/iOS/ListViewRenderer.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,7 @@ internal class ListViewDataSource : UITableViewSource
986986
readonly WeakReference<UITableView> _uiTableView;
987987
readonly WeakReference<FormsUITableViewController> _uiTableViewController;
988988
protected readonly WeakReference<ListView> _list;
989+
readonly HashSet<ContextActionsCell> _contextActionsCells = new();
989990
bool _isDragging;
990991
bool _setupSelection;
991992
bool _selectionFromNative;
@@ -1113,6 +1114,10 @@ public override UITableViewCell GetCell(UITableView tableView, NSIndexPath index
11131114
SetCellBackgroundColor(platformCell, bgColor);
11141115
PreserveActivityIndicatorState(cell);
11151116
Performance.Stop(reference);
1117+
1118+
if(platformCell is ContextActionsCell contextActionsCell)
1119+
_contextActionsCells.Add(contextActionsCell);
1120+
11161121
return platformCell;
11171122
}
11181123

@@ -1495,12 +1500,16 @@ protected override void Dispose(bool disposing)
14951500

14961501
if (disposing)
14971502
{
1498-
if (!_list.TryGetTarget(out var list))
1503+
if (_list.TryGetTarget(out var list))
14991504
{
15001505
list.ItemSelected -= OnItemSelected;
15011506
WatchShortNameCollection(false);
15021507
}
15031508

1509+
foreach (var cell in _contextActionsCells)
1510+
cell.Dispose();
1511+
_contextActionsCells.Clear();
1512+
15041513
_templateToId = null;
15051514
}
15061515

src/Controls/src/Core/Handlers/Items2/iOS/GroupableItemsViewController2.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,14 @@ protected override void RegisterViewTypes()
6161
private protected override void RegisterSupplementaryViews(UICollectionElementKindSection kind)
6262
{
6363
base.RegisterSupplementaryViews(kind);
64-
if (IsHorizontal)
65-
{
66-
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalSupplementaryView2),
67-
kind, HorizontalSupplementalView2ReuseId);
68-
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalDefaultSupplementalView2),
69-
kind, HorizontalDefaultSupplementalView2ReuseId);
70-
}
71-
else
72-
{
73-
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalSupplementaryView2),
74-
kind, VerticalSupplementaryView2ReuseId);
75-
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalDefaultSupplementalView2),
76-
kind, VerticalDefaultSupplementalView2ReuseId);
77-
}
64+
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalSupplementaryView2),
65+
kind, HorizontalSupplementalView2ReuseId);
66+
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalDefaultSupplementalView2),
67+
kind, HorizontalDefaultSupplementalView2ReuseId);
68+
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalSupplementaryView2),
69+
kind, VerticalSupplementaryView2ReuseId);
70+
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalDefaultSupplementalView2),
71+
kind, VerticalDefaultSupplementalView2ReuseId);
7872
}
7973

8074
string DetermineViewReuseId(NSString elementKind)

src/Controls/src/Core/Handlers/Items2/iOS/StructuredItemsViewController2.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,14 @@ public override UICollectionReusableView GetViewForSupplementaryElement(UICollec
7575

7676
private protected virtual void RegisterSupplementaryViews(UICollectionElementKindSection kind)
7777
{
78-
if (IsHorizontal)
79-
{
80-
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalSupplementaryView2),
81-
kind, HorizontalSupplementaryView2.ReuseId);
82-
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalDefaultSupplementalView2),
83-
kind, HorizontalDefaultSupplementalView2.ReuseId);
84-
}
85-
else
86-
{
87-
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalSupplementaryView2),
88-
kind, VerticalSupplementaryView2.ReuseId);
89-
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalDefaultSupplementalView2),
90-
kind, VerticalDefaultSupplementalView2.ReuseId);
91-
}
78+
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalSupplementaryView2),
79+
kind, HorizontalSupplementaryView2.ReuseId);
80+
CollectionView.RegisterClassForSupplementaryView(typeof(HorizontalDefaultSupplementalView2),
81+
kind, HorizontalDefaultSupplementalView2.ReuseId);
82+
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalSupplementaryView2),
83+
kind, VerticalSupplementaryView2.ReuseId);
84+
CollectionView.RegisterClassForSupplementaryView(typeof(VerticalDefaultSupplementalView2),
85+
kind, VerticalDefaultSupplementalView2.ReuseId);
9286
}
9387

9488
string DetermineViewReuseId(NSString elementKind)
194 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 28678, "TargetInvocationException Occurs When Selecting Header/Footer After Changing ItemsLayout in CV2", PlatformAffected.iOS)]
4+
public class Issue28678 : ContentPage
5+
{
6+
public Issue28678()
7+
{
8+
// Create the CollectionView
9+
var collectionView = new CollectionView2
10+
{
11+
HeightRequest = 100,
12+
};
13+
14+
var button = new Button
15+
{
16+
Text = "Change ItemsLayout",
17+
AutomationId = "Button"
18+
};
19+
button.Clicked += (s, e) =>
20+
{
21+
collectionView.ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal);
22+
};
23+
24+
var button1 = new Button
25+
{
26+
Text = "Add Header",
27+
AutomationId = "HeaderButton"
28+
};
29+
button1.Clicked += (s, e) =>
30+
{
31+
collectionView.Header = "Header";
32+
};
33+
34+
var button2 = new Button
35+
{
36+
Text = "Add Footer",
37+
AutomationId = "FooterButton"
38+
};
39+
button2.Clicked += (s, e) =>
40+
{
41+
collectionView.Footer = "Footer";
42+
};
43+
44+
Content = new VerticalStackLayout
45+
{
46+
Children =
47+
{
48+
collectionView,
49+
button,
50+
button1,
51+
button2
52+
}
53+
};
54+
}
55+
}
-507 Bytes
Loading
-634 Bytes
Loading

0 commit comments

Comments
 (0)