xamarin/Xamarin.Forms
[Bug] Xaml Code generation produces wrong code with generic base class
Open
#8,115 opened on Oct 21, 2019
a/Xaml </>help wantedi/highinactivet/bug :bug:up-for-grabs
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Description
There seems to be a bug in Xaml code generation when using generic EventArgs.
I've created a generic base class containing logic that I want to share between views. This class contains an EventHandler with generic EventArgs which gets fired when the view's value changes. I've also created two subclasses that inherit from this class.
Now when using these views in Xaml, my code crashes in the InitializeComponent() with the following error:
System.InvalidCastException: "Unable to cast object of type 'System.EventHandler`1[Redacted.PickerValueChangedEventArgs`1[System.Nullable`1[System.DateTime]]]' to type 'System.EventHandler`1[Redacted.PickerValueChangedEventArgs`1[System.Nullable`1[System.TimeSpan]]]'."
Steps to Reproduce
- Clone the reproduction repo
- Start it (Platform shouldn't matter, but I testet it under UWP)
- The app crashes
Expected Behavior
The app doesn't crash and the EventHandlers are successfully registered
Actual Behavior
The app crashes with the above exception
Basic Information
- Version with issue: 4.2.0.709249
- Last known good version: -
- IDE: Visual Studio 2019 Professional
- Platform Target Frameworks:
- UWP: 16299
- Nuget Packages: -
- Affected Devices: Windows 10 PC