Implement [<ArgumentFlag>] for two-case DUs (#242)

This commit is contained in:
Patrick Stevens
2024-09-04 22:48:36 +01:00
committed by GitHub
parent bdce82fb7a
commit e4cbab3209
15 changed files with 1085 additions and 126 deletions

View File

@@ -263,11 +263,11 @@ module internal JsonSerializeGenerator =
let unionModule (spec : JsonSerializeOutputSpec) (typeName : LongIdent) (cases : SynUnionCase list) =
let inputArg = Ident.create "input"
let fields = cases |> List.map SynUnionCase.extract
let fields = cases |> List.map UnionCase.ofSynUnionCase
fields
|> List.map (fun unionCase ->
let propertyName = getPropertyName unionCase.Ident unionCase.Attrs
let propertyName = getPropertyName unionCase.Name unionCase.Attributes
let caseNames = unionCase.Fields |> List.mapi (fun i _ -> $"arg%i{i}")
@@ -275,7 +275,7 @@ module internal JsonSerializeGenerator =
let pattern =
SynPat.LongIdent (
SynLongIdent.create (typeName @ [ unionCase.Ident ]),
SynLongIdent.create (typeName @ [ unionCase.Name ]),
None,
None,
argPats,