Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting MenuFlyoutSubItem IconImageSource throws a NullReferenceException #25893

Open
molesmoke opened this issue Nov 16, 2024 · 3 comments · May be fixed by #26021
Open

Setting MenuFlyoutSubItem IconImageSource throws a NullReferenceException #25893

molesmoke opened this issue Nov 16, 2024 · 3 comments · May be fixed by #26021
Assignees
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@molesmoke
Copy link
Contributor

Description

Setting MenuFlyoutSubItem IconImageSource throws a NullReferenceException

Steps to Reproduce

Add the following to a MenuFlyout:

<MenuFlyoutSubItem IconImageSource="dotnet_bot.png" Text="Test" />

Actual: Throws a NullReferenceException:

Expected: MenuFlyoutSubItem displayed with the given icon

MenuFlyoutItems work OK:

<MenuFlyoutItem IconImageSource="dotnet_bot.png" Text="Test" />

Link to public reproduction project repository

https://github.com/molesmoke/MauiTestApp/tree/net9.0-menuflyoutsubitem-nre

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.100 SR10

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.ApplyStyleSheets(System.Collections.Generic.List<Microsoft.Maui.Controls.StyleSheets.StyleSheet> sheets, Microsoft.Maui.IVisualTreeElement element)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.ApplyStyleSheets(System.Collections.Generic.List<Microsoft.Maui.Controls.StyleSheets.StyleSheet> sheets, Microsoft.Maui.IVisualTreeElement element)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.ApplyStyleSheets()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.OnParentSet()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetParent(Microsoft.Maui.Controls.Element value)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.OnChildAdded(Microsoft.Maui.Controls.Element child)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.AddLogicalChild(Microsoft.Maui.Controls.Element element)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.MenuFlyout.Add(Microsoft.Maui.IMenuElement item)	Unknown
 	[Lightweight Function]	
 	System.Private.CoreLib.dll!System.Reflection.MethodBaseInvoker.InvokeWithOneArg(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit(Microsoft.Maui.Controls.Xaml.ElementNode node, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.ElementNode.Accept(Microsoft.Maui.Controls.Xaml.IXamlNodeVisitor visitor, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.ElementNode.Accept(Microsoft.Maui.Controls.Xaml.IXamlNodeVisitor visitor, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.ElementNode.Accept(Microsoft.Maui.Controls.Xaml.IXamlNodeVisitor visitor, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.ElementNode.Accept(Microsoft.Maui.Controls.Xaml.IXamlNodeVisitor visitor, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.RootNode.Accept(Microsoft.Maui.Controls.Xaml.IXamlNodeVisitor visitor, Microsoft.Maui.Controls.Xaml.INode parentNode)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(Microsoft.Maui.Controls.Xaml.RootNode rootnode, Microsoft.Maui.Controls.Xaml.HydrationContext visitorContext, bool useDesignProperties)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.XamlLoader.Load(object view, string xaml, System.Reflection.Assembly rootAssembly, bool useDesignProperties)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.XamlLoader.Load(object view, string xaml, bool useDesignProperties)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.XamlLoader.Load(object view, System.Type callingType)	Unknown
 	Microsoft.Maui.Controls.Xaml.dll!Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml<MauiTestApp.MainPage>(MauiTestApp.MainPage view, System.Type callingType)	Unknown
>	MauiTestApp.dll!MauiTestApp.MainPage.InitializeComponent() Line 27	C#
 	MauiTestApp.dll!MauiTestApp.MainPage.MainPage() Line 7	C#
 	[Lightweight Function]	
 	System.Private.CoreLib.dll!System.Reflection.ConstructorInvoker.InvokeImpl(object arg1, object arg2, object arg3, object arg4)	Unknown
 	System.Private.CoreLib.dll!System.Reflection.ConstructorInvoker.Invoke(System.Span<object> arguments)	Unknown
 	Microsoft.Extensions.DependencyInjection.Abstractions.dll!Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(System.IServiceProvider provider)	Unknown
 	Microsoft.Extensions.DependencyInjection.Abstractions.dll!Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(System.IServiceProvider provider, System.Type instanceType, object[] parameters)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent.AnonymousMethod__0()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ElementTemplate.CreateContent()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(Microsoft.Maui.Controls.DataTemplate self, object item, Microsoft.Maui.Controls.BindableObject container)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellContentHandler.CreatePlatformElement()	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler<System.__Canon, System.__Canon>.OnCreatePlatformElement()	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement()	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetHandler(Microsoft.Maui.IElementHandler newHandler)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToHandler(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToPlatform(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SyncNavigationStack(bool animated, Microsoft.Maui.Controls.Internals.NavigationRequestedEventArgs e)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellSectionHandler.MapCurrentItem(Microsoft.Maui.Controls.Handlers.ShellSectionHandler handler, Microsoft.Maui.Controls.ShellSection item)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.Controls.ShellSection, Microsoft.Maui.Controls.Handlers.ShellSectionHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperties(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetHandler(Microsoft.Maui.IElementHandler newHandler)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToHandler(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellItemHandler.UpdateCurrentItem()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellItemHandler.MapCurrentItem(Microsoft.Maui.Controls.Handlers.ShellItemHandler handler, Microsoft.Maui.Controls.ShellItem item)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.Controls.ShellItem, Microsoft.Maui.Controls.Handlers.ShellItemHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperties(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellItemHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetHandler(Microsoft.Maui.IElementHandler newHandler)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToHandler(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ShellView.CreateShellItemView()	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Platform.ShellView.SwitchShellItem(Microsoft.Maui.Controls.ShellItem newItem, bool animate)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellHandler.MapCurrentItem(Microsoft.Maui.Controls.Handlers.ShellHandler handler, Microsoft.Maui.Controls.Shell view)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.Controls.Shell, Microsoft.Maui.Controls.Handlers.ShellHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperties(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler<System.__Canon, System.__Canon>.SetVirtualView(Microsoft.Maui.IView view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Handlers.ShellHandler.SetVirtualView(Microsoft.Maui.IView view)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ViewHandler<System.__Canon, System.__Canon>.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetHandler(Microsoft.Maui.IElementHandler newHandler)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToHandler(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.ToPlatform(Microsoft.Maui.IElement view, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.WindowHandler.MapContent(Microsoft.Maui.Handlers.IWindowHandler handler, Microsoft.Maui.IWindow window)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper<Microsoft.Maui.IWindow, Microsoft.Maui.Handlers.IWindowHandler>.Add.AnonymousMethod__0(Microsoft.Maui.IElementHandler h, Microsoft.Maui.IElement v)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdatePropertyCore(string key, Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.PropertyMapper.UpdateProperties(Microsoft.Maui.IElementHandler viewHandler, Microsoft.Maui.IElement virtualView)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(Microsoft.Maui.IElement view)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.SetHandler(Microsoft.Maui.IElementHandler newHandler)	Unknown
 	Microsoft.Maui.Controls.dll!Microsoft.Maui.Controls.Element.Handler.set(Microsoft.Maui.IElementHandler value)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.SetHandler(WinRT.IWinRTObject nativeElement, Microsoft.Maui.IElement element, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ElementExtensions.SetWindowHandler(Microsoft.UI.Xaml.Window platformWindow, Microsoft.Maui.IWindow window, Microsoft.Maui.IMauiContext context)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Microsoft.UI.Xaml.Application platformApplication, Microsoft.Maui.IApplication application, Microsoft.Maui.Handlers.OpenWindowRequest args)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Microsoft.UI.Xaml.Application platformApplication, Microsoft.Maui.IApplication application, Microsoft.UI.Xaml.LaunchActivatedEventArgs args)	Unknown
 	Microsoft.Maui.dll!Microsoft.Maui.MauiWinUIApplication.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)	Unknown
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(nint thisPtr, nint args)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	Microsoft.WinUI.dll!ABI.Microsoft.UI.Xaml.IApplicationStaticsMethods.Start(WinRT.IObjectReference _obj, Microsoft.UI.Xaml.ApplicationInitializationCallback callback)	Unknown
 	Microsoft.WinUI.dll!Microsoft.UI.Xaml.Application.Start(Microsoft.UI.Xaml.ApplicationInitializationCallback callback)	Unknown
 	MauiTestApp.dll!MauiTestApp.WinUI.Program.Main(string[] args) Line 26	C#
@molesmoke molesmoke added the t/bug Something isn't working label Nov 16, 2024
@PureWeen PureWeen added this to the .NET 9 SR1.1 milestone Nov 16, 2024
@PureWeen PureWeen added the potential-regression This issue described a possible regression on a currently supported version., verification pending label Nov 16, 2024
@PureWeen PureWeen added platform/windows 🪟 area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels Nov 16, 2024
@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed i/regression This issue described a confirmed regression on a currently supported version and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Nov 18, 2024
@ninachen03
Copy link

This issue has been verified using Visual Studio 17.13.0 Preview 1(9.0.0-rc.2.24503.2 & 9.0.10). Can repro this issue at android platform. but no throws a NullReferenceException on 8.0.100
Image

@jsuarezruiz jsuarezruiz self-assigned this Nov 18, 2024
@jsuarezruiz
Copy link
Contributor

Notes from a quick review. The MenuFlyoutSubItem have an incorrect null child in the LogicalChildren.
Maybe related with this change 09d3049

@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Nov 20, 2024
@jsuarezruiz
Copy link
Contributor

Notes from a quick review. The MenuFlyoutSubItem have an incorrect null child in the LogicalChildren. Maybe related with this change 09d3049

Not related. The regression comes from #24688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout i/regression This issue described a confirmed regression on a currently supported version platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

4 participants