Hi, thanks for the suggestion, I have created ticket: https://github.com/intellifactory/websharper/issues/696

There is a current workaround to this, using the Constant attribute which allows converting argumentless unioncases to literals and is respected by RPCs and JSON serialization. For example:

1
2
3
type Evnt =
    | [<Constant "START">] START 
    | [<Constant "DONE">] DONE

One caveat is that if you have any instance members, you have to apply the [<Prototype false>] attribute explicitly (there is also a bug here, no compiler errors if it is missing) to make WS tranlate instance calls to static.

1
2
3
4
5
6
7
8
9
[<Prototype false>]
type Evnt =
    | [<Constant "START">] START 
    | [<Constant "DONE">] DONE

    member this.Opposite =
        match this with
        | START -> DONE
        | DONE -> START
By on 5/24/2017 5:29 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us
Built with WebSharper