Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception for setting value for (DateTime cval): TypeInitialization_Type, FSharp.Data.Adaptive.ShallowEqualityComparer`1 #117

Open
albertwoo opened this issue Sep 13, 2024 · 1 comment

Comments

@albertwoo
Copy link

Issue

I am using dotnet 6 blazor WASM, in developing mode it works fine. But when publish in release mode, I got exception at runtime.

I did some investigation, it looks like at

il.EmitCall(OpCodes.Call, eq, null)

It will try to find DateTime's field _dateData (UInt64) for method of ShallowEqualityComparer[UInt64].ShallowEquals, but cannot find it.

By the way, I also tried with dotnet 8, it works fine.

Workaround

I can define below code in my own application to avoid this:

let _ = ShallowEqualityComparer<UInt64>.ShallowEquals

Exception detail:

Unhandled exception rendering component: TypeInitialization_Type, FSharp.Data.Adaptive.ShallowEqualityComparer`1
System.TypeInitializationException: TypeInitialization_Type, FSharp.Data.Adaptive.ShallowEqualityComparer`1
 ---> System.ArgumentNullException: ArgumentNull_Generic Arg_ParamName_Name, methodInfo
   at System.Reflection.Emit.ILGenerator.EmitCall(OpCode , MethodInfo , Type[] )
   at <StartupCode$FSharp-Data-Adaptive>.$ShallowEquality.equals$cont@273[DateTime](Type , Type , Unit )
   at FSharp.Data.Adaptive.ShallowEqualityComparer`1[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..cctor()
   Exception_EndOfInnerExceptionStack
   at FSharp.Data.Adaptive.AValModule.MapVal`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Tuple`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.FSharpFunc`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.Unit, FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Compute(AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.arg10@78[Tuple`2](AbstractVal`1 , AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.AbstractVal`1[[System.Tuple`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.FSharpFunc`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.Unit, FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetValue(AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.AbstractVal`1[[System.Tuple`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.FSharpFunc`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.Unit, FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].FSharp.Data.Adaptive.IAdaptiveValue<'T>.GetValue(AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.BindVal`2[[System.Tuple`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.FSharpFunc`2[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.FSharp.Core.Unit, FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], FSharp.Core, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Fun.Blazor.NodeRenderFragment, Fun.Blazor, Version=4.0.9.0, Culture=neutral, PublicKeyToken=null]].Compute(AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.arg10@78[NodeRenderFragment](AbstractVal`1 , AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.AbstractVal`1[[Fun.Blazor.NodeRenderFragment, Fun.Blazor, Version=4.0.9.0, Culture=neutral, PublicKeyToken=null]].GetValue(AdaptiveToken )
   at FSharp.Data.Adaptive.AValModule.AbstractVal`1[[Fun.Blazor.NodeRenderFragment, Fun.Blazor, Version=4.0.9.0, Culture=neutral, PublicKeyToken=null]].FSharp.Data.Adaptive.IAdaptiveValue<'T>.GetValue(AdaptiveToken )
   at FSharp.Data.Adaptive.EvaluationCallbackExtensions.sub@51-3[[Fun.Blazor.NodeRenderFragment, Fun.Blazor, Version=4.0.9.0, Culture=neutral, PublicKeyToken=null]].Invoke(Unit )
   at FSharp.Data.Adaptive.Transaction.runFinalizers()
   at FSharp.Data.Adaptive.Transaction.System.IDisposable.Dispose()
   at FSharp.Data.Adaptive.TransactionModule.transact[Unit](FSharpFunc`2 )
   at Fun.Blazor.DslAdaptive.setValue@92[[System.DateTime, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Invoke(DateTime )
   at [email protected](MouseEventArgs delegateArg0)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
--- End of stack trace from previous location ---
   at <StartupCode$Fun-Blazor>.$Core.Microsoft-AspNetCore-Components-IHandleEvent-HandleEventAsync@130.MoveNext()
   at MudBlazor.MudBaseButton.OnClickHandler(MouseEventArgs ev)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task , ComponentState )
@luithefirst
Copy link
Collaborator

That's a curious issue, thank you for bringing it up! Unfortunately, I don't have a lot of knowledge about WASM and only a net8 project around where I cannot reproduce it. At least you already found a workaround, great!

Net 6.0 will run out of support soon anyway, I hope you can jump to net8 too. There are some nice improvements that you get by using net8 and the latest FSharp.Core in your own project (even FSharp.Data.Adaptive has been built with net6 and an old FSharp.Core).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants