#24778·uno

`FrameworkElement` exposes a public, empty `Dispose()` that WinUI does not have

Author: MartinZikmundCreated Sep 28, 2026Updated Sep 28, 2026
Labelskind/bug

Current behavior

Microsoft.UI.Xaml.FrameworkElement exposes public void Dispose() { } (src/Uno.UI/UI/Xaml/FrameworkElement.Interface.cs). It is empty and non-virtual, and FrameworkElement doesn't implement IDisposable. WinUI's FrameworkElement has no Dispose member at all.

The consequences:

  • A control that really needs disposal must hide the base member with public new void Dispose().
  • A caller holding it as FrameworkElement or Panel silently calls the empty base method, and cleanup is skipped.
  • Code shared with WinAppSDK can accidentally compile against a member that doesn't exist there.

For example, Uno.Maui.Embedding.MauiHost in unoplatform/uno.maui.renderer has to use new void Dispose(), and its README warns users not to call Dispose through a FrameworkElement reference.

Expected behavior

Match WinUI: FrameworkElement has no public Dispose.

How to reproduce it (as minimally and precisely as possible)

csharp
public sealed class MyHost : Grid, IDisposable
{
    public new void Dispose() { /* real cleanup */ }
}

FrameworkElement fe = new MyHost();
fe.Dispose(); // compiles on Uno (and calls the empty base method); doesn't compile on WinAppSDK

Workaround ️

Use new void Dispose() in derived types, and document that callers must go through IDisposable or the derived type.

Renderer

  • Skia

Affected platforms ️

All platforms

Uno.Sdk version (and other relevant versions)

Uno.WinUI 7.0.0-dev.763 (lib/net10.0/Uno.UI.dll, confirmed by reflection). Also present on master.

IDE version ‍

N/A

Anything else we need to know?

Suggested fix: mark it [EditorBrowsable(Never)] and [Obsolete] now, and remove it in the next breaking-change window. We found this while reviewing unoplatform/uno.maui.renderer (see unoplatform/uno.maui.renderer#12).

Generated with Claude Code