xamarin/Xamarin.Forms
Nullable DateTime with value is null in a constructor
Aperta
#5469 aperta il 6 mar 2019
e/6 :clock6:help wantedinactivep/iOS 🍎t/bug :bug:up-for-grabs
Metriche repository
- Star
- (5644 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
From @azuken on March 5, 2019 15:7
Steps to Reproduce
- Have a nullable DateTime ViewModel property, bound to a Xamarin.Forms view (Custom widget extended from DatePicker)
- Have a model with a constructor, which have a nullable DateTime parameter
- 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