xamarin/Xamarin.Forms

Nullable DateTime with value is null in a constructor

オープン

#5,469 opened on 2019/03/06

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)C# (1,926 件のフォーク)batch import
e/6 :clock6:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs

Repository metrics

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

説明

From @azuken on March 5, 2019 15:7

Steps to Reproduce

  1. Have a nullable DateTime ViewModel property, bound to a Xamarin.Forms view (Custom widget extended from DatePicker)
  2. Have a model with a constructor, which have a nullable DateTime parameter
  3. Get ViewModel property, pass it to constructor
       // CODE FROM VIEW MODEL
        private DateTime? _installationDate;
        public DateTime? InstallationDate
        {
            get => _installationDate;
            set
            {
                _installationDate = value;
                RaisePropertyChanged();
            }
        }

        private async Task EditEquipment() {
            var info = new CustomerEquipmentInfo(EquipmentInfo.Id, InstallationDate);
        }
       // CODE FROM VIEW MODEL

public class CustomerEquipmentInfo {
       public CustomerEquipmentInfo(Guid id, DateTime? installationDate) {
            Id = id;
            InstallationDate = installationDate;
       }

        public Guid Id { get; private set; }
        public DateTime? InstallationDate { get; private set; }
}

Current Behavior

Nullable datetime set with a valid date value become null when passed to a constructor, in Release mode, on Xamarin iOS, on a real device (iPad Air 2 with iOS 12.1 & iPhone 8 with iOS 12.1) (Xamarin iOS Debug works, Xamarin Android Debug and Release works). On iPhone Emulator, it works too.

Expected Behavior

I expect that my DateTime passed to object is not null

On which platforms did you notice this

[ * ] macOS (Development on Xamarins Forms 3.4.0.1029999) [ ] Linux [ ] Windows

Version Used:

Mono 5.16.0.221

Stacktrace

No exception, no stacktrace.

Copied from original issue: mono/mono#13310

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