dotnet-websharper / core

WebSharper - Full-stack, functional, reactive web apps and microservices in F# and C#
https://websharper.com
Apache License 2.0
600 stars 50 forks source link

DeserializeLambda: Type not supported #524

Open fjoppe opened 8 years ago

fjoppe commented 8 years ago

Hi, I am trying to do something with Websocket, and for this I need Websharper.Json, and especially the serialize/deserialize functions.

I have an akka.net actor-system which orchestrates state, and this system has some messages. I wanted to reuse these messages, to be send through the Websocket, and therefore I tried to make them Websharper.Json ready with attribute [<NamedUnionCases>].

So I have two aggregate DU's, the source is here. "PlayerMessage" is send from client to actor system. "PlayerMessageResponse" is send from actor system to client.

So for, so good.

One of the cases in "PlayerMessageResponse" gives problems. When I compile (not the library, but the ws application using the library) gives the following compilation error:

Error GameEngine.Common.PlayerMessageResponse: DeserializeLambda: Type not supported: GameEngine.Common.TileType GameUI.Suave F:....\WebSharper.3.6.7.227\build\WebSharper.targets 60

Detail, the library containing "PlayerMessageResponse" was first an ordinary library, but I added a property to the project as explained here. This fixed the previous problem that no DU was compiling at all. So now its reduced to "TileType".

The source of TileType is found here. Decorated with an attribute or not; it does not compile.

My suspicion is that this DU is different because it actualy is an enumeration and I assign constants to it. Still, I'm stuck here, so I suspect a defect.

Tarmil commented 8 years ago

Yes this seems to be an issue with enumerations, I'm investigating.

fjoppe commented 8 years ago

Hi,

I just upgraded to WS 3.6.10.230. I don't know what to expect, but this issue is still in there.

granicz commented 8 years ago

That's no good news, reopening ticket then for Loic to double-check.

Tarmil commented 8 years ago

This is strange. I just added test cases for enum types and they are passing just fine.

fjoppe commented 8 years ago

I still see the issue. However I have a suspect. I get this error in a Websharper.Suave (3.6.4.30) project, but a Websharper C/S project which includes the same dll, does not provide this error.

The WS.Suave project gets a list of other packages from nuget, including Fsharp.Core 3.1.2.5. In coïncidence with a propriaty project at work this week, I discovered that different Fsharp.Core's can influence how WS works. I found that Fsharp.Data and WS, in sepearte dll-projects, were not working together very well, until I used Fsharp.Core 4.4.0.0 in both projects.

So the Fsharp.Core is my prime suspect. As I'm turning away from the idea of using a Websocket in a Websharper.Suave project, due to complications, maybe its good to reconsider if you want to fix this, for this type of situation.