Skip to content

Commit cd4e60c

Browse files
authored
6/30/2025 Inflight Candidate (#30306)
2 parents d145ee8 + ef395b4 commit cd4e60c

File tree

449 files changed

+6704
-121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+6704
-121
lines changed

src/BlazorWebView/tests/MauiDeviceTests/WebViewHelpers.Windows.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ public static async Task WaitForWebViewReady(WebView2 wv2)
1212
{
1313
CoreWebView2 coreWebView2 = null;
1414

15+
// Ensure that the WebView2 runtime is installed and initialized and has a CoreWebView2 instance.
16+
if (wv2?.CoreWebView2 == null)
17+
{
18+
string version = CoreWebView2Environment.GetAvailableBrowserVersionString(null);
19+
if (string.IsNullOrEmpty(version))
20+
{
21+
throw new InvalidOperationException("WebView2 runtime is not installed.");
22+
}
23+
await wv2.EnsureCoreWebView2Async();
24+
}
25+
1526
await Retry(() =>
1627
{
1728
coreWebView2 = wv2.CoreWebView2;

src/Controls/src/Core/Element/Element.Windows.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public partial class Element
99
{
1010
public static void MapAutomationPropertiesIsInAccessibleTree(IElementHandler handler, Element element)
1111
{
12+
if (handler.IsConnectingHandler() && element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) is null)
13+
return;
14+
1215
Platform.AccessibilityExtensions.SetAutomationPropertiesAccessibilityView(
1316
handler.PlatformView as Microsoft.UI.Xaml.FrameworkElement, element);
1417
}

src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ public override void ViewWillLayoutSubviews()
209209
}
210210

211211
base.ViewWillLayoutSubviews();
212-
212+
213213
if (needsCellLayout || // A cell changed its measure
214-
!_laidOut || // We have never laid out
215-
// With no cells, nothing will trigger a layout when bounds change,
216-
// but we still need to properly lay out supplementary views
217-
ItemsSource.ItemCount == 0)
214+
!_laidOut || // We have never laid out
215+
// With no cells, nothing will trigger a layout when bounds change,
216+
// but we still need to properly lay out supplementary views
217+
ItemsSource.ItemCount == 0)
218218
{
219219
// We don't want to mess up with ContentOffset while refreshing, given that's also gonna cause
220220
// a change in the content's offset Y.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ public static UICollectionViewLayout CreateCarouselLayout(
272272
NSCollectionLayoutDimension itemHeight = NSCollectionLayoutDimension.CreateFractionalHeight(1);
273273
NSCollectionLayoutDimension groupWidth = NSCollectionLayoutDimension.CreateFractionalWidth(1);
274274
NSCollectionLayoutDimension groupHeight = NSCollectionLayoutDimension.CreateFractionalHeight(1);
275-
nfloat itemSpacing = 0;
276275
NSCollectionLayoutGroup group = null;
277276

278277
var layout = new UICollectionViewCompositionalLayout((sectionIndex, environment) =>
@@ -325,7 +324,10 @@ public static UICollectionViewLayout CreateCarouselLayout(
325324
}
326325

327326
var section = NSCollectionLayoutSection.Create(group: group);
328-
section.InterGroupSpacing = itemSpacing;
327+
if (itemsView.ItemsLayout is LinearItemsLayout linearItemsLayout)
328+
{
329+
section.InterGroupSpacing = (nfloat)linearItemsLayout.ItemSpacing;
330+
}
329331
section.OrthogonalScrollingBehavior = isHorizontal
330332
? UICollectionLayoutSectionOrthogonalScrollingBehavior.GroupPagingCentered
331333
: UICollectionLayoutSectionOrthogonalScrollingBehavior.None;

src/Controls/src/Core/Label/Label.Mapper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public partial class Label
2121

2222
// these are really a single property
2323
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(nameof(Text), MapText);
24-
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(nameof(FormattedText), MapText);
24+
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(nameof(FormattedText), MapFormattedText);
2525

2626
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(nameof(LineBreakMode), MapLineBreakMode);
2727
LabelHandler.Mapper.ReplaceMapping<Label, ILabelHandler>(nameof(MaxLines), MapMaxLines);
@@ -54,8 +54,17 @@ public static void MapTextType(ILabelHandler handler, Label label) =>
5454
MapTextOrFormattedText(handler, label);
5555
static void MapTextTransform(ILabelHandler handler, Label label) =>
5656
MapTextOrFormattedText(handler, label);
57+
static void MapFormattedText(ILabelHandler handler, Label label)
58+
{
59+
if (label.IsConnectingHandler()) return;
60+
61+
MapText(handler, label);
62+
}
63+
5764
static void MapTextOrFormattedText(ILabelHandler handler, Label label)
5865
{
66+
if (label.IsConnectingHandler()) return;
67+
5968
if (label.HasFormattedTextSpans)
6069
handler.UpdateValue(nameof(FormattedText));
6170
else

src/Controls/src/Core/NavigationProxy.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ protected virtual void OnRemovePage(Page page)
244244
{
245245
currentInner.RemovePage(page);
246246
}
247+
page?.DisconnectHandlers();
247248
}
248249

249250
Page Pop()

src/Controls/src/Core/Platform/Android/Extensions/ToolbarExtensions.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,22 @@ public static void UpdateMenuItems(this AToolbar toolbar,
232232
if (sortedToolbarItems == null || previousMenuItems == null)
233233
return;
234234

235-
var context = mauiContext.Context;
236235
var menu = toolbar.Menu;
237236

237+
// menu items can be deleted by Android after switching activities, removing outdated menu items first
238+
if (menu != null)
239+
{
240+
for (var j = previousMenuItems.Count - 1; j >= 0; j--)
241+
{
242+
var previousMenuItem = previousMenuItems[j];
243+
if (menu.FindItem(previousMenuItem.ItemId) == null)
244+
{
245+
previousMenuItem.Dispose();
246+
previousMenuItems.RemoveAt(j);
247+
}
248+
}
249+
}
250+
238251
foreach (var toolbarItem in previousToolBarItems)
239252
toolbarItem.PropertyChanged -= toolbarItemChanged;
240253

src/Controls/tests/DeviceTests/ControlsHandlerTestBase.Android.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ protected bool IsBackButtonVisible(IElementHandler handler)
219219
return false;
220220
}
221221

222+
protected void AssertTranslationMatches(Android.Views.View nativeView, double expectedTranslationX, double expectedTranslationY)
223+
{
224+
var context = nativeView?.Context ?? throw new InvalidOperationException("Context cannot be null.");
225+
226+
var expectedXInPixels = context.ToPixels(expectedTranslationX);
227+
Assert.Equal(expectedXInPixels, nativeView.TranslationX, precision: 1);
228+
229+
var expectedYInPixels = context.ToPixels(expectedTranslationY);
230+
Assert.Equal(expectedYInPixels, nativeView.TranslationY, precision: 1);
231+
}
232+
222233
class WindowTestFragment : Fragment
223234
{
224235
TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();

src/Controls/tests/DeviceTests/Elements/BoxView/BoxViewTests.Android.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,26 @@ Task<bool> GetPlatformIsVisible(ShapeViewHandler boxViewViewHandler)
126126
return nativeView.Visibility == Android.Views.ViewStates.Visible;
127127
});
128128
}
129+
130+
//src/Compatibility/Core/tests/Android/TranslationTests.cs
131+
[Fact]
132+
[Description("The Translation property of a BoxView should match with native Translation")]
133+
public async Task BoxViewTranslationConsistent()
134+
{
135+
var boxView = new BoxView()
136+
{
137+
HeightRequest = 100,
138+
WidthRequest = 200,
139+
TranslationX = 50,
140+
TranslationY = -20
141+
};
142+
143+
var handler = await CreateHandlerAsync<ShapeViewHandler>(boxView);
144+
var nativeView = GetNativeBoxView(handler);
145+
await InvokeOnMainThreadAsync(() =>
146+
{
147+
AssertTranslationMatches(nativeView, boxView.TranslationX, boxView.TranslationY);
148+
});
149+
}
129150
}
130151
}

src/Controls/tests/DeviceTests/Elements/Button/ButtonTests.Android.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,25 @@ public async Task RotationConsistent()
190190
var platformRotation = await InvokeOnMainThreadAsync(() => platformButton.Rotation);
191191
Assert.Equal(expected, platformRotation);
192192
}
193+
194+
//src/Compatibility/Core/tests/Android/TranslationTests.cs
195+
[Fact]
196+
[Description("The Translation property of a Button should match with native Translation")]
197+
public async Task ButtonTranslationConsistent()
198+
{
199+
var button = new Button()
200+
{
201+
Text = "Button Test",
202+
TranslationX = 50,
203+
TranslationY = -20
204+
};
205+
206+
var handler = await CreateHandlerAsync<ButtonHandler>(button);
207+
var nativeView = GetPlatformButton(handler);
208+
await InvokeOnMainThreadAsync(() =>
209+
{
210+
AssertTranslationMatches(nativeView, button.TranslationX, button.TranslationY);
211+
});
212+
}
193213
}
194214
}

0 commit comments

Comments
 (0)