Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Xamarin - Binding a DateTime gives "InvalidProgramException - Invalid IL Code" #11061

Closed
vsfeedback opened this issue Jun 15, 2020 · 2 comments · Fixed by #11086
Closed

Xamarin - Binding a DateTime gives "InvalidProgramException - Invalid IL Code" #11061

vsfeedback opened this issue Jun 15, 2020 · 2 comments · Fixed by #11086
Assignees
Labels
a/Xaml </> feedback-ticket Issue originates from https://developercommunity.visualstudio.com i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! partner/cat 😻 t/bug 🐛

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


This is my code:

MyChildControl.cs

public class MyChildControl : NControlView
{
    public DateTime MyDateTime { get; set; }
}

MyParentControlModel.cs

public class MyParentControlModel : INotifyPropertyChanged
{
    private DateTime _myDateTime;
    public DateTime MyDateTime
    {
        get => _myDateTime;
        set
        {
            _myDateTime= value;
            OnPropertyChanged();
        }
    }
    ....
}

MyParentControl.xaml

...
<myNamespace:MyChildControl MyDateTime="{Binding MyDateTime}"/>
...

Doing this results in an InvalidProgramException "Invalid IL Code". Removing the binding makes the issue disappear


Original Comments

Visual Studio Feedback System on 6/15/2020, 00:34 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

@pauldipietro pauldipietro added this to New in Triage Jun 15, 2020
@samhouts
Copy link
Member

The problem seems to be that the Xaml parser is getting confused when the property is a DateTime and is attempting to compile something to IL instead of throwing the expected exception that MyDateTime is not a BindableProperty. If you change MyDateTime to be a string instead of a DateTime, you get the proper compile exception.

Repro without NControl:
FT1141376.zip

@samhouts samhouts added a/Xaml </> i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often feedback-ticket Issue originates from https://developercommunity.visualstudio.com s/unverified New report that has yet to be verified t/bug 🐛 partner/cat 😻 labels Jun 15, 2020
@StephaneDelcroix StephaneDelcroix self-assigned this Jun 17, 2020
@StephaneDelcroix StephaneDelcroix removed the s/unverified New report that has yet to be verified label Jun 17, 2020
@StephaneDelcroix StephaneDelcroix moved this from New to Ready For Work in Triage Jun 17, 2020
@StephaneDelcroix
Copy link
Member

the Xaml compiler is confused because DateTime supports Add() 🤦

StephaneDelcroix added a commit that referenced this issue Jun 17, 2020
There was a `TODO: check parameter type` in this code, like if past me
knew that, at some point in time, what was only a potential edge case
bug, would explode in my face and ruin my faith in humanity.

Those FIXMEs... they are bottled 'I TOLD YOU SO' little time capsules

- fixes #11061
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jun 17, 2020
StephaneDelcroix added a commit that referenced this issue Jun 17, 2020
There was a `TODO: check parameter type` in this code, like if past me
knew that, at some point in time, what was only a potential edge case
bug, would explode in my face and ruin my faith in humanity.

Those FIXMEs... they are bottled 'I TOLD YOU SO' little time capsules

- fixes #11061
StephaneDelcroix added a commit that referenced this issue Jun 17, 2020
There was a `TODO: check parameter type` in this code, like if past me
knew that, at some point in time, what was only a potential edge case
bug, would explode in my face and ruin my faith in humanity.

Those FIXMEs... they are bottled 'I TOLD YOU SO' little time capsules

- fixes #11061
StephaneDelcroix added a commit that referenced this issue Jun 17, 2020
There was a `TODO: check parameter type` in this code, like if past me
knew that, at some point in time, what was only a potential edge case
bug, would explode in my face and ruin my faith in humanity.

Those FIXMEs... they are bottled 'I TOLD YOU SO' little time capsules

- fixes #11061
@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Jun 18, 2020
@samhouts samhouts moved this from Needs Estimate to Ready For Work in Triage Jul 23, 2020
@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Jul 23, 2020
Triage automation moved this from Needs Estimate to Closed Jul 30, 2020
@samhouts samhouts added this to In Progress in vCurrent (4.8.0) Jul 30, 2020
@samhouts samhouts moved this from In Progress to Done in vCurrent (4.8.0) Jul 30, 2020
@samhouts samhouts removed this from Closed in Triage Aug 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/Xaml </> feedback-ticket Issue originates from https://developercommunity.visualstudio.com i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often in-progress This issue has an associated pull request that may resolve it! partner/cat 😻 t/bug 🐛
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants