xamarin/Xamarin.Forms

[Bug] Xaml Code generation produces wrong code with generic base class

Ouverte

#8 115 ouverte le 21 oct. 2019

 (2 commentaires) (0 réaction) (1 personne assignée)C# (1 926 forks)batch import
a/Xaml </>help wantedi/highinactivet/bug :bug:up-for-grabs

Métriques du dépôt

Stars
 (5 644 étoiles)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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

  1. Clone the reproduction repo
  2. Start it (Platform shouldn't matter, but I testet it under UWP)
  3. 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

Reproduction Link

Link

Guide contributeur