mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-10-10 22:48:40 +00:00
This reverts commit 8d275f0047
.
This commit is contained in:
@@ -356,19 +356,3 @@ module internal AstHelper =
|
||||
}
|
||||
)
|
||||
| _ -> failwithf "Failed to get record elements for type that was: %+A" repr
|
||||
|
||||
let raiseIfNull (variable : Ident) : SynExpr =
|
||||
SynExpr.createMatch
|
||||
(SynExpr.createIdent' variable)
|
||||
[
|
||||
SynMatchClause.create
|
||||
SynPat.createNull
|
||||
(SynExpr.applyFunction
|
||||
(SynExpr.createIdent "raise")
|
||||
(SynExpr.paren (
|
||||
SynExpr.applyFunction
|
||||
(SynExpr.createLongIdent [ "System" ; "ArgumentNullException" ])
|
||||
(SynExpr.CreateConst ())
|
||||
)))
|
||||
SynMatchClause.create (SynPat.named "v") (SynExpr.createIdent "v")
|
||||
]
|
||||
|
@@ -1,5 +1,6 @@
|
||||
namespace WoofWare.Myriad.Plugins
|
||||
|
||||
open System.IO
|
||||
open System.Net.Http
|
||||
open Fantomas.FCS.Syntax
|
||||
open WoofWare.Whippet.Fantomas
|
||||
@@ -13,6 +14,17 @@ type internal HttpClientGeneratorOutputSpec =
|
||||
module internal HttpClientGenerator =
|
||||
open Fantomas.FCS.Text.Range
|
||||
|
||||
let outputFile = FileInfo "/tmp/output.txt"
|
||||
|
||||
// do
|
||||
// use _ = File.Create outputFile.FullName
|
||||
// ()
|
||||
|
||||
let log (line : string) =
|
||||
// use w = outputFile.AppendText ()
|
||||
// w.WriteLine line
|
||||
()
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
type PathSpec =
|
||||
| Verbatim of string
|
||||
@@ -556,9 +568,6 @@ module internal HttpClientGenerator =
|
||||
)
|
||||
)
|
||||
|
||||
let jsonNodeNotNull =
|
||||
Let ("jsonNode", AstHelper.raiseIfNull (Ident.create "jsonNode"))
|
||||
|
||||
let setVariableHeaders =
|
||||
variableHeaders
|
||||
|> List.map (fun (headerName, callToGetValue) ->
|
||||
@@ -633,7 +642,6 @@ module internal HttpClientGenerator =
|
||||
yield responseString
|
||||
yield responseStream
|
||||
yield jsonNode
|
||||
yield jsonNodeNotNull
|
||||
| String -> yield responseString
|
||||
| Stream -> yield responseStream
|
||||
| UnitType ->
|
||||
@@ -642,7 +650,6 @@ module internal HttpClientGenerator =
|
||||
| _ ->
|
||||
yield responseStream
|
||||
yield jsonNode
|
||||
yield jsonNodeNotNull
|
||||
]
|
||||
|> SynExpr.createCompExpr "async" returnExpr
|
||||
|> SynExpr.startAsTask cancellationTokenArg
|
||||
@@ -907,6 +914,10 @@ module internal HttpClientGenerator =
|
||||
"Create a REST client. The input functions will be re-evaluated on every HTTP request to obtain the required values for the corresponding header properties."
|
||||
|> PreXmlDoc.create
|
||||
|
||||
let functionName = Ident.create "client"
|
||||
|
||||
let pattern = SynLongIdent.createS "make"
|
||||
|
||||
let returnInfo = SynType.createLongIdent interfaceType.Name
|
||||
|
||||
let nameWithoutLeadingI =
|
||||
|
@@ -78,7 +78,6 @@ module internal JsonParseGenerator =
|
||||
/// collectionType is e.g. "List"; we'll be calling `ofSeq` on it.
|
||||
/// body is the body of a lambda which takes a parameter `elt`.
|
||||
/// {assertNotNull node}.AsArray()
|
||||
/// |> Seq.cast<JsonNode>
|
||||
/// |> Seq.map (fun elt -> {body})
|
||||
/// |> {collectionType}.ofSeq
|
||||
let asArrayMapped
|
||||
@@ -92,13 +91,6 @@ module internal JsonParseGenerator =
|
||||
| None -> node
|
||||
| Some propertyName -> assertNotNull propertyName node
|
||||
|> SynExpr.callMethod "AsArray"
|
||||
|> SynExpr.pipeThroughFunction (
|
||||
SynExpr.createLongIdent [ "Seq" ; "cast" ]
|
||||
|> SynExpr.typeApp
|
||||
[
|
||||
SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ]
|
||||
]
|
||||
)
|
||||
|> SynExpr.pipeThroughFunction (
|
||||
SynExpr.applyFunction (SynExpr.createLongIdent [ "Seq" ; "map" ]) (SynExpr.createLambda "elt" body)
|
||||
)
|
||||
@@ -281,12 +273,10 @@ module internal JsonParseGenerator =
|
||||
)
|
||||
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
|
||||
| BigInt ->
|
||||
AstHelper.raiseIfNull (Ident.create "v")
|
||||
|> SynExpr.paren
|
||||
node
|
||||
|> SynExpr.callMethod "ToJsonString"
|
||||
|> SynExpr.paren
|
||||
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "Numerics" ; "BigInteger" ; "Parse" ])
|
||||
|> SynExpr.createLet [ SynBinding.basic [ Ident.create "v" ] [] node ]
|
||||
| Measure (_measure, primType) ->
|
||||
parseNumberType options propertyName node primType
|
||||
|> SynExpr.pipeThroughFunction (Measure.getLanguagePrimitivesMeasure primType)
|
||||
|
Reference in New Issue
Block a user