Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,14 @@ void IElementHandler.Invoke(string command, object? args)

void IElementHandler.DisconnectHandler()
{
// Disconnect the content's handler to break circular references and allow GC.
// This is important for memory leak prevention - when a Frame is being removed,
// its content (ListView, etc.) should also be disconnected.
if (Element?.Content is IView content)
{
content.Handler?.DisconnectHandler();
}

_viewHandlerWrapper.DisconnectHandler();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public ShellFlyoutRecyclerAdapter(IShellContext shellContext, Action<Element> se
_selectedCallback = selectedCallback;
}

public override int ItemCount => _listItems.Count;
public override int ItemCount => _listItems?.Count ?? 0;

protected Shell Shell => _shellContext.Shell;
protected Shell Shell => _shellContext?.Shell;

IShellController ShellController => (IShellController)Shell;

Expand All @@ -47,11 +47,16 @@ public ShellFlyoutRecyclerAdapter(IShellContext shellContext, Action<Element> se

public override int GetItemViewType(int position)
{
if (_listItems == null || position >= _listItems.Count)
return -1;
return _listItems[position].Index;
}

DataTemplate GetDataTemplate(int viewTypeId)
{
if (_listItems == null)
return null;

AdapterListItem item = null;

foreach (var ali in _listItems)
Expand Down Expand Up @@ -81,6 +86,9 @@ DataTemplate GetDataTemplate(int viewTypeId)

public override void OnViewRecycled(Java.Lang.Object holder)
{
if (_listItems == null)
return;

if (holder is ElementViewHolder evh)
{
// only clear out the Element if the item has been removed
Expand All @@ -103,6 +111,9 @@ public override void OnViewRecycled(Java.Lang.Object holder)

public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
if (_listItems == null || position >= _listItems.Count)
return;

var item = _listItems[position];
var elementHolder = (ElementViewHolder)holder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ protected virtual void OnElementSet(Shell shell)

protected virtual void SwitchFragment(FragmentManager manager, AView targetView, ShellItem newItem, bool animate = true)
{
if (_disposed || targetView == null)
return;

var previousView = _currentView;
_currentView = CreateShellItemRenderer(newItem);
_currentView.ShellItem = newItem;
Expand Down Expand Up @@ -316,9 +319,39 @@ void IElementHandler.DisconnectHandler()

_disposed = true;

Element.PropertyChanged -= OnElementPropertyChanged;
Element.SizeChanged -= OnElementSizeChanged;
((IShellController)Element).RemoveAppearanceObserver(this);
if (Element != null)
{
Element.PropertyChanged -= OnElementPropertyChanged;
Element.SizeChanged -= OnElementSizeChanged;
((IShellController)Element).RemoveAppearanceObserver(this);
}

// Execute any pending fragment transactions and remove the current fragment
// BEFORE the container is removed to prevent "No view found for id" crashes
try
{
var fragmentManager = Element?.FindMauiContext()?.GetFragmentManager();
if (fragmentManager != null && !fragmentManager.IsDestroyed)
{
fragmentManager.ExecutePendingTransactions();

if (_currentView?.Fragment != null && _currentView.Fragment.IsAdded)
{
var transaction = fragmentManager.BeginTransactionEx();
transaction.RemoveEx(_currentView.Fragment);
transaction.CommitAllowingStateLossEx();
fragmentManager.ExecutePendingTransactions();
}
}
}
catch (Java.Lang.IllegalArgumentException)
{
// Fragment container may already be removed - ignore
}
catch (Java.Lang.IllegalStateException)
{
// Fragment manager may be in an invalid state - ignore
}

if (_flyoutView is ShellFlyoutRenderer sfr)
sfr.Disconnect();
Expand All @@ -328,7 +361,7 @@ void IElementHandler.DisconnectHandler()
if (_currentView is ShellItemRendererBase sir)
sir.Disconnect();
else
_currentView.Dispose();
_currentView?.Dispose();

_currentView = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,17 @@ protected override void Dispose(bool disposing)
if (_backButtonBehavior != null)
_backButtonBehavior.PropertyChanged -= OnBackButtonBehaviorChanged;

((IShellController)ShellContext.Shell)?.RemoveFlyoutBehaviorObserver(this);
// Wrap in try-catch because the JNI peer may already be disposed by the time
// this is called, and RemoveFlyoutBehaviorObserver uses List.Remove which
// calls Equals() - which fails for disposed Java objects.
try
{
((IShellController)ShellContext.Shell)?.RemoveFlyoutBehaviorObserver(this);
}
catch (ObjectDisposedException)
{
// Ignore - we're disposing anyway
}
_shellRootToolBar.PropertyChanged -= OnToolbarPropertyChanged;
_shell.Navigated -= OnShellNavigated;
_shell.PropertyChanged -= HandleShellPropertyChanged;
Expand Down
23 changes: 23 additions & 0 deletions src/Controls/src/Core/FlyoutPage/FlyoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,33 @@ void OnWindowChanged(object sender, EventArgs e)
SizeChanged -= OnSizeChanged;
SizeChanged += OnSizeChanged;
DeviceDisplay.MainDisplayInfoChanged -= OnMainDisplayInfoChanged;

// Propagate Window = null to children so they can clean up their resources.
// This is necessary because Window propagation only happens when Parent changes,
// not when parent's Window changes. Without this, children like NavigationPage
// won't know they've been removed from the window and won't clean up their toolbar.
if (Detail is IWindowController detailWindowController)
{
detailWindowController.Window = null;
}
if (Flyout is IWindowController flyoutWindowController)
{
flyoutWindowController.Window = null;
}
}
else
{
DeviceDisplay.MainDisplayInfoChanged += OnMainDisplayInfoChanged;

// Propagate Window to children
if (Detail is IWindowController detailWindowController)
{
detailWindowController.Window = Window;
}
if (Flyout is IWindowController flyoutWindowController)
{
flyoutWindowController.Window = Window;
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/Controls/src/Core/NavigationPage/NavigationPageToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,13 @@ internal void Disconnect()
navPage.ChildAdded -= NavigationPageChildrenChanged;
navPage.ChildRemoved -= NavigationPageChildrenChanged;
}
// Clear the list to release references to NavigationPages
_navigationPagesStack.Clear();
}

// Clear page references to allow GC
_currentNavigationPage = null;
_currentPage = null;
}
}
}
8 changes: 4 additions & 4 deletions src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
susing System;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[critical] Build & MSBuild — This typo changes using System; to susing System;, which is a C# syntax error and prevents the Controls/XAML projects from compiling.

using System.Diagnostics.CodeAnalysis;

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Material3 Sample App Build Sample App (Material3))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Material3 Sample App Build Sample App (Material3))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests CoreCLR Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests CoreCLR Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 Android CoreCLR Helix Tests Build Device Tests (CoreCLR))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 Android CoreCLR Helix Tests Build Device Tests (CoreCLR))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 ios/catalyst/android Helix Tests (Mono) Build Device Tests (Mono))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 ios/catalyst/android Helix Tests (Mono) Build Device Tests (Mono))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 2 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L2

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(2,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations
using System.Linq;

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Material3 Sample App Build Sample App (Material3))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests CoreCLR Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 Android CoreCLR Helix Tests Build Device Tests (CoreCLR))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 ios/catalyst/android Helix Tests (Mono) Build Device Tests (Mono))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 3 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L3

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(3,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations
using System.Reflection;

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Material3 Sample App Build Sample App (Material3))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests CoreCLR Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 Android CoreCLR Helix Tests Build Device Tests (CoreCLR))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 ios/catalyst/android Helix Tests (Mono) Build Device Tests (Mono))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 4 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L4

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(4,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations
using System.Xml;

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Material3 Sample App Build Sample App (Material3))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests (Build UITests CoreCLR Sample App Build Sample App)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 Android CoreCLR Helix Tests Build Device Tests (CoreCLR))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-devicetests (net10.0 ios/catalyst/android Helix Tests (Mono) Build Device Tests (Mono))

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): error CS1529: (NETCORE_ENGINEERING_TELEMETRY=Build) A using clause must precede all other elements defined in the namespace except extern alias declarations

Check failure on line 5 in src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs

View check run for this annotation

Azure Pipelines / maui-pr-uitests

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs#L5

src/Controls/src/Xaml/MarkupExtensions/StaticExtension.cs(5,1): Error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations

namespace Microsoft.Maui.Controls.Xaml
{
Expand All @@ -29,9 +29,9 @@
if (string.IsNullOrEmpty(Member) || Member.IndexOf(".", StringComparison.Ordinal) == -1)
throw new XamlParseException("Syntax for x:Static is [Member=][prefix:]typeName.staticMemberName", serviceProvider);

#pragma warning disable CA1865 // Use 'string.LastIndexOf(char)' - CA1307 requires StringComparison
var dotIdx = Member.LastIndexOf(".", StringComparison.Ordinal);
#pragma warning restore CA1865
#pragma warning disable CA1307 // Specify StringComparison for clarity - char overload doesn't have StringComparison
var dotIdx = Member.LastIndexOf('.');
#pragma warning restore CA1307
var typename = Member.Substring(0, dotIdx);
var membername = Member.Substring(dotIdx + 1);

Expand Down
28 changes: 28 additions & 0 deletions src/Controls/tests/Core.UnitTests/CollectionViewTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers.Items;
using Xunit;

namespace Microsoft.Maui.Controls.Core.UnitTests
{
public class CollectionViewTests : BaseTestFixture
{
[Fact, Category(TestCategory.Memory)]
public async Task CanCollectEmptyView()
{
var collectionView = new CollectionView { IsPlatformEnabled = true };
collectionView.EmptyView = new View();

var weakReference = new WeakReference(collectionView.EmptyView);

collectionView.EmptyView = null;

await Task.Yield();
GC.Collect(2);
GC.WaitForPendingFinalizers();

Assert.False(weakReference.IsAlive);
}
}
}
2 changes: 1 addition & 1 deletion src/Controls/tests/Core.UnitTests/TestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ public static async Task<bool> WaitForCollect(this WeakReference<object> referen
return reference.TryGetTarget(out _);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ await CreateHandlerAndAddToWindow<WindowHandlerStub>(new Window(navPage), async
}

[Fact(DisplayName = "Does Not Leak"
#if WINDOWS || ANDROID
, Skip = "Failing https://github.com/dotnet/maui/issues/27411"
#if WINDOWS
, Skip = "Failing"
#endif
)]
public async Task DoesNotLeak()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ public _409555_Page2()

public class _409555_Page3 : ContentPage
{
Label successLabel;

public _409555_Page3()
{
Title = Page3Title;
Expand All @@ -176,20 +178,31 @@ public _409555_Page3()
Command = new Command(async () => await DisplayAlertAsync("Alert", Success, "Ok"))
});

var successLabel = new Label();
successLabel = new Label();
Content = new StackLayout
{
Children =
{
lbl
lbl,
successLabel
}
};
}

protected override void OnAppearing()
protected override async void OnAppearing()
{
base.OnAppearing();
GarbageCollectionHelper.Collect();

// Try multiple GC cycles to ensure finalizers run
// Android GC can be less aggressive, so we need to retry
for (int i = 0; i < 10 && string.IsNullOrEmpty(Success); i++)
{
GarbageCollectionHelper.Collect();
await Task.Delay(100);
}

successLabel.Text = Success;
successLabel.AutomationId = Success;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,18 @@ public _42329_Page3()
};
}

protected override void OnAppearing()
protected override async void OnAppearing()
{
base.OnAppearing();
GarbageCollectionHelper.Collect();

// Try multiple GC cycles to ensure finalizers run
// Android GC can be less aggressive, so we need to retry
for (int i = 0; i < 10 && string.IsNullOrEmpty(Success); i++)
{
GarbageCollectionHelper.Collect();
await Task.Delay(100);
}

otherLabel.Text = Success;
otherLabel.AutomationId = Success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ protected override void Init()
goButton.Clicked += (sender, args) => Application.Current.MainPage = new _44166MDP();

var gcButton = new Button { Text = "GC", AutomationId = "GC" };
gcButton.Clicked += (sender, args) =>
gcButton.Clicked += async (sender, args) =>
{
GarbageCollectionHelper.Collect();
// Try multiple GC cycles to ensure finalizers run
// Android GC can be less aggressive, so we need to retry
for (int i = 0; i < 10; i++)
{
GarbageCollectionHelper.Collect();
await Task.Delay(100);
}

if (_44166MDP.Counter > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/tests/TestCases.HostApp/Issues/Issue5555.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.None, 5555, "Memory leak when SwitchCell or EntryCell", PlatformAffected.iOS)]
[Issue(IssueTracker.None, 5555, "Memory leak when SwitchCell or EntryCell", PlatformAffected.All)]
public class Issue5555 : NavigationPage
{
public Issue5555() : base(new TestPage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static void Collect()
GC.Collect();
GC.WaitForPendingFinalizers();

GC.Collect();
GC.Collect(2);
GC.WaitForPendingFinalizers();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public Bugzilla40955(TestDevice testDevice) : base(testDevice)
public override string Issue => "Memory leak with FormsAppCompatActivity and NavigationPage";

[Test]
#if ANDROID
[Ignore("Failing on net10 https://github.com/dotnet/maui/issues/27411")]
#endif
[Category(UITestCategories.Performance)]
public void MemoryLeakInFormsAppCompatActivity()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public Bugzilla42329(TestDevice testDevice) : base(testDevice)
public override string Issue => "ListView in Frame and FormsAppCompatActivity Memory Leak";

[Test]
#if ANDROID
[Ignore("Failing on net10 https://github.com/dotnet/maui/issues/27411")]
#endif
[Category(UITestCategories.ListView)]
public async Task MemoryLeakB42329()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public Bugzilla44166(TestDevice testDevice) : base(testDevice)
public override string Issue => "FlyoutPage instances do not get disposed upon GC";

[Test]
#if ANDROID
[Ignore("Failing on net10 https://github.com/dotnet/maui/issues/27411")]
#endif
[Category(UITestCategories.Performance)]
public void Bugzilla44166Test()
{
Expand Down
Loading
Loading