roubachof / Sharpnado.Tabs

Pure MAUI and Xamarin.Forms Tabs, including fixed tabs, scrollable tabs, bottom tabs, badge, segmented control, custom tabs, button tabs, bendable tabs...
MIT License
479 stars 62 forks source link

[MAUI] Crashes on .NET 9 #116

Open daltzctr opened 3 weeks ago

daltzctr commented 3 weeks ago

Platform (please complete the following information):

Describe the bug Whenever an instance of Sharpnado tabs is initialized and connected to a view, it crashes the application with XAML issues.

To Reproduce

  1. Create a MAUI .NET 9 project
  2. Add the Sharpnado nuget
  3. Initialize tabs, no item source is necessary 4 Exceptions (if applicable)
    Unhandled managed exception: Exception has been thrown by the target of an invocation. (System.Reflection.TargetInvocationException)
    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
    at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.Activator.CreateInstance(Type type)
    at Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode)
    at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode)
    at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.<>c__DisplayClass43_0.<SetTemplate>b__0()
    at Microsoft.Maui.Controls.ElementTemplate.CreateContent()
    at Sharpnado.Tabs.TabHostView.CreateTabItem(Object item)
    at Sharpnado.Tabs.TabHostView.InitializeItems()
    at Sharpnado.Tabs.TabHostView.UpdateItemsSource()
    at Sharpnado.Tabs.TabHostView.OnPropertyChanged(String propertyName)
    at Microsoft.Maui.Controls.BindableObject.OnBindablePropertySet(BindableProperty property, Object original, Object value, Boolean didChange, Boolean willFirePropertyChanged)

This is likely due to the use of reflection based bindings in Sharpnado. This is no longer allowed in .NET 9 and all bindings must be compiled (or explicitly opted out with x:DataType={x:Null}.

This is due to references to obsolete code