xamarin/Xamarin.Forms

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

オープン

#8,115 opened on 2019/10/21

 (2 件のコメント) (0 件のリアクション) (1 人の担当者)C# (1,926 件のフォーク)batch import
a/Xaml </>help wantedi/highinactivet/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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

コントリビューターガイド