You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ILC: Method '[MyMauiApp]MyMauiApp.MainPage.<InitializeComponent>typedBindingsM__0(ViewModel)' will always throw because: Invalid IL or CLR metadata
The IL of the method in question is:
.methodprivate hidebysig staticvaluetype[System.Private.CoreLib]System.ValueTuple`2<string,bool> '<InitializeComponent>typedBindingsM__0' (classMyMauiApp.ViewModel ''
) cil managed
{.custom instance void[System.Private.CoreLib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()=(01000000)// Method begins at RVA 0x11ac8// Header size: 12// Code size: 33 (0x21).maxstack3.locals init ([0]valuetype[System.Private.CoreLib]System.ValueTuple`2<string,bool>)// if (P_0 != null)
IL_0000: ldarg.0
IL_0001: dup
IL_0002: brfalse IL_0013
// return ("Title", true);
IL_0007: ldstr "Title"
IL_000c: ldc.i4.1IL_000d: newobj instance void valuetype [System.Private.CoreLib]System.ValueTuple`2<string,bool>::.ctor(!0,!1)
IL_0012: ret
// (no C# code)
IL_0013: pop
// return default((string, bool));
IL_0014: ldloca.s 0IL_0016: initobj valuetype [System.Private.CoreLib]System.ValueTuple`2<string,bool>
IL_001c: ldloc 0
IL_0020: ret
}// end of method MainPage::'<InitializeComponent>typedBindingsM__0'
It seems to me that the dup and pop instructions are used incorrectly. We never call pop if we reach IL_0012 and we're returning with two items on the stack. We shouldn't need either when the returned value is static.
Should XamlC even allow this type of binding? Should it report an error? On the other hand, this is something that apparently works with classic bindings, so it should be supported.
I found this issue when I tried building the eShop sample app with NativeAOT (see view and the view mode).
Should XamlC even allow this type of binding? Should it report an error? On the other hand, this is something that apparently works with classic bindings, so it should be supported.
So, after further testing, I think this should be reported as invalid XAML. When the same binding isn't compiled, it doesn't resolve the static Title value either and the label is blank.
Consider the following example:
When compiled with ILC, it produces this warning:
The IL of the method in question is:
It seems to me that the
dup
andpop
instructions are used incorrectly. We never callpop
if we reachIL_0012
and we're returning with two items on the stack. We shouldn't need either when the returned value is static.Should XamlC even allow this type of binding? Should it report an error? On the other hand, this is something that apparently works with classic bindings, so it should be supported.
I found this issue when I tried building the eShop sample app with NativeAOT (see view and the view mode).
/cc @StephaneDelcroix @jamesmontemagno
The text was updated successfully, but these errors were encountered: