Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
273 stars 55 forks source link

Support for BCL collections #114

Closed 0x53A closed 5 years ago

0x53A commented 5 years ago

Hi, what do you think about adding support for the most common collections (System.Collections.Generic.Dictionary, List, maybe HashSet)?

I have DTOs I want to share between a C# backend-server, F# web-server in the middle and F# Fable on the client.

F# Map and List are a bit annoying to use in C#, and I don't quite trust the WCF serializer to serialize them correctly (I unfortunately still use WCF between C# and F# servers).


I tried to use a Dictionary<int, Record>, but that failed.

Zaid-Ajaj commented 5 years ago

Hello @0x53A, this sounds like a rare use case but surely I can investigate whether it is possible or not for Fable to handle these types given that BCL support is quite limited in Fable itself.

Could you help me out a bit, I have two questions:

0x53A commented 5 years ago

Hi @Zaid-Ajaj, in this case I worked around it by using a (key*val) array instead.

Imo only Dictionary has much of an advantage, instead of List you can easily use an array. HashSet maybe if you want to reinforce that the objects should be distinct, otherwise you can also just use an array.

Queue and Stack, etc are probably not relevant. 😂


It failed on deserialization on the client. The json sent from the server looked good at a glance. The error was that it couldn't convert JObject to Any, but as I've applied the workaround now, I don't have the exact error message at the moment.

Zaid-Ajaj commented 5 years ago

It seems that List<'t> is already supported so I have added support for dictionary and hashset. A package has been released at 5.1.0-beta using latest Fable and will be available soon when nuget finishes it's magic

Let me know if anything doesn't work properly :smile:

0x53A commented 5 years ago

Thank you!

I can't yet update and test, because the dependency on Fable.Core (3.0.0-beta-005) breaks ... a lot.

But the workaround works for the short term, and when I update I can then prettify my domain models again.