MaterialButton: XPE when loading styles with triggers
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Tái hiện lỗi bằng cách thêm kiểu MaterialButton được hiển thị vào App.xaml và khởi chạy ứng dụng trên iOS hoặc Android. Sau đó kiểm tra Material.cs quanh GetResource và Color.Secondary, cũng như UI/MaterialButton.cs quanh trình khởi tạo tĩnh của nó; được xem là hoàn tất khi App.InitializeComponent() hoàn thành mà không có XamlParseException được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔙 Regression
In our Application we use MaterialButtons to emulate toggle buttons. The default ButtonType is Text.
For Buttons that are toggleable Buttons the ButtonType is set via a Binding and a custom BoolToButtonTypeConverter.
(false->Text, true->Flat)
To invert the TextColor when the Button is toggled on, we use the following style, defined in App.xaml.
<Style TargetType="ui:MaterialButton" ApplyToDerivedTypes="False">
<Style.Triggers>
<Trigger TargetType="ui:MaterialButton" Property="ButtonType" Value="Flat">
<Trigger.Setters>
<Setter Property="TextColor" Value="White"/>
</Trigger.Setters>
</Trigger>
</Style.Triggers>
</Style>
Old (and correct) behavior
The app is initialized without any errors, Buttons behave as expected. (Xamarin.Forms 4.7.0.1142; XF.Material 1.5.8)
Current behavior
The app fails to start with a XamlParseException, as soon as the App-Constructor calls InitializeComponent(). (Xamarin.Forms 5.0.0.1874; XF.Material 1.7.7)
Callstack:
Xamarin.Forms.Xaml.XamlParseException: Position 62:53. Type converter failed: The type initializer for 'XF.Material.Forms.UI.MaterialButton' threw an exception. ---> System.TypeInitializationException: The type initializer for 'XF.Material.Forms.UI.MaterialButton' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at XF.Material.Forms.Material.GetResource[T] (System.String key) [0x00000] in C:\Users\mhvdi\Documents\OpenSource\XF-Material-Library\XF.Material\Material.cs:57
at XF.Material.Forms.Material+Color.GetSecondaryColor () [0x00000] in C:\Users\mhvdi\Documents\OpenSource\XF-Material-Library\XF.Material\Material.cs:203
at XF.Material.Forms.Material+Color.get_Secondary () [0x00000] in C:\Users\mhvdi\Documents\OpenSource\XF-Material-Library\XF.Material\Material.cs:198
at XF.Material.Forms.UI.MaterialButton..cctor () [0x0003e] in C:\Users\mhvdi\Documents\OpenSource\XF-Material-Library\XF.Material\UI\MaterialButton.cs:20
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Reflection.RuntimeFieldInfo.GetValueInternal(System.Reflection.RuntimeFieldInfo,object)
at System.Reflection.RuntimeFieldInfo.GetValue (System.Object obj) [0x0005e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeFieldInfo.cs:251
at Xamarin.Forms.BindablePropertyConverter.ConvertFrom (System.Type type, System.String propertyName, System.Xml.IXmlLineInfo lineinfo) [0x00055] in D:\a\1\s\Xamarin.Forms.Core\BindablePropertyConverter.cs:99
at Xamarin.Forms.BindablePropertyConverter.Xamarin.Forms.IExtendedTypeConverter.ConvertFromInvariantString (System.String value, System.IServiceProvider serviceProvider) [0x00169] in D:\a\1\s\Xamarin.Forms.Core\BindablePropertyConverter.cs:60
at Xamarin.Forms.Xaml.TypeConversionExtensions.ConvertTo (System.Object value, System.Type toType, System.Func`1[TResult] getConverter, System.IServiceProvider serviceProvider, System.Exception& exception) [0x00041] in D:\a\1\s\Xamarin.Forms.Core\Xaml\TypeConversionExtensions.cs:134
--- End of inner exception stack trace ---
at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.SetPropertyValue (System.Object xamlelement, Xamarin.Forms.Xaml.XmlName propertyName, System.Object value, System.Object rootElement, Xamarin.Forms.Xaml.INode node, Xamarin.Forms.Xaml.HydrationContext context, System.Xml.IXmlLineInfo lineInfo) [0x0007d] in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:366
at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ValueNode node, Xamarin.Forms.Xaml.INode parentNode) [0x0007b] in D:\a\1\s\Xamarin.Forms.Xaml\ApplyPropertiesVisitor.cs:60
at Xamarin.Forms.Xaml.ValueNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:91
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:152
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:152
at Xamarin.Forms.Xaml.FillResourceDictionariesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x000ec] in D:\a\1\s\Xamarin.Forms.Xaml\FillResourceDictionariesVisitor.cs:57
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00012] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:147
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:211
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext, System.Boolean useDesignProperties) [0x0007e] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:235
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Reflection.Assembly rootAssembly, System.Boolean useDesignProperties) [0x000a2] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:104
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Reflection.Assembly rootAssembly) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:78
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.String xaml, System.Reflection.Assembly rootAssembly) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\ViewExtensions.cs:49
at Xamarin.Forms.Xaml.ResourcesLoader.CreateFromResource[T] (System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo) [0x000b1] in D:\a\1\s\Xamarin.Forms.Xaml\ResourcesLoader.cs:39
at Xamarin.Forms.ResourceDictionary.SetAndLoadSource (System.Uri value, System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo) [0x00063] in D:\a\1\s\Xamarin.Forms.Core\ResourceDictionary.cs:76
at Vendor.MobileApp.App.InitializeComponent ()
Reproduction steps
Add the style above into App.xaml and try to launch the App in an Emulator.
Configuration
Version: 1.7.7
Platform:
- 📱 iOS
- 🤖 Android
- 🏁 WPF
- 🌎 UWP
- 🍎 MacOS
- 📺 tvOS
- 🐒 Xamarin.Forms
- Ngôn ngữ chính
- C#
- Star
- 631
- Fork
- 150
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Baseflow/XF-Material-Library
-
.Net Maui SupportĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Baseflow/XF-Material-Library#458 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
Baseflow/XF-Material-Library#457 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Baseflow/XF-Material-Library#456 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Baseflow/XF-Material-Library#454 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 58/100
Baseflow/XF-Material-Library#453 ·
Tất cả issue của Baseflow/XF-Material-Library
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
nightscout/nocturne#2135 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Devolutions/UniGetUI#5541 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[aw] PR Iteration Agent 🔧 failedĐang mởagentic-workflows Needs: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[誤判定]Đang mởlinux アプリ: ブラウザー 再現済み 要トリアージ 誤判定
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
yksr-melt/Meltype#853 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày