Compare commits

..

3 Commits

Author SHA1 Message Date
Smaug123
3189143473 Merge branch 'main' into add-bit-of-myriad 2024-10-06 22:09:00 +01:00
Smaug123
21dfa77850 Deps 2024-10-06 22:04:51 +01:00
Smaug123
217ef138f6 Add a function from Myriad 2024-10-06 21:56:39 +01:00
39 changed files with 10063 additions and 28954 deletions

View File

@@ -3,13 +3,13 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"fantomas": { "fantomas": {
"version": "7.0.1", "version": "6.3.15",
"commands": [ "commands": [
"fantomas" "fantomas"
] ]
}, },
"fsharp-analyzers": { "fsharp-analyzers": {
"version": "0.30.0", "version": "0.27.0",
"commands": [ "commands": [
"fsharp-analyzers" "fsharp-analyzers"
] ]

View File

@@ -29,7 +29,7 @@ jobs:
with: with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -50,7 +50,7 @@ jobs:
with: with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -67,7 +67,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -82,7 +82,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -97,7 +97,7 @@ jobs:
with: with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -116,7 +116,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -129,7 +129,7 @@ jobs:
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -142,7 +142,7 @@ jobs:
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -156,7 +156,7 @@ jobs:
with: with:
fetch-depth: 0 # so that NerdBank.GitVersioning has access to history fetch-depth: 0 # so that NerdBank.GitVersioning has access to history
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -198,40 +198,27 @@ jobs:
# Verify that there is exactly one nupkg in the artifact that would be NuGet published # Verify that there is exactly one nupkg in the artifact that would be NuGet published
run: if [[ $(find packed-attribute -maxdepth 1 -name 'WoofWare.Myriad.Plugins.Attributes.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi run: if [[ $(find packed-attribute -maxdepth 1 -name 'WoofWare.Myriad.Plugins.Attributes.*.nupkg' -printf c | wc -c) -ne "1" ]]; then exit 1; fi
github-release-dry-run: github-release-plugin-dry-run:
strategy:
matrix:
artifact:
- nuget-package-plugin
- nuget-package-attribute
runs-on: ubuntu-latest
needs: [nuget-pack] needs: [nuget-pack]
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Download NuGet artifact - name: Download NuGet artifact (plugin)
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: ${{ matrix.artifact }} name: nuget-package-plugin
- name: Compute package path - name: Download NuGet artifact (attribute)
id: compute-path uses: actions/download-artifact@v4
run: |
find . -maxdepth 1 -type f -name 'WoofWare.Myriad.*.nupkg' -exec sh -c 'echo "output=$(basename "$1")" >> $GITHUB_OUTPUT' shell {} \;
- name: Compute tag name
id: compute-tag
env:
NUPKG_PATH: ${{ steps.compute-path.outputs.output }}
run: echo "output=$(basename "$NUPKG_PATH" .nupkg)" >> $GITHUB_OUTPUT
- name: Tag and release
uses: G-Research/common-actions/github-release@19d7281a0f9f83e13c78f99a610dbc80fc59ba3b
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} name: nuget-package-attribute
target-commitish: ${{ github.sha }} - name: Tag and release plugin
tag: ${{ steps.compute-tag.outputs.output }} env:
binary-contents: ${{ steps.compute-path.outputs.output }} DRY_RUN: 1
dry-run: true GITHUB_TOKEN: mock-token
run: sh .github/workflows/tag.sh
all-required-checks-complete: all-required-checks-complete:
needs: [check-dotnet-format, check-nix-format, check-accurate-generations, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack, github-release-dry-run] needs: [check-dotnet-format, check-nix-format, check-accurate-generations, build, build-nix, linkcheck, flake-check, analyzers, nuget-pack, expected-pack, github-release-plugin-dry-run]
if: ${{ always() }} if: ${{ always() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -254,7 +241,7 @@ jobs:
name: nuget-package-attribute name: nuget-package-attribute
path: packed path: packed
- name: Attest Build Provenance - name: Attest Build Provenance
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3 uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with: with:
subject-path: "packed/*.nupkg" subject-path: "packed/*.nupkg"
@@ -273,7 +260,7 @@ jobs:
name: nuget-package-plugin name: nuget-package-plugin
path: packed path: packed
- name: Attest Build Provenance - name: Attest Build Provenance
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3 uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with: with:
subject-path: "packed/*.nupkg" subject-path: "packed/*.nupkg"
@@ -289,7 +276,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -322,7 +309,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: cachix/install-nix-action@v31 uses: cachix/install-nix-action@v29
with: with:
extra_nix_config: | extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
@@ -343,12 +330,7 @@ jobs:
nupkg-dir: packed/ nupkg-dir: packed/
dotnet: ${{ steps.dotnet-identify.outputs.dotnet }} dotnet: ${{ steps.dotnet-identify.outputs.dotnet }}
github-release: github-release-plugin:
strategy:
matrix:
artifact:
- nuget-package-attribute
- nuget-package-plugin
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }} if: ${{ !github.event.repository.fork && github.ref == 'refs/heads/main' }}
needs: [all-required-checks-complete] needs: [all-required-checks-complete]
@@ -357,23 +339,15 @@ jobs:
contents: write contents: write
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Download NuGet artifact - name: Download NuGet artifact (plugin)
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: ${{ matrix.artifact }} name: nuget-package-plugin
- name: Compute package path - name: Download NuGet artifact (attribute)
id: compute-path uses: actions/download-artifact@v4
run: |
find . -maxdepth 1 -type f -name 'WoofWare.Myriad.*.nupkg' -exec sh -c 'echo "output=$(basename "$1")" >> $GITHUB_OUTPUT' shell {} \;
- name: Compute tag name
id: compute-tag
env:
NUPKG_PATH: ${{ steps.compute-path.outputs.output }}
run: echo "output=$(basename "$NUPKG_PATH" .nupkg)" >> $GITHUB_OUTPUT
- name: Tag and release
uses: G-Research/common-actions/github-release@19d7281a0f9f83e13c78f99a610dbc80fc59ba3b
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} name: nuget-package-attribute
target-commitish: ${{ github.sha }} - name: Tag and release plugin
tag: ${{ steps.compute-tag.outputs.output }} env:
binary-contents: ${{ steps.compute-path.outputs.output }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sh .github/workflows/tag.sh

View File

@@ -21,20 +21,20 @@ jobs:
- name: Update Nix flake - name: Update Nix flake
run: 'nix flake update' run: 'nix flake update'
- name: Build fetch-deps - name: Build passthru
run: 'nix build ".#default.fetch-deps"' run: 'nix build ".#default.passthru.fetch-deps"'
- name: Run fetch-deps - name: Run passthru
run: | run: |
set -o pipefail set -o pipefail
./result nix/deps.json ./result nix/deps.nix
- name: Format - name: Format
run: 'nix develop --command alejandra .' run: 'nix develop --command alejandra .'
- name: Create token - name: Create token
id: generate-token id: generate-token
uses: actions/create-github-app-token@v2 uses: actions/create-github-app-token@v1
with: with:
# https://github.com/actions/create-github-app-token/issues/136 # https://github.com/actions/create-github-app-token/issues/136
app-id: ${{ secrets.APP_ID }} app-id: ${{ secrets.APP_ID }}

120
.github/workflows/tag.sh vendored Normal file
View File

@@ -0,0 +1,120 @@
#!/bin/bash
echo "Dry-run? $DRY_RUN!"
find . -maxdepth 1 -type f ! -name "$(printf "*\n*")" -name '*.nupkg' | while IFS= read -r file
do
tag=$(basename "$file" .nupkg)
git tag "$tag"
${DRY_RUN:+echo} git push origin "$tag"
done
export TAG
TAG=$(find . -maxdepth 1 -type f -name 'WoofWare.Myriad.Plugins.*.nupkg' -exec sh -c 'basename "$1" .nupkg' shell {} \; | grep -v Attributes)
case "$TAG" in
*"
"*)
echo "Error: TAG contains a newline; multiple plugins found."
exit 1
;;
esac
# target_commitish empty indicates the repo default branch
curl_body='{"tag_name":"'"$TAG"'","target_commitish":"","name":"'"$TAG"'","draft":false,"prerelease":false,"generate_release_notes":false}'
echo "cURL body: $curl_body"
failed_output=$(cat <<'EOF'
{
"message": "Validation Failed",
"errors": [
{
"resource": "Release",
"code": "already_exists",
"field": "tag_name"
}
],
"documentation_url": "https://docs.github.com/rest/releases/releases#create-a-release"
}
EOF
)
success_output=$(cat <<'EOF'
{
"url": "https://api.github.com/repos/Smaug123/WoofWare.Myriad/releases/158152116",
"assets_url": "https://api.github.com/repos/Smaug123/WoofWare.Myriad/releases/158152116/assets",
"upload_url": "https://uploads.github.com/repos/Smaug123/WoofWare.Myriad/releases/158152116/assets{?name,label}",
"html_url": "https://github.com/Smaug123/WoofWare.Myriad/releases/tag/WoofWare.Myriad.Plugins.2.1.30",
"id": 158152116,
"author": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"node_id": "RE_kwDOJfksgc4JbTW0",
"tag_name": "WoofWare.Myriad.Plugins.2.1.30",
"target_commitish": "main",
"name": "WoofWare.Myriad.Plugins.2.1.30",
"draft": false,
"prerelease": false,
"created_at": "2024-05-30T11:00:55Z",
"published_at": "2024-05-30T11:03:02Z",
"assets": [
],
"tarball_url": "https://api.github.com/repos/Smaug123/WoofWare.Myriad/tarball/WoofWare.Myriad.Plugins.2.1.30",
"zipball_url": "https://api.github.com/repos/Smaug123/WoofWare.Myriad/zipball/WoofWare.Myriad.Plugins.2.1.30",
"body": null
}
EOF
)
HANDLE_OUTPUT=''
handle_error() {
ERROR_OUTPUT="$1"
exit_message=$(echo "$ERROR_OUTPUT" | jq -r --exit-status 'if .errors | length == 1 then .errors[0].code else null end')
if [ "$exit_message" = "already_exists" ] ; then
HANDLE_OUTPUT="Did not create GitHub release because it already exists at this version."
else
echo "Unexpected error output from curl: $(cat curl_output.json)"
echo "JQ output: $(exit_message)"
exit 2
fi
}
run_tests() {
handle_error "$failed_output"
if [ "$HANDLE_OUTPUT" != "Did not create GitHub release because it already exists at this version." ]; then
echo "Bad output from handler: $HANDLE_OUTPUT"
exit 3
fi
HANDLE_OUTPUT=''
echo "Tests passed."
}
run_tests
if [ "$DRY_RUN" != 1 ] ; then
if curl --fail-with-body -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/Smaug123/WoofWare.Myriad/releases -d "$curl_body" > curl_output.json; then
echo "Curl succeeded."
else
handle_error "$(cat curl_output.json)"
echo "$HANDLE_OUTPUT"
fi
fi

View File

@@ -1,27 +1,5 @@
Notable changes are recorded here. Notable changes are recorded here.
# WoofWare.Myriad.Plugins 7.0.1
All generators should now be compatible with `<Nullable>enable</Nullable>`.
**Please test the results and let me know of unexpected failures.**
There are a number of heuristics in this code, because:
* `System.Text.Json.Nodes` is an unfathomably weird API which simply requires us to make educated guesses about whether a user-provided type is supposed to be nullable, despite this being irrelevant to the operation of `System.Text.Json`;
* Some types (like `Uri` and `String`) have `ToString` methods which can't return `null`, but in general `Object.ToString` can of course return `null`, and as far as I can tell there is simply no way to know from the source alone whether a given type will have a nullable `ToString`.
# WoofWare.Myriad.Plugins 6.0.1
The `ArgParser` generator's type signatures have changed.
The `parse'` method no longer takes `getEnvironmentVariable : string -> string`; it's now `getEnvironmentVariable : string -> string option`.
This is to permit satisfying the `<Nullable>enable</Nullable>` compiler setting.
If you're calling `parse'`, give it `Environment.GetEnvironmentVariable >> Option.ofObj` instead.
# WoofWare.Myriad.Plugins 5.0.1
We now enforce non-nullability on more types during JSON parse.
We have always expected you to consume nullable types wrapped in an `option`, but now we enforce this in more cases by throwing `ArgumentNullException`.
# WoofWare.Myriad.Plugins 3.0.1 # WoofWare.Myriad.Plugins 3.0.1
Semantics of `HttpClient`'s URI component composition changed: Semantics of `HttpClient`'s URI component composition changed:

View File

@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<OtherFlags>--reflectionfree $(OtherFlags)</OtherFlags> <OtherFlags>--reflectionfree $(OtherFlags)</OtherFlags>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<MyriadSdkGenerator Include="$(MSBuildThisFileDirectory)..\WoofWare.Myriad.Plugins\bin\$(Configuration)\net6.0\WoofWare.Myriad.Plugins.dll"/> <MyriadSdkGenerator Include="$(MSBuildThisFileDirectory)..\WoofWare.Myriad.Plugins\bin\$(Configuration)\net6.0\WoofWare.Myriad.Plugins.dll"/>

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,7 @@ module BasicNoPositionals =
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string option) (args : string list) : BasicNoPositionals = let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicNoPositionals =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -223,7 +223,7 @@ module BasicNoPositionals =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
let parse (args : string list) : BasicNoPositionals = let parse (args : string list) : BasicNoPositionals =
parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -239,7 +239,7 @@ module Basic =
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string option) (args : string list) : Basic = let parse' (getEnvironmentVariable : string -> string) (args : string list) : Basic =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -430,7 +430,7 @@ module Basic =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
let parse (args : string list) : Basic = let parse (args : string list) : Basic =
parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -446,7 +446,7 @@ module BasicWithIntPositionals =
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string option) (args : string list) : BasicWithIntPositionals = let parse' (getEnvironmentVariable : string -> string) (args : string list) : BasicWithIntPositionals =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -633,7 +633,7 @@ module BasicWithIntPositionals =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
let parse (args : string list) : BasicWithIntPositionals = let parse (args : string list) : BasicWithIntPositionals =
parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -649,7 +649,7 @@ module LoadsOfTypes =
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string option) (args : string list) : LoadsOfTypes = let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypes =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -1038,7 +1038,7 @@ module LoadsOfTypes =
match arg_10 with match arg_10 with
| None -> | None ->
match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with
| None -> | null ->
sprintf sprintf
"No value was supplied for %s, nor was environment variable %s set" "No value was supplied for %s, nor was environment variable %s set"
(sprintf "--%s" "yet-another-optional-thing") (sprintf "--%s" "yet-another-optional-thing")
@@ -1046,7 +1046,7 @@ module LoadsOfTypes =
|> ArgParser_errors.Add |> ArgParser_errors.Add
Unchecked.defaultof<_> Unchecked.defaultof<_>
| Some x -> x |> (fun x -> x) | x -> x |> (fun x -> x)
|> Choice2Of2 |> Choice2Of2
| Some x -> Choice1Of2 x | Some x -> Choice1Of2 x
@@ -1068,7 +1068,7 @@ module LoadsOfTypes =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
let parse (args : string list) : LoadsOfTypes = let parse (args : string list) : LoadsOfTypes =
parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -1084,7 +1084,7 @@ module LoadsOfTypesNoPositionals =
/// Waiting to receive a value for the key we've already consumed /// Waiting to receive a value for the key we've already consumed
| AwaitingValue of key : string | AwaitingValue of key : string
let parse' (getEnvironmentVariable : string -> string option) (args : string list) : LoadsOfTypesNoPositionals = let parse' (getEnvironmentVariable : string -> string) (args : string list) : LoadsOfTypesNoPositionals =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -1476,7 +1476,7 @@ module LoadsOfTypesNoPositionals =
match arg_9 with match arg_9 with
| None -> | None ->
match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with
| None -> | null ->
sprintf sprintf
"No value was supplied for %s, nor was environment variable %s set" "No value was supplied for %s, nor was environment variable %s set"
(sprintf "--%s" "yet-another-optional-thing") (sprintf "--%s" "yet-another-optional-thing")
@@ -1484,7 +1484,7 @@ module LoadsOfTypesNoPositionals =
|> ArgParser_errors.Add |> ArgParser_errors.Add
Unchecked.defaultof<_> Unchecked.defaultof<_>
| Some x -> x |> (fun x -> x) | x -> x |> (fun x -> x)
|> Choice2Of2 |> Choice2Of2
| Some x -> Choice1Of2 x | Some x -> Choice1Of2 x
@@ -1505,7 +1505,7 @@ module LoadsOfTypesNoPositionals =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
let parse (args : string list) : LoadsOfTypesNoPositionals = let parse (args : string list) : LoadsOfTypesNoPositionals =
parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -1524,7 +1524,7 @@ module DatesAndTimesArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type DatesAndTimes with type DatesAndTimes with
static member parse' (getEnvironmentVariable : string -> string option) (args : string list) : DatesAndTimes = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : DatesAndTimes =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -1787,7 +1787,7 @@ module DatesAndTimesArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : DatesAndTimes = static member parse (args : string list) : DatesAndTimes =
DatesAndTimes.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args DatesAndTimes.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -1806,7 +1806,7 @@ module ParentRecordArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ParentRecord with type ParentRecord with
static member parse' (getEnvironmentVariable : string -> string option) (args : string list) : ParentRecord = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecord =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2016,7 +2016,7 @@ module ParentRecordArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ParentRecord = static member parse (args : string list) : ParentRecord =
ParentRecord.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ParentRecord.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2035,11 +2035,7 @@ module ParentRecordChildPosArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ParentRecordChildPos with type ParentRecordChildPos with
static member parse' static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordChildPos =
(getEnvironmentVariable : string -> string option)
(args : string list)
: ParentRecordChildPos
=
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2213,7 +2209,7 @@ module ParentRecordChildPosArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ParentRecordChildPos = static member parse (args : string list) : ParentRecordChildPos =
ParentRecordChildPos.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ParentRecordChildPos.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2232,11 +2228,7 @@ module ParentRecordSelfPosArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ParentRecordSelfPos with type ParentRecordSelfPos with
static member parse' static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ParentRecordSelfPos =
(getEnvironmentVariable : string -> string option)
(args : string list)
: ParentRecordSelfPos
=
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2396,7 +2388,7 @@ module ParentRecordSelfPosArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ParentRecordSelfPos = static member parse (args : string list) : ParentRecordSelfPos =
ParentRecordSelfPos.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ParentRecordSelfPos.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2415,11 +2407,7 @@ module ChoicePositionalsArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ChoicePositionals with type ChoicePositionals with
static member parse' static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ChoicePositionals =
(getEnvironmentVariable : string -> string option)
(args : string list)
: ChoicePositionals
=
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2514,7 +2502,7 @@ module ChoicePositionalsArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ChoicePositionals = static member parse (args : string list) : ChoicePositionals =
ChoicePositionals.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ChoicePositionals.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2533,11 +2521,7 @@ module ContainsBoolEnvVarArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ContainsBoolEnvVar with type ContainsBoolEnvVar with
static member parse' static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsBoolEnvVar =
(getEnvironmentVariable : string -> string option)
(args : string list)
: ContainsBoolEnvVar
=
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2669,7 +2653,7 @@ module ContainsBoolEnvVarArgParse =
match arg_0 with match arg_0 with
| None -> | None ->
match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with
| None -> | null ->
sprintf sprintf
"No value was supplied for %s, nor was environment variable %s set" "No value was supplied for %s, nor was environment variable %s set"
(sprintf "--%s" "bool-var") (sprintf "--%s" "bool-var")
@@ -2677,7 +2661,7 @@ module ContainsBoolEnvVarArgParse =
|> ArgParser_errors.Add |> ArgParser_errors.Add
Unchecked.defaultof<_> Unchecked.defaultof<_>
| Some x -> | x ->
if System.String.Equals (x, "1", System.StringComparison.OrdinalIgnoreCase) then if System.String.Equals (x, "1", System.StringComparison.OrdinalIgnoreCase) then
true true
else if System.String.Equals (x, "0", System.StringComparison.OrdinalIgnoreCase) then else if System.String.Equals (x, "0", System.StringComparison.OrdinalIgnoreCase) then
@@ -2695,7 +2679,7 @@ module ContainsBoolEnvVarArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ContainsBoolEnvVar = static member parse (args : string list) : ContainsBoolEnvVar =
ContainsBoolEnvVar.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ContainsBoolEnvVar.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2714,7 +2698,7 @@ module WithFlagDuArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type WithFlagDu with type WithFlagDu with
static member parse' (getEnvironmentVariable : string -> string option) (args : string list) : WithFlagDu = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : WithFlagDu =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -2868,7 +2852,7 @@ module WithFlagDuArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : WithFlagDu = static member parse (args : string list) : WithFlagDu =
WithFlagDu.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args WithFlagDu.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -2887,11 +2871,7 @@ module ContainsFlagEnvVarArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ContainsFlagEnvVar with type ContainsFlagEnvVar with
static member parse' static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ContainsFlagEnvVar =
(getEnvironmentVariable : string -> string option)
(args : string list)
: ContainsFlagEnvVar
=
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -3038,7 +3018,7 @@ module ContainsFlagEnvVarArgParse =
match arg_0 with match arg_0 with
| None -> | None ->
match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with match "CONSUMEPLUGIN_THINGS" |> getEnvironmentVariable with
| None -> | null ->
sprintf sprintf
"No value was supplied for %s, nor was environment variable %s set" "No value was supplied for %s, nor was environment variable %s set"
(sprintf "--%s" "dry-run") (sprintf "--%s" "dry-run")
@@ -3046,7 +3026,7 @@ module ContainsFlagEnvVarArgParse =
|> ArgParser_errors.Add |> ArgParser_errors.Add
Unchecked.defaultof<_> Unchecked.defaultof<_>
| Some x -> | x ->
if System.String.Equals (x, "1", System.StringComparison.OrdinalIgnoreCase) then if System.String.Equals (x, "1", System.StringComparison.OrdinalIgnoreCase) then
if true = Consts.FALSE then if true = Consts.FALSE then
DryRunMode.Wet DryRunMode.Wet
@@ -3076,7 +3056,7 @@ module ContainsFlagEnvVarArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ContainsFlagEnvVar = static member parse (args : string list) : ContainsFlagEnvVar =
ContainsFlagEnvVar.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ContainsFlagEnvVar.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -3096,7 +3076,7 @@ module ContainsFlagDefaultValueArgParse =
type ContainsFlagDefaultValue with type ContainsFlagDefaultValue with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: ContainsFlagDefaultValue : ContainsFlagDefaultValue
= =
@@ -3259,7 +3239,7 @@ module ContainsFlagDefaultValueArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ContainsFlagDefaultValue = static member parse (args : string list) : ContainsFlagDefaultValue =
ContainsFlagDefaultValue.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ContainsFlagDefaultValue.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -3278,7 +3258,7 @@ module ManyLongFormsArgParse =
/// Extension methods for argument parsing /// Extension methods for argument parsing
type ManyLongForms with type ManyLongForms with
static member parse' (getEnvironmentVariable : string -> string option) (args : string list) : ManyLongForms = static member parse' (getEnvironmentVariable : string -> string) (args : string list) : ManyLongForms =
let ArgParser_errors = ResizeArray () let ArgParser_errors = ResizeArray ()
let helpText () = let helpText () =
@@ -3524,7 +3504,7 @@ module ManyLongFormsArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : ManyLongForms = static member parse (args : string list) : ManyLongForms =
ManyLongForms.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args ManyLongForms.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -3544,7 +3524,7 @@ module FlagsIntoPositionalArgsArgParse =
type FlagsIntoPositionalArgs with type FlagsIntoPositionalArgs with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: FlagsIntoPositionalArgs : FlagsIntoPositionalArgs
= =
@@ -3688,7 +3668,7 @@ module FlagsIntoPositionalArgsArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : FlagsIntoPositionalArgs = static member parse (args : string list) : FlagsIntoPositionalArgs =
FlagsIntoPositionalArgs.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args FlagsIntoPositionalArgs.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -3708,7 +3688,7 @@ module FlagsIntoPositionalArgsChoiceArgParse =
type FlagsIntoPositionalArgsChoice with type FlagsIntoPositionalArgsChoice with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: FlagsIntoPositionalArgsChoice : FlagsIntoPositionalArgsChoice
= =
@@ -3852,7 +3832,7 @@ module FlagsIntoPositionalArgsChoiceArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : FlagsIntoPositionalArgsChoice = static member parse (args : string list) : FlagsIntoPositionalArgsChoice =
FlagsIntoPositionalArgsChoice.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args FlagsIntoPositionalArgsChoice.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -3872,7 +3852,7 @@ module FlagsIntoPositionalArgsIntArgParse =
type FlagsIntoPositionalArgsInt with type FlagsIntoPositionalArgsInt with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: FlagsIntoPositionalArgsInt : FlagsIntoPositionalArgsInt
= =
@@ -4016,7 +3996,7 @@ module FlagsIntoPositionalArgsIntArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : FlagsIntoPositionalArgsInt = static member parse (args : string list) : FlagsIntoPositionalArgsInt =
FlagsIntoPositionalArgsInt.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args FlagsIntoPositionalArgsInt.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -4036,7 +4016,7 @@ module FlagsIntoPositionalArgsIntChoiceArgParse =
type FlagsIntoPositionalArgsIntChoice with type FlagsIntoPositionalArgsIntChoice with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: FlagsIntoPositionalArgsIntChoice : FlagsIntoPositionalArgsIntChoice
= =
@@ -4180,7 +4160,7 @@ module FlagsIntoPositionalArgsIntChoiceArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : FlagsIntoPositionalArgsIntChoice = static member parse (args : string list) : FlagsIntoPositionalArgsIntChoice =
FlagsIntoPositionalArgsIntChoice.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args FlagsIntoPositionalArgsIntChoice.parse' System.Environment.GetEnvironmentVariable args
namespace ConsumePlugin namespace ConsumePlugin
open System open System
@@ -4200,7 +4180,7 @@ module FlagsIntoPositionalArgs'ArgParse =
type FlagsIntoPositionalArgs' with type FlagsIntoPositionalArgs' with
static member parse' static member parse'
(getEnvironmentVariable : string -> string option) (getEnvironmentVariable : string -> string)
(args : string list) (args : string list)
: FlagsIntoPositionalArgs' : FlagsIntoPositionalArgs'
= =
@@ -4344,4 +4324,4 @@ module FlagsIntoPositionalArgs'ArgParse =
ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s" ArgParser_errors |> String.concat "\n" |> failwithf "Errors during parse!\n%s"
static member parse (args : string list) : FlagsIntoPositionalArgs' = static member parse (args : string list) : FlagsIntoPositionalArgs' =
FlagsIntoPositionalArgs'.parse' (System.Environment.GetEnvironmentVariable >> Option.ofObj) args FlagsIntoPositionalArgs'.parse' System.Environment.GetEnvironmentVariable args

View File

@@ -14,24 +14,7 @@ module internal InternalTypeNotExtensionSerial =
/// Serialize to a JSON node /// Serialize to a JSON node
let toJsonNode (input : InternalTypeNotExtensionSerial) : System.Text.Json.Nodes.JsonNode = let toJsonNode (input : InternalTypeNotExtensionSerial) : System.Text.Json.Nodes.JsonNode =
let node = System.Text.Json.Nodes.JsonObject () let node = System.Text.Json.Nodes.JsonObject ()
do node.Add ((Literals.something), (input.InternalThing2 |> System.Text.Json.Nodes.JsonValue.Create<string>))
do
node.Add (
(Literals.something),
(input.InternalThing2
|> (fun field ->
let field = System.Text.Json.Nodes.JsonValue.Create<string> field
(match field with
| null ->
raise (
System.ArgumentNullException
"Expected type string to be non-null, but received a null value when serialising"
)
| field -> field)
))
)
node :> _ node :> _
namespace ConsumePlugin namespace ConsumePlugin
@@ -46,24 +29,7 @@ module internal InternalTypeExtensionJsonSerializeExtension =
/// Serialize to a JSON node /// Serialize to a JSON node
static member toJsonNode (input : InternalTypeExtension) : System.Text.Json.Nodes.JsonNode = static member toJsonNode (input : InternalTypeExtension) : System.Text.Json.Nodes.JsonNode =
let node = System.Text.Json.Nodes.JsonObject () let node = System.Text.Json.Nodes.JsonObject ()
do node.Add ((Literals.something), (input.ExternalThing |> System.Text.Json.Nodes.JsonValue.Create<string>))
do
node.Add (
(Literals.something),
(input.ExternalThing
|> (fun field ->
let field = System.Text.Json.Nodes.JsonValue.Create<string> field
(match field with
| null ->
raise (
System.ArgumentNullException
"Expected type string to be non-null, but received a null value when serialising"
)
| field -> field)
))
)
node :> _ node :> _
namespace ConsumePlugin namespace ConsumePlugin
@@ -74,14 +40,16 @@ module InnerType =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : InnerType = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : InnerType =
let arg_0 = let arg_0 =
match node.[(Literals.something)] |> Option.ofObj with (match node.[(Literals.something)] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ((Literals.something)) sprintf "Required key '%s' not found on JSON object" ((Literals.something))
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
Thing = arg_0 Thing = arg_0
@@ -94,97 +62,79 @@ module JsonRecordType =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JsonRecordType = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JsonRecordType =
let arg_5 = let arg_5 =
match node.["f"] |> Option.ofObj with (match node.["f"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("f") sprintf "Required key '%s' not found on JSON object" ("f")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
(match elt with |> Array.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type int32) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.Int32> ())
)
|> Array.ofSeq
let arg_4 = let arg_4 =
match node.["e"] |> Option.ofObj with (match node.["e"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("e") sprintf "Required key '%s' not found on JSON object" ("e")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
(match elt with |> Array.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type string) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.String> ())
)
|> Array.ofSeq
let arg_3 = let arg_3 =
match node.["d"] |> Option.ofObj with InnerType.jsonParse (
| None -> match node.["d"] with
raise ( | null ->
System.Collections.Generic.KeyNotFoundException ( raise (
sprintf "Required key '%s' not found on JSON object" ("d") System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("d")
)
) )
) | v -> v
| Some node -> InnerType.jsonParse node )
let arg_2 = let arg_2 =
match node.["hi"] |> Option.ofObj with (match node.["hi"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("hi") sprintf "Required key '%s' not found on JSON object" ("hi")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.Int32> ())
(match elt with |> List.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type int32) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.Int32> ())
)
|> List.ofSeq
let arg_1 = let arg_1 =
match node.["another-thing"] |> Option.ofObj with (match node.["another-thing"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("another-thing") sprintf "Required key '%s' not found on JSON object" ("another-thing")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_0 = let arg_0 =
match node.["a"] |> Option.ofObj with (match node.["a"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("a") sprintf "Required key '%s' not found on JSON object" ("a")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
{ {
A = arg_0 A = arg_0
@@ -202,14 +152,16 @@ module internal InternalTypeNotExtension =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : InternalTypeNotExtension = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : InternalTypeNotExtension =
let arg_0 = let arg_0 =
match node.[(Literals.something)] |> Option.ofObj with (match node.[(Literals.something)] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ((Literals.something)) sprintf "Required key '%s' not found on JSON object" ((Literals.something))
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
InternalThing = arg_0 InternalThing = arg_0
@@ -225,14 +177,16 @@ module internal InternalTypeExtensionJsonParseExtension =
/// Parse from a JSON node. /// Parse from a JSON node.
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : InternalTypeExtension = static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : InternalTypeExtension =
let arg_0 = let arg_0 =
match node.[(Literals.something)] |> Option.ofObj with (match node.[(Literals.something)] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ((Literals.something)) sprintf "Required key '%s' not found on JSON object" ((Literals.something))
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
ExternalThing = arg_0 ExternalThing = arg_0
@@ -247,215 +201,248 @@ module ToGetExtensionMethodJsonParseExtension =
/// Parse from a JSON node. /// Parse from a JSON node.
static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : ToGetExtensionMethod = static member jsonParse (node : System.Text.Json.Nodes.JsonNode) : ToGetExtensionMethod =
let arg_20 = let arg_20 = System.Numerics.BigInteger.Parse (node.["whiskey"].ToJsonString ())
match node.["whiskey"] |> Option.ofObj with
| None ->
raise (
System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("whiskey")
)
)
| Some node -> System.Numerics.BigInteger.Parse (node.ToJsonString ())
let arg_19 = let arg_19 =
match node.["victor"] |> Option.ofObj with (match node.["victor"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("victor") sprintf "Required key '%s' not found on JSON object" ("victor")
) )
) )
| Some node -> node.AsValue().GetValue<System.Char> () | v -> v)
.AsValue()
.GetValue<System.Char> ()
let arg_18 = let arg_18 =
match node.["uniform"] |> Option.ofObj with (match node.["uniform"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("uniform") sprintf "Required key '%s' not found on JSON object" ("uniform")
) )
) )
| Some node -> node.AsValue().GetValue<System.Decimal> () | v -> v)
.AsValue()
.GetValue<System.Decimal> ()
let arg_17 = let arg_17 =
match node.["tango"] |> Option.ofObj with (match node.["tango"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("tango") sprintf "Required key '%s' not found on JSON object" ("tango")
) )
) )
| Some node -> node.AsValue().GetValue<System.SByte> () | v -> v)
.AsValue()
.GetValue<System.SByte> ()
let arg_16 = let arg_16 =
match node.["quebec"] |> Option.ofObj with (match node.["quebec"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("quebec") sprintf "Required key '%s' not found on JSON object" ("quebec")
) )
) )
| Some node -> node.AsValue().GetValue<System.Byte> () | v -> v)
.AsValue()
.GetValue<System.Byte> ()
let arg_15 = let arg_15 =
match node.["papa"] |> Option.ofObj with (match node.["papa"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("papa") sprintf "Required key '%s' not found on JSON object" ("papa")
) )
) )
| Some node -> node.AsValue().GetValue<System.Byte> () | v -> v)
.AsValue()
.GetValue<System.Byte> ()
let arg_14 = let arg_14 =
match node.["oscar"] |> Option.ofObj with (match node.["oscar"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("oscar") sprintf "Required key '%s' not found on JSON object" ("oscar")
) )
) )
| Some node -> node.AsValue().GetValue<System.SByte> () | v -> v)
.AsValue()
.GetValue<System.SByte> ()
let arg_13 = let arg_13 =
match node.["november"] |> Option.ofObj with (match node.["november"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("november") sprintf "Required key '%s' not found on JSON object" ("november")
) )
) )
| Some node -> node.AsValue().GetValue<System.UInt16> () | v -> v)
.AsValue()
.GetValue<System.UInt16> ()
let arg_12 = let arg_12 =
match node.["mike"] |> Option.ofObj with (match node.["mike"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("mike") sprintf "Required key '%s' not found on JSON object" ("mike")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int16> () | v -> v)
.AsValue()
.GetValue<System.Int16> ()
let arg_11 = let arg_11 =
match node.["lima"] |> Option.ofObj with (match node.["lima"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lima") sprintf "Required key '%s' not found on JSON object" ("lima")
) )
) )
| Some node -> node.AsValue().GetValue<System.UInt32> () | v -> v)
.AsValue()
.GetValue<System.UInt32> ()
let arg_10 = let arg_10 =
match node.["kilo"] |> Option.ofObj with (match node.["kilo"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("kilo") sprintf "Required key '%s' not found on JSON object" ("kilo")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_9 = let arg_9 =
match node.["juliette"] |> Option.ofObj with (match node.["juliette"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("juliette") sprintf "Required key '%s' not found on JSON object" ("juliette")
) )
) )
| Some node -> node.AsValue().GetValue<System.UInt32> () | v -> v)
.AsValue()
.GetValue<System.UInt32> ()
let arg_8 = let arg_8 =
match node.["india"] |> Option.ofObj with (match node.["india"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("india") sprintf "Required key '%s' not found on JSON object" ("india")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_7 = let arg_7 =
match node.["hotel"] |> Option.ofObj with (match node.["hotel"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("hotel") sprintf "Required key '%s' not found on JSON object" ("hotel")
) )
) )
| Some node -> node.AsValue().GetValue<System.UInt64> () | v -> v)
.AsValue()
.GetValue<System.UInt64> ()
let arg_6 = let arg_6 =
match node.["golf"] |> Option.ofObj with (match node.["golf"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("golf") sprintf "Required key '%s' not found on JSON object" ("golf")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int64> () | v -> v)
.AsValue()
.GetValue<System.Int64> ()
let arg_5 = let arg_5 =
match node.["foxtrot"] |> Option.ofObj with (match node.["foxtrot"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("foxtrot") sprintf "Required key '%s' not found on JSON object" ("foxtrot")
) )
) )
| Some node -> node.AsValue().GetValue<System.Double> () | v -> v)
.AsValue()
.GetValue<System.Double> ()
let arg_4 = let arg_4 =
match node.["echo"] |> Option.ofObj with (match node.["echo"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("echo") sprintf "Required key '%s' not found on JSON object" ("echo")
) )
) )
| Some node -> node.AsValue().GetValue<System.Single> () | v -> v)
.AsValue()
.GetValue<System.Single> ()
let arg_3 = let arg_3 =
match node.["delta"] |> Option.ofObj with (match node.["delta"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("delta") sprintf "Required key '%s' not found on JSON object" ("delta")
) )
) )
| Some node -> node.AsValue().GetValue<System.Single> () | v -> v)
.AsValue()
.GetValue<System.Single> ()
let arg_2 = let arg_2 =
match node.["charlie"] |> Option.ofObj with (match node.["charlie"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("charlie") sprintf "Required key '%s' not found on JSON object" ("charlie")
) )
) )
| Some node -> node.AsValue().GetValue<System.Double> () | v -> v)
.AsValue()
.GetValue<System.Double> ()
let arg_1 = let arg_1 =
match node.["bravo"] |> Option.ofObj with (match node.["bravo"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("bravo") sprintf "Required key '%s' not found on JSON object" ("bravo")
) )
) )
| Some node -> node.AsValue().GetValue<string> () |> System.Uri | v -> v)
.AsValue()
.GetValue<string> ()
|> System.Uri
let arg_0 = let arg_0 =
match node.["alpha"] |> Option.ofObj with (match node.["alpha"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("alpha") sprintf "Required key '%s' not found on JSON object" ("alpha")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
Alpha = arg_0 Alpha = arg_0

View File

@@ -206,34 +206,3 @@ type internal TypeWithInterfaceMock =
interface System.IDisposable with interface System.IDisposable with
member this.Dispose () : unit = this.Dispose () member this.Dispose () : unit = this.Dispose ()
namespace SomeNamespace
open System
open WoofWare.Myriad.Plugins
/// Mock record type for an interface
type internal TypeWithPropertiesMock =
{
/// Implementation of IDisposable.Dispose
Dispose : unit -> unit
Prop1 : unit -> int
Prop2 : unit -> unit Async
Mem1 : string option -> string[] Async
}
/// An implementation where every method throws.
static member Empty : TypeWithPropertiesMock =
{
Dispose = (fun () -> ())
Prop1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Prop1"))
Prop2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Prop2"))
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
}
interface TypeWithProperties with
member this.Mem1 arg_0_0 = this.Mem1 (arg_0_0)
member this.Prop1 = this.Prop1 ()
member this.Prop2 = this.Prop2 ()
interface System.IDisposable with
member this.Dispose () : unit = this.Dispose ()

File diff suppressed because it is too large Load Diff

View File

@@ -48,27 +48,7 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode = return jsonNode.AsArray () |> Seq.map (fun elt -> Gym.jsonParse elt) |> List.ofSeq
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Gym list"
)
| jsonNode -> jsonNode)
return
jsonNode.AsArray ()
|> Seq.map (fun elt ->
(match elt with
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type Gym) to be non-null, but found a null element"
)
| elt -> Gym.jsonParse elt)
)
|> List.ofSeq
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -102,15 +82,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type GymAttendance"
)
| jsonNode -> jsonNode)
return GymAttendance.jsonParse jsonNode return GymAttendance.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -145,15 +116,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type GymAttendance"
)
| jsonNode -> jsonNode)
return GymAttendance.jsonParse jsonNode return GymAttendance.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -184,15 +146,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Member"
)
| jsonNode -> jsonNode)
return Member.jsonParse jsonNode return Member.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -207,7 +160,8 @@ module PureGymApi =
| null -> System.Uri "https://whatnot.com/" | null -> System.Uri "https://whatnot.com/"
| v -> v), | v -> v),
System.Uri ( System.Uri (
"v1/gyms/{gym}".Replace ("{gym}", gym.ToString () |> System.Uri.EscapeDataString), "v1/gyms/{gym}"
.Replace ("{gym}", gym.ToString () |> System.Uri.EscapeDataString),
System.UriKind.Relative System.UriKind.Relative
) )
) )
@@ -226,15 +180,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Gym"
)
| jsonNode -> jsonNode)
return Gym.jsonParse jsonNode return Gym.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -265,15 +210,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type MemberActivityDto"
)
| jsonNode -> jsonNode)
return MemberActivityDto.jsonParse jsonNode return MemberActivityDto.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -304,15 +240,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type UriThing"
)
| jsonNode -> jsonNode)
return UriThing.jsonParse jsonNode return UriThing.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -340,42 +267,23 @@ module PureGymApi =
foo foo
|> (fun field -> |> (fun field ->
match field with match field with
| None -> None | None -> null :> System.Text.Json.Nodes.JsonNode
| Some field -> | Some field ->
(field ((fun field ->
|> (fun field -> let ret = System.Text.Json.Nodes.JsonObject ()
let ret = System.Text.Json.Nodes.JsonObject ()
for (KeyValue (key, value)) in field do for (KeyValue (key, value)) in field do
let key = key.ToString () ret.Add (
key.ToString (),
System.Text.Json.Nodes.JsonValue.Create<string> value
)
ret.Add ( ret
key, )
(fun field -> field)
let field =
System.Text.Json.Nodes.JsonValue.Create<string> field
(match field with
| null ->
raise (
System.ArgumentNullException
"Expected type string to be non-null, but received a null value when serialising"
)
| field -> field)
)
value
)
ret
))
:> System.Text.Json.Nodes.JsonNode :> System.Text.Json.Nodes.JsonNode
|> Some
)
|> (fun node ->
match node with
| None -> "null"
| Some node -> node.ToJsonString ()
) )
|> (fun node -> if isNull node then "null" else node.ToJsonString ())
) )
do httpMessage.Content <- queryParams do httpMessage.Content <- queryParams
@@ -387,25 +295,15 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode = jsonNode |> Option.ofObj
return return
match jsonNode with match jsonNode with
| None -> None | null -> None
| Some v -> | v ->
v.AsObject () v.AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key,
(match value with
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
) )
|> Map.ofSeq |> Map.ofSeq
|> Some |> Some
@@ -449,15 +347,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Sessions"
)
| jsonNode -> jsonNode)
return Sessions.jsonParse jsonNode return Sessions.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -499,15 +388,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Sessions"
)
| jsonNode -> jsonNode)
return Sessions.jsonParse jsonNode return Sessions.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -667,7 +547,9 @@ module PureGymApi =
let queryParams = let queryParams =
new System.Net.Http.StringContent ( new System.Net.Http.StringContent (
user |> PureGym.Member.toJsonNode |> (fun node -> node.ToJsonString ()) user
|> PureGym.Member.toJsonNode
|> (fun node -> if isNull node then "null" else node.ToJsonString ())
) )
do httpMessage.Content <- queryParams do httpMessage.Content <- queryParams
@@ -699,18 +581,8 @@ module PureGymApi =
let queryParams = let queryParams =
new System.Net.Http.StringContent ( new System.Net.Http.StringContent (
user user
|> (fun field -> |> System.Text.Json.Nodes.JsonValue.Create<Uri>
let field = System.Text.Json.Nodes.JsonValue.Create<Uri> field |> (fun node -> if isNull node then "null" else node.ToJsonString ())
(match field with
| null ->
raise (
System.ArgumentNullException
"Expected type URI to be non-null, but received a null value when serialising"
)
| field -> field)
)
|> (fun node -> node.ToJsonString ())
) )
do httpMessage.Content <- queryParams do httpMessage.Content <- queryParams
@@ -742,18 +614,8 @@ module PureGymApi =
let queryParams = let queryParams =
new System.Net.Http.StringContent ( new System.Net.Http.StringContent (
user user
|> (fun field -> |> System.Text.Json.Nodes.JsonValue.Create<int>
let field = System.Text.Json.Nodes.JsonValue.Create<int> field |> (fun node -> if isNull node then "null" else node.ToJsonString ())
(match field with
| null ->
raise (
System.ArgumentNullException
"Expected type int32 to be non-null, but received a null value when serialising"
)
| field -> field)
)
|> (fun node -> node.ToJsonString ())
) )
do httpMessage.Content <- queryParams do httpMessage.Content <- queryParams
@@ -1017,15 +879,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Response<MemberActivityDto>"
)
| jsonNode -> jsonNode)
return return
new RestEase.Response<_> ( new RestEase.Response<_> (
responseString, responseString,
@@ -1062,15 +915,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type RestEase.Response<MemberActivityDto>"
)
| jsonNode -> jsonNode)
return return
new RestEase.Response<_> ( new RestEase.Response<_> (
responseString, responseString,
@@ -1107,15 +951,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type Response<MemberActivityDto>"
)
| jsonNode -> jsonNode)
return return
new RestEase.Response<_> ( new RestEase.Response<_> (
responseString, responseString,
@@ -1152,15 +987,6 @@ module PureGymApi =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type RestEase.Response<MemberActivityDto>"
)
| jsonNode -> jsonNode)
return return
new RestEase.Response<_> ( new RestEase.Response<_> (
responseString, responseString,

File diff suppressed because it is too large Load Diff

View File

@@ -13,147 +13,139 @@ module JwtVaultAuthResponse =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultAuthResponse = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultAuthResponse =
let arg_10 = let arg_10 =
match node.["num_uses"] |> Option.ofObj with (match node.["num_uses"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("num_uses") sprintf "Required key '%s' not found on JSON object" ("num_uses")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_9 = let arg_9 =
match node.["orphan"] |> Option.ofObj with (match node.["orphan"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("orphan") sprintf "Required key '%s' not found on JSON object" ("orphan")
) )
) )
| Some node -> node.AsValue().GetValue<System.Boolean> () | v -> v)
.AsValue()
.GetValue<System.Boolean> ()
let arg_8 = let arg_8 =
match node.["entity_id"] |> Option.ofObj with (match node.["entity_id"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("entity_id") sprintf "Required key '%s' not found on JSON object" ("entity_id")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_7 = let arg_7 =
match node.["token_type"] |> Option.ofObj with (match node.["token_type"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("token_type") sprintf "Required key '%s' not found on JSON object" ("token_type")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_6 = let arg_6 =
match node.["renewable"] |> Option.ofObj with (match node.["renewable"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("renewable") sprintf "Required key '%s' not found on JSON object" ("renewable")
) )
) )
| Some node -> node.AsValue().GetValue<System.Boolean> () | v -> v)
.AsValue()
.GetValue<System.Boolean> ()
let arg_5 = let arg_5 =
match node.["lease_duration"] |> Option.ofObj with (match node.["lease_duration"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lease_duration") sprintf "Required key '%s' not found on JSON object" ("lease_duration")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_4 = let arg_4 =
match node.["identity_policies"] |> Option.ofObj with (match node.["identity_policies"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("identity_policies") sprintf "Required key '%s' not found on JSON object" ("identity_policies")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
(match elt with |> List.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type string) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.String> ())
)
|> List.ofSeq
let arg_3 = let arg_3 =
match node.["token_policies"] |> Option.ofObj with (match node.["token_policies"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("token_policies") sprintf "Required key '%s' not found on JSON object" ("token_policies")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
(match elt with |> List.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type string) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.String> ())
)
|> List.ofSeq
let arg_2 = let arg_2 =
match node.["policies"] |> Option.ofObj with (match node.["policies"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("policies") sprintf "Required key '%s' not found on JSON object" ("policies")
) )
) )
| Some node -> | v -> v)
node.AsArray () .AsArray ()
|> Seq.map (fun elt -> |> Seq.map (fun elt -> elt.AsValue().GetValue<System.String> ())
(match elt with |> List.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected element of array (element type string) to be non-null, but found a null element"
)
| elt -> elt.AsValue().GetValue<System.String> ())
)
|> List.ofSeq
let arg_1 = let arg_1 =
match node.["accessor"] |> Option.ofObj with (match node.["accessor"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("accessor") sprintf "Required key '%s' not found on JSON object" ("accessor")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_0 = let arg_0 =
match node.["client_token"] |> Option.ofObj with (match node.["client_token"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("client_token") sprintf "Required key '%s' not found on JSON object" ("client_token")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
ClientToken = arg_0 ClientToken = arg_0
@@ -176,54 +168,64 @@ module JwtVaultResponse =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultResponse = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtVaultResponse =
let arg_4 = let arg_4 =
match node.["auth"] |> Option.ofObj with JwtVaultAuthResponse.jsonParse (
| None -> match node.["auth"] with
raise ( | null ->
System.Collections.Generic.KeyNotFoundException ( raise (
sprintf "Required key '%s' not found on JSON object" ("auth") System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("auth")
)
) )
) | v -> v
| Some node -> JwtVaultAuthResponse.jsonParse node )
let arg_3 = let arg_3 =
match node.["lease_duration"] |> Option.ofObj with (match node.["lease_duration"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lease_duration") sprintf "Required key '%s' not found on JSON object" ("lease_duration")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_2 = let arg_2 =
match node.["renewable"] |> Option.ofObj with (match node.["renewable"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("renewable") sprintf "Required key '%s' not found on JSON object" ("renewable")
) )
) )
| Some node -> node.AsValue().GetValue<System.Boolean> () | v -> v)
.AsValue()
.GetValue<System.Boolean> ()
let arg_1 = let arg_1 =
match node.["lease_id"] |> Option.ofObj with (match node.["lease_id"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lease_id") sprintf "Required key '%s' not found on JSON object" ("lease_id")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_0 = let arg_0 =
match node.["request_id"] |> Option.ofObj with (match node.["request_id"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("request_id") sprintf "Required key '%s' not found on JSON object" ("request_id")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
RequestId = arg_0 RequestId = arg_0
@@ -240,246 +242,190 @@ module JwtSecretResponse =
/// Parse from a JSON node. /// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtSecretResponse = let jsonParse (node : System.Text.Json.Nodes.JsonNode) : JwtSecretResponse =
let arg_11 = let arg_11 =
match node.["data8"] |> Option.ofObj with (match node.["data8"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data8") sprintf "Required key '%s' not found on JSON object" ("data8")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<string> () |> System.Uri
key, value
key, )
(match value with |> Seq.map System.Collections.Generic.KeyValuePair
| null -> |> System.Collections.Generic.Dictionary
raise (
System.ArgumentNullException
"Expected dictionary value of type URI to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<string> () |> System.Uri)
)
|> Seq.map System.Collections.Generic.KeyValuePair
|> System.Collections.Generic.Dictionary
let arg_10 = let arg_10 =
match node.["data7"] |> Option.ofObj with (match node.["data7"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data7") sprintf "Required key '%s' not found on JSON object" ("data7")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.Int32> ()
key, value
key, )
(match value with |> Map.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type int32 to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.Int32> ())
)
|> Map.ofSeq
let arg_9 = let arg_9 =
match node.["data6"] |> Option.ofObj with (match node.["data6"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data6") sprintf "Required key '%s' not found on JSON object" ("data6")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) |> System.Uri let key = (kvp.Key) |> System.Uri
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> dict
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> dict
let arg_8 = let arg_8 =
match node.["data5"] |> Option.ofObj with (match node.["data5"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data5") sprintf "Required key '%s' not found on JSON object" ("data5")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) |> System.Uri let key = (kvp.Key) |> System.Uri
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> readOnlyDict
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> readOnlyDict
let arg_7 = let arg_7 =
match node.["data4"] |> Option.ofObj with (match node.["data4"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data4") sprintf "Required key '%s' not found on JSON object" ("data4")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> Map.ofSeq
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> Map.ofSeq
let arg_6 = let arg_6 =
match node.["data3"] |> Option.ofObj with (match node.["data3"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data3") sprintf "Required key '%s' not found on JSON object" ("data3")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> Seq.map System.Collections.Generic.KeyValuePair
| null -> |> System.Collections.Generic.Dictionary
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> Seq.map System.Collections.Generic.KeyValuePair
|> System.Collections.Generic.Dictionary
let arg_5 = let arg_5 =
match node.["data2"] |> Option.ofObj with (match node.["data2"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data2") sprintf "Required key '%s' not found on JSON object" ("data2")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> dict
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> dict
let arg_4 = let arg_4 =
match node.["data"] |> Option.ofObj with (match node.["data"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("data") sprintf "Required key '%s' not found on JSON object" ("data")
) )
) )
| Some node -> | v -> v)
node.AsObject () .AsObject ()
|> Seq.map (fun kvp -> |> Seq.map (fun kvp ->
let key = (kvp.Key) let key = (kvp.Key)
let value = kvp.Value let value = (kvp.Value).AsValue().GetValue<System.String> ()
key, value
key, )
(match value with |> readOnlyDict
| null ->
raise (
System.ArgumentNullException
"Expected dictionary value of type string to be non-null, but it was null"
)
| value -> value.AsValue().GetValue<System.String> ())
)
|> readOnlyDict
let arg_3 = let arg_3 =
match node.["lease_duration"] |> Option.ofObj with (match node.["lease_duration"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lease_duration") sprintf "Required key '%s' not found on JSON object" ("lease_duration")
) )
) )
| Some node -> node.AsValue().GetValue<System.Int32> () | v -> v)
.AsValue()
.GetValue<System.Int32> ()
let arg_2 = let arg_2 =
match node.["renewable"] |> Option.ofObj with (match node.["renewable"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("renewable") sprintf "Required key '%s' not found on JSON object" ("renewable")
) )
) )
| Some node -> node.AsValue().GetValue<System.Boolean> () | v -> v)
.AsValue()
.GetValue<System.Boolean> ()
let arg_1 = let arg_1 =
match node.["lease_id"] |> Option.ofObj with (match node.["lease_id"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("lease_id") sprintf "Required key '%s' not found on JSON object" ("lease_id")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
let arg_0 = let arg_0 =
match node.["request_id"] |> Option.ofObj with (match node.["request_id"] with
| None -> | null ->
raise ( raise (
System.Collections.Generic.KeyNotFoundException ( System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("request_id") sprintf "Required key '%s' not found on JSON object" ("request_id")
) )
) )
| Some node -> node.AsValue().GetValue<System.String> () | v -> v)
.AsValue()
.GetValue<System.String> ()
{ {
RequestId = arg_0 RequestId = arg_0
@@ -550,15 +496,6 @@ module VaultClient =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtSecretResponse"
)
| jsonNode -> jsonNode)
return JwtSecretResponse.jsonParse jsonNode return JwtSecretResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -595,15 +532,6 @@ module VaultClient =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtVaultResponse"
)
| jsonNode -> jsonNode)
return JwtVaultResponse.jsonParse jsonNode return JwtVaultResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -662,15 +590,6 @@ module VaultClientNonExtensionMethod =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtSecretResponse"
)
| jsonNode -> jsonNode)
return JwtSecretResponse.jsonParse jsonNode return JwtSecretResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -707,15 +626,6 @@ module VaultClientNonExtensionMethod =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtVaultResponse"
)
| jsonNode -> jsonNode)
return JwtVaultResponse.jsonParse jsonNode return JwtVaultResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -777,15 +687,6 @@ module VaultClientExtensionMethodHttpClientExtension =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtSecretResponse"
)
| jsonNode -> jsonNode)
return JwtSecretResponse.jsonParse jsonNode return JwtSecretResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))
@@ -822,15 +723,6 @@ module VaultClientExtensionMethodHttpClientExtension =
System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct) System.Text.Json.Nodes.JsonNode.ParseAsync (responseStream, cancellationToken = ct)
|> Async.AwaitTask |> Async.AwaitTask
let jsonNode =
(match jsonNode with
| null ->
raise (
System.ArgumentNullException
"Response from server was the JSON null object; expected a non-nullable type JwtVaultResponse"
)
| jsonNode -> jsonNode)
return JwtVaultResponse.jsonParse jsonNode return JwtVaultResponse.jsonParse jsonNode
} }
|> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct)) |> (fun a -> Async.StartAsTask (a, ?cancellationToken = ct))

View File

@@ -48,10 +48,3 @@ type TypeWithInterface =
inherit IDisposable inherit IDisposable
abstract Mem1 : string option -> string[] Async abstract Mem1 : string option -> string[] Async
abstract Mem2 : unit -> string[] Async abstract Mem2 : unit -> string[] Async
[<GenerateMock>]
type TypeWithProperties =
inherit IDisposable
abstract Mem1 : string option -> string[] Async
abstract Prop1 : int
abstract Prop2 : unit Async

View File

@@ -10,7 +10,7 @@
<WarnOn>FS3388,FS3559</WarnOn> <WarnOn>FS3388,FS3559</WarnOn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.8.38-alpha" PrivateAssets="all"/> <PackageReference Include="Nerdbank.GitVersioning" Version="3.6.143" PrivateAssets="all"/>
<SourceLinkGitHubHost Include="github.com" ContentUrl="https://raw.githubusercontent.com"/> <SourceLinkGitHubHost Include="github.com" ContentUrl="https://raw.githubusercontent.com"/>
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="'$(GITHUB_ACTION)' != ''"> <PropertyGroup Condition="'$(GITHUB_ACTION)' != ''">

View File

@@ -26,11 +26,6 @@ type ArgParserAttribute (isExtensionMethod : bool) =
/// an argument which looks like a flag but which we don't recognise.) /// an argument which looks like a flag but which we don't recognise.)
/// We will still interpret `--help` as requesting help, unless it comes after /// We will still interpret `--help` as requesting help, unless it comes after
/// a standalone `--` separator. /// a standalone `--` separator.
///
/// If the type of the PositionalArgs field is `Choice<'a, 'a>`, then we will
/// tell you whether each arg came before or after a standalone `--` separator.
/// For example, `MyApp foo bar -- baz` with PositionalArgs of `Choice<string, string>`
/// would yield `Choice1Of2 foo, Choice1Of2 bar, Choice2Of2 baz`.
type PositionalArgsAttribute (includeFlagLike : bool) = type PositionalArgsAttribute (includeFlagLike : bool) =
inherit Attribute () inherit Attribute ()

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
@@ -17,10 +17,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ApiSurface" Version="4.1.20" /> <PackageReference Include="ApiSurface" Version="4.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="NUnit" Version="4.3.2"/> <PackageReference Include="NUnit" Version="4.2.2"/>
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0"/> <PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -68,7 +68,7 @@ module TestArgParser =
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envCalls |> ignore<int> Interlocked.Increment envCalls |> ignore<int>
None ""
let args = [ "--foo=3" ; "--non-existent" ; "--bar=4" ; "--baz=true" ] let args = [ "--foo=3" ; "--non-existent" ; "--bar=4" ; "--baz=true" ]
@@ -91,7 +91,7 @@ module TestArgParser =
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envCalls |> ignore<int> Interlocked.Increment envCalls |> ignore<int>
None ""
let property (args : (int * bool) list) (afterDoubleDash : int list option) = let property (args : (int * bool) list) (afterDoubleDash : int list option) =
let flatArgs = let flatArgs =
@@ -127,7 +127,7 @@ module TestArgParser =
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envCalls |> ignore<int> Interlocked.Increment envCalls |> ignore<int>
None ""
let args = [ "--foo=3" ; "--rest" ; "7" ; "--bar=4" ; "--baz=true" ; "--rest=8" ] let args = [ "--foo=3" ; "--rest" ; "7" ; "--bar=4" ; "--baz=true" ; "--rest=8" ]
@@ -150,7 +150,7 @@ module TestArgParser =
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envCalls |> ignore<int> Interlocked.Increment envCalls |> ignore<int>
None ""
let args = [ "--foo=3" ; "--foo" ; "9" ; "--bar=4" ; "--baz=true" ; "--baz=false" ] let args = [ "--foo=3" ; "--foo" ; "9" ; "--bar=4" ; "--baz=true" ; "--baz=false" ]
@@ -171,7 +171,7 @@ Argument '--baz' was supplied multiple times: True and false"""
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envCalls |> ignore<int> Interlocked.Increment envCalls |> ignore<int>
None ""
let args = [ "--" ; "--foo=3" ; "--bar=4" ; "--baz=true" ] let args = [ "--" ; "--foo=3" ; "--bar=4" ; "--baz=true" ]
@@ -191,7 +191,7 @@ Required argument '--baz' received no value"""
let ``Help text`` () = let ``Help text`` () =
let getEnvVar (s : string) = let getEnvVar (s : string) =
s |> shouldEqual "CONSUMEPLUGIN_THINGS" s |> shouldEqual "CONSUMEPLUGIN_THINGS"
Some "hi!" "hi!"
let exc = let exc =
Assert.Throws<exn> (fun () -> Basic.parse' getEnvVar [ "--help" ] |> ignore<Basic>) Assert.Throws<exn> (fun () -> Basic.parse' getEnvVar [ "--help" ] |> ignore<Basic>)
@@ -210,7 +210,7 @@ Required argument '--baz' received no value"""
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment envVars |> ignore<int> Interlocked.Increment envVars |> ignore<int>
None ""
let exc = let exc =
Assert.Throws<exn> (fun () -> LoadsOfTypes.parse' getEnvVar [ "--help" ] |> ignore<LoadsOfTypes>) Assert.Throws<exn> (fun () -> LoadsOfTypes.parse' getEnvVar [ "--help" ] |> ignore<LoadsOfTypes>)
@@ -236,7 +236,7 @@ Required argument '--baz' received no value"""
let ``Default values`` () = let ``Default values`` () =
let getEnvVar (s : string) = let getEnvVar (s : string) =
s |> shouldEqual "CONSUMEPLUGIN_THINGS" s |> shouldEqual "CONSUMEPLUGIN_THINGS"
Some "hi!" "hi!"
let args = let args =
[ [
@@ -264,7 +264,7 @@ Required argument '--baz' received no value"""
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment count |> ignore<int> Interlocked.Increment count |> ignore<int>
None ""
let exc = let exc =
Assert.Throws<exn> (fun () -> DatesAndTimes.parse' getEnvVar [ "--help" ] |> ignore<DatesAndTimes>) Assert.Throws<exn> (fun () -> DatesAndTimes.parse' getEnvVar [ "--help" ] |> ignore<DatesAndTimes>)
@@ -285,7 +285,7 @@ Required argument '--baz' received no value"""
let getEnvVar (_ : string) = let getEnvVar (_ : string) =
Interlocked.Increment count |> ignore<int> Interlocked.Increment count |> ignore<int>
None ""
let parsed = let parsed =
DatesAndTimes.parse' DatesAndTimes.parse'
@@ -448,7 +448,7 @@ Required argument '--exact' received no value"""
let ``Bool env vars can be populated`` (envValue : string, boolValue : bool) = let ``Bool env vars can be populated`` (envValue : string, boolValue : bool) =
let getEnvVar (s : string) = let getEnvVar (s : string) =
s |> shouldEqual "CONSUMEPLUGIN_THINGS" s |> shouldEqual "CONSUMEPLUGIN_THINGS"
Some envValue envValue
ContainsBoolEnvVar.parse' getEnvVar [] ContainsBoolEnvVar.parse' getEnvVar []
|> shouldEqual |> shouldEqual
@@ -470,7 +470,7 @@ Required argument '--exact' received no value"""
let ``Flag DUs can be parsed from env var`` (envValue : string, boolValue : bool) = let ``Flag DUs can be parsed from env var`` (envValue : string, boolValue : bool) =
let getEnvVar (s : string) = let getEnvVar (s : string) =
s |> shouldEqual "CONSUMEPLUGIN_THINGS" s |> shouldEqual "CONSUMEPLUGIN_THINGS"
Some envValue envValue
let boolValue = if boolValue then DryRunMode.Dry else DryRunMode.Wet let boolValue = if boolValue then DryRunMode.Dry else DryRunMode.Wet

View File

@@ -3,7 +3,7 @@ namespace WoofWare.Myriad.Plugins.Test
open System open System
open System.Collections.Generic open System.Collections.Generic
open System.Text.Json.Nodes open System.Text.Json.Nodes
open FsCheck.FSharp open FsCheck.Random
open Microsoft.FSharp.Reflection open Microsoft.FSharp.Reflection
open NUnit.Framework open NUnit.Framework
open FsCheck open FsCheck
@@ -15,21 +15,21 @@ module TestJsonSerde =
let uriGen : Gen<Uri> = let uriGen : Gen<Uri> =
gen { gen {
let! suffix = ArbMap.generate<int> ArbMap.defaults let! suffix = Arb.generate<int>
return Uri $"https://example.com/%i{suffix}" return Uri $"https://example.com/%i{suffix}"
} }
let rec innerGen (count : int) : Gen<InnerTypeWithBoth> = let rec innerGen (count : int) : Gen<InnerTypeWithBoth> =
gen { gen {
let! guid = ArbMap.generate<Guid> ArbMap.defaults let! guid = Arb.generate<Guid>
let! mapKeys = Gen.listOf (ArbMap.generate<NonNull<string>> ArbMap.defaults) let! mapKeys = Gen.listOf Arb.generate<NonNull<string>>
let mapKeys = mapKeys |> List.map _.Get |> List.distinct let mapKeys = mapKeys |> List.map _.Get |> List.distinct
let! mapValues = Gen.listOfLength mapKeys.Length uriGen let! mapValues = Gen.listOfLength mapKeys.Length uriGen
let map = List.zip mapKeys mapValues |> Map.ofList let map = List.zip mapKeys mapValues |> Map.ofList
let! concreteDictKeys = let! concreteDictKeys =
if count > 0 then if count > 0 then
Gen.listOf (ArbMap.generate<NonNull<string>> ArbMap.defaults) Gen.listOf Arb.generate<NonNull<string>>
else else
Gen.constant [] Gen.constant []
@@ -50,16 +50,13 @@ module TestJsonSerde =
|> List.map KeyValuePair |> List.map KeyValuePair
|> Dictionary |> Dictionary
let! readOnlyDictKeys = Gen.listOf (ArbMap.generate<NonNull<string>> ArbMap.defaults) let! readOnlyDictKeys = Gen.listOf Arb.generate<NonNull<string>>
let readOnlyDictKeys = readOnlyDictKeys |> List.map _.Get |> List.distinct let readOnlyDictKeys = readOnlyDictKeys |> List.map _.Get |> List.distinct
let! readOnlyDictValues = Gen.listOfLength readOnlyDictKeys.Length (Gen.listOf Arb.generate<char>)
let! readOnlyDictValues =
Gen.listOfLength readOnlyDictKeys.Length (Gen.listOf (ArbMap.generate<char> ArbMap.defaults))
let readOnlyDict = List.zip readOnlyDictKeys readOnlyDictValues |> readOnlyDict let readOnlyDict = List.zip readOnlyDictKeys readOnlyDictValues |> readOnlyDict
let! dictKeys = Gen.listOf uriGen let! dictKeys = Gen.listOf uriGen
let! dictValues = Gen.listOfLength dictKeys.Length (ArbMap.generate<bool> ArbMap.defaults) let! dictValues = Gen.listOfLength dictKeys.Length Arb.generate<bool>
let dict = List.zip dictKeys dictValues |> dict let dict = List.zip dictKeys dictValues |> dict
return return
@@ -74,38 +71,28 @@ module TestJsonSerde =
let outerGen : Gen<JsonRecordTypeWithBoth> = let outerGen : Gen<JsonRecordTypeWithBoth> =
gen { gen {
let! a = ArbMap.generate<int> ArbMap.defaults let! a = Arb.generate<int>
let! b = ArbMap.generate<NonNull<string>> ArbMap.defaults let! b = Arb.generate<NonNull<string>>
let! c = Gen.listOf (ArbMap.generate<int> ArbMap.defaults) let! c = Gen.listOf Arb.generate<int>
let! depth = Gen.choose (0, 2) let! depth = Gen.choose (0, 2)
let! d = innerGen depth let! d = innerGen depth
let! e = Gen.arrayOf (ArbMap.generate<NonNull<string>> ArbMap.defaults) let! e = Gen.arrayOf Arb.generate<NonNull<string>>
let! arr = Gen.arrayOf (ArbMap.generate<int> ArbMap.defaults) let! arr = Gen.arrayOf Arb.generate<int>
let! byte = ArbMap.generate ArbMap.defaults let! byte = Arb.generate
let! sbyte = ArbMap.generate ArbMap.defaults let! sbyte = Arb.generate
let! i = ArbMap.generate ArbMap.defaults let! i = Arb.generate
let! i32 = ArbMap.generate ArbMap.defaults let! i32 = Arb.generate
let! i64 = ArbMap.generate ArbMap.defaults let! i64 = Arb.generate
let! u = ArbMap.generate ArbMap.defaults let! u = Arb.generate
let! u32 = ArbMap.generate ArbMap.defaults let! u32 = Arb.generate
let! u64 = ArbMap.generate ArbMap.defaults let! u64 = Arb.generate
let! f = Arb.generate |> Gen.filter (fun s -> Double.IsFinite (s / 1.0<measure>))
let! f = let! f32 = Arb.generate |> Gen.filter (fun s -> Single.IsFinite (s / 1.0f<measure>))
ArbMap.generate ArbMap.defaults let! single = Arb.generate |> Gen.filter (fun s -> Single.IsFinite (s / 1.0f<measure>))
|> Gen.filter (fun s -> Double.IsFinite (s / 1.0<measure>)) let! intMeasureOption = Arb.generate
let! intMeasureNullable = Arb.generate
let! f32 =
ArbMap.generate ArbMap.defaults
|> Gen.filter (fun s -> Single.IsFinite (s / 1.0f<measure>))
let! single =
ArbMap.generate ArbMap.defaults
|> Gen.filter (fun s -> Single.IsFinite (s / 1.0f<measure>))
let! intMeasureOption = ArbMap.generate ArbMap.defaults
let! intMeasureNullable = ArbMap.generate ArbMap.defaults
let! someEnum = Gen.choose (0, 1) let! someEnum = Gen.choose (0, 1)
let! timestamp = ArbMap.generate ArbMap.defaults let! timestamp = Arb.generate
return return
{ {
@@ -283,10 +270,10 @@ module TestJsonSerde =
match case with match case with
| 0 -> return FirstDu.EmptyCase | 0 -> return FirstDu.EmptyCase
| 1 -> | 1 ->
let! s = ArbMap.generate<NonNull<string>> ArbMap.defaults let! s = Arb.generate<NonNull<string>>
return FirstDu.Case1 s.Get return FirstDu.Case1 s.Get
| 2 -> | 2 ->
let! i = ArbMap.generate<int> ArbMap.defaults let! i = Arb.generate<int>
let! record = outerGen let! record = outerGen
return FirstDu.Case2 (record, i) return FirstDu.Case2 (record, i)
| _ -> return failwith $"unexpected: %i{case}" | _ -> return failwith $"unexpected: %i{case}"
@@ -306,6 +293,7 @@ module TestJsonSerde =
[<Test>] [<Test>]
let ``DU generator covers all cases`` () = let ``DU generator covers all cases`` () =
let rand = Random ()
let cases = FSharpType.GetUnionCases typeof<FirstDu> let cases = FSharpType.GetUnionCases typeof<FirstDu>
let counts = Array.zeroCreate<int> cases.Length let counts = Array.zeroCreate<int> cases.Length
@@ -313,13 +301,11 @@ module TestJsonSerde =
let mutable i = 0 let mutable i = 0
let property (du : FirstDu) = while i < 10_000 && Array.exists (fun i -> i = 0) counts do
let du = Gen.eval 10 (StdGen.StdGen (rand.Next (), rand.Next ())) duGen
let tag = decompose du let tag = decompose du
counts.[tag] <- counts.[tag] + 1 counts.[tag] <- counts.[tag] + 1
i <- i + 1 i <- i + 1
true
Check.One (Config.Quick, Prop.forAll (Arb.fromGen duGen) property)
for i in counts do for i in counts do
i |> shouldBeGreaterThan 0 i |> shouldBeGreaterThan 0

View File

@@ -34,16 +34,3 @@ module TestMockGenerator =
mock.Mem1 3 'a' |> shouldEqual "aaa" mock.Mem1 3 'a' |> shouldEqual "aaa"
mock.Mem2 (3, "hi") 'a' |> shouldEqual "hiahiahi" mock.Mem2 (3, "hi") 'a' |> shouldEqual "hiahiahi"
mock.Mem3 (3, "hi") 'a' |> shouldEqual "hiahiahi" mock.Mem3 (3, "hi") 'a' |> shouldEqual "hiahiahi"
[<Test>]
let ``Example of use: properties`` () =
let mock : TypeWithProperties =
{ TypeWithPropertiesMock.Empty with
Mem1 = fun i -> async { return Option.toArray i }
Prop1 = fun () -> 44
}
:> _
mock.Mem1 (Some "hi") |> Async.RunSynchronously |> shouldEqual [| "hi" |]
mock.Prop1 |> shouldEqual 44

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
<!-- <!--
@@ -9,7 +9,6 @@
I have not yet seen a single instance where I care about this warning I have not yet seen a single instance where I care about this warning
--> -->
<NoWarn>$(NoWarn),NU1903</NoWarn> <NoWarn>$(NoWarn),NU1903</NoWarn>
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -42,12 +41,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ApiSurface" Version="4.1.20"/> <PackageReference Include="ApiSurface" Version="4.1.5"/>
<PackageReference Include="FsCheck" Version="3.2.0"/> <PackageReference Include="FsCheck" Version="2.16.6"/>
<PackageReference Include="FsUnit" Version="7.0.1"/> <PackageReference Include="FsUnit" Version="6.0.1"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0"/> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="NUnit" Version="4.3.2"/> <PackageReference Include="NUnit" Version="4.2.2"/>
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0"/> <PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -673,7 +673,7 @@ module internal ArgParserGenerator =
args args
|> Map.toList |> Map.toList
|> List.map (fun (ident, expr) -> SynLongIdent.create [ Ident.create ident ], expr) |> List.map (fun (ident, expr) -> SynLongIdent.create [ Ident.create ident ], expr)
|> SynExpr.createRecord None |> AstHelper.instantiateRecord
) )
tree, counter tree, counter
@@ -1396,7 +1396,7 @@ module internal ArgParserGenerator =
[ [
SynMatchClause.create SynMatchClause.create
(SynPat.named "None") SynPat.createNull
(SynExpr.sequential (SynExpr.sequential
[ [
errorMessage errorMessage
@@ -1406,7 +1406,7 @@ module internal ArgParserGenerator =
unchecked unchecked
]) ])
SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "x" ]) parser SynMatchClause.create (SynPat.named "x") parser
] ]
|> SynExpr.createMatch result |> SynExpr.createMatch result
| ArgumentDefaultSpec.FunctionCall name -> | ArgumentDefaultSpec.FunctionCall name ->
@@ -1694,7 +1694,7 @@ module internal ArgParserGenerator =
[ Ident.create "parse'" ] [ Ident.create "parse'" ]
[ [
SynPat.named "getEnvironmentVariable" SynPat.named "getEnvironmentVariable"
|> SynPat.annotateType (SynType.funFromDomain SynType.string (SynType.option SynType.string)) |> SynPat.annotateType (SynType.funFromDomain SynType.string SynType.string)
argsParam argsParam
] ]
|> SynBinding.withReturnAnnotation (SynType.createLongIdent [ taggedType.Name ]) |> SynBinding.withReturnAnnotation (SynType.createLongIdent [ taggedType.Name ])
@@ -1708,12 +1708,7 @@ module internal ArgParserGenerator =
let parse = let parse =
SynExpr.createLongIdent' parsePrimeCall SynExpr.createLongIdent' parsePrimeCall
|> SynExpr.applyTo ( |> SynExpr.applyTo (SynExpr.createLongIdent [ "System" ; "Environment" ; "GetEnvironmentVariable" ])
SynExpr.paren (
SynExpr.createLongIdent [ "System" ; "Environment" ; "GetEnvironmentVariable" ]
|> SynExpr.composeWith (SynExpr.createLongIdent [ "Option" ; "ofObj" ])
)
)
|> SynExpr.applyTo (SynExpr.createIdent "args") |> SynExpr.applyTo (SynExpr.createIdent "args")
|> SynBinding.basic [ Ident.create "parse" ] [ argsParam ] |> SynBinding.basic [ Ident.create "parse" ] [ argsParam ]
|> SynBinding.withReturnAnnotation (SynType.createLongIdent [ taggedType.Name ]) |> SynBinding.withReturnAnnotation (SynType.createLongIdent [ taggedType.Name ])
@@ -1763,7 +1758,10 @@ type ArgParserGenerator () =
let ast, _ = let ast, _ =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let types = Ast.getTypes ast let types =
Ast.extractTypeDefn ast
|> List.groupBy (fst >> List.map _.idText >> String.concat ".")
|> List.map (fun (_, v) -> fst (List.head v), List.collect snd v)
let opens = AstHelper.extractOpens ast let opens = AstHelper.extractOpens ast

View File

@@ -36,6 +36,13 @@ module internal AstHelper =
| SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Enum _, _) -> true | SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Enum _, _) -> true
| _ -> false | _ -> false
let instantiateRecord (fields : (SynLongIdent * SynExpr) list) : SynExpr =
let fields =
fields
|> List.map (fun (rfn, synExpr) -> SynExprRecordField ((rfn, true), Some range0, Some synExpr, None))
SynExpr.Record (None, None, fields, range0)
let defineRecordType (record : RecordType) : SynTypeDefn = let defineRecordType (record : RecordType) : SynTypeDefn =
let name = let name =
SynComponentInfo.create record.Name SynComponentInfo.create record.Name

View File

@@ -1,5 +1,6 @@
namespace WoofWare.Myriad.Plugins namespace WoofWare.Myriad.Plugins
open System.IO
open System.Net.Http open System.Net.Http
open Fantomas.FCS.Syntax open Fantomas.FCS.Syntax
open WoofWare.Whippet.Fantomas open WoofWare.Whippet.Fantomas
@@ -13,6 +14,17 @@ type internal HttpClientGeneratorOutputSpec =
module internal HttpClientGenerator = module internal HttpClientGenerator =
open Fantomas.FCS.Text.Range 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>] [<RequireQualifiedAccess>]
type PathSpec = type PathSpec =
| Verbatim of string | Verbatim of string
@@ -397,59 +409,30 @@ module internal HttpClientGenerator =
| String -> SynExpr.createIdent "responseString" | String -> SynExpr.createIdent "responseString"
| Stream -> SynExpr.createIdent "responseStream" | Stream -> SynExpr.createIdent "responseStream"
| RestEaseResponseType contents -> | RestEaseResponseType contents ->
match JsonNodeWithNullability.Identify contents with let deserialiser =
| CannotBeNull -> JsonParseGenerator.parseNode
let deserialiser = None
JsonParseGenerator.parseNonNullableNode JsonParseGenerator.JsonParseOption.None
None contents
JsonParseGenerator.JsonParseOption.None (SynExpr.createIdent "jsonNode")
contents |> SynExpr.paren
(SynExpr.createIdent "jsonNode") |> SynExpr.createThunk
|> SynExpr.paren
|> SynExpr.createThunk
// new RestEase.Response (content : string, response : HttpResponseMessage, deserialiser : unit -> 'T) // new RestEase.Response (content : string, response : HttpResponseMessage, deserialiser : unit -> 'T)
SynExpr.createNew SynExpr.createNew
(SynType.app' (SynType.createLongIdent' [ "RestEase" ; "Response" ]) [ SynType.Anon range0 ]) (SynType.app' (SynType.createLongIdent' [ "RestEase" ; "Response" ]) [ SynType.Anon range0 ])
(SynExpr.tupleNoParen (SynExpr.tupleNoParen
[ [
SynExpr.createIdent "responseString" SynExpr.createIdent "responseString"
SynExpr.createIdent "response" SynExpr.createIdent "response"
deserialiser deserialiser
]) ])
| Nullable ->
let deserialiser =
JsonParseGenerator.parseNullableNode
None
JsonParseGenerator.JsonParseOption.None
contents
(SynExpr.createIdent "jsonNode")
|> SynExpr.paren
|> SynExpr.createThunk
// new RestEase.Response (content : string, response : HttpResponseMessage, deserialiser : unit -> 'T)
SynExpr.createNew
(SynType.app' (SynType.createLongIdent' [ "RestEase" ; "Response" ]) [ SynType.Anon range0 ])
(SynExpr.tupleNoParen
[
SynExpr.createIdent "responseString"
SynExpr.createIdent "response"
deserialiser
])
| retType -> | retType ->
match JsonNodeWithNullability.Identify retType with JsonParseGenerator.parseNode
| Nullable -> None
JsonParseGenerator.parseNullableNode JsonParseGenerator.JsonParseOption.None
None retType
JsonParseGenerator.JsonParseOption.None (SynExpr.createIdent "jsonNode")
retType
(SynExpr.createIdent "jsonNode")
| CannotBeNull ->
JsonParseGenerator.parseNonNullableNode
None
JsonParseGenerator.JsonParseOption.None
retType
(SynExpr.createIdent "jsonNode")
let contentTypeHeader, memberHeaders = let contentTypeHeader, memberHeaders =
info.Headers info.Headers
@@ -522,45 +505,23 @@ module internal HttpClientGenerator =
) )
] ]
| BodyParamMethods.Serialise ty -> | BodyParamMethods.Serialise ty ->
let isNullable =
match JsonNodeWithNullability.Identify ty with
| CannotBeNull -> false
| Nullable -> true
[ [
Let ( Let (
"queryParams", "queryParams",
createStringContent ( createStringContent (
SynExpr.createIdent' bodyParamName SynExpr.createIdent' bodyParamName
|> SynExpr.pipeThroughFunction ( |> SynExpr.pipeThroughFunction (fst (JsonSerializeGenerator.serializeNode ty))
fst (
(if isNullable then
JsonSerializeGenerator.serializeNodeNullable
else
JsonSerializeGenerator.serializeNodeNonNullable)
ty
)
)
|> SynExpr.pipeThroughFunction ( |> SynExpr.pipeThroughFunction (
SynExpr.createLambda SynExpr.createLambda
"node" "node"
(if isNullable then (SynExpr.ifThenElse
SynExpr.createMatch (SynExpr.applyFunction
(SynExpr.createIdent "node") (SynExpr.createIdent "isNull")
[ (SynExpr.createIdent "node"))
SynMatchClause.create (SynExpr.applyFunction
(SynPat.named "None") (SynExpr.createLongIdent [ "node" ; "ToJsonString" ])
(SynExpr.CreateConst "null") (SynExpr.CreateConst ()))
SynMatchClause.create (SynExpr.CreateConst "null"))
(SynPat.nameWithArgs "Some" [ SynPat.named "node" ])
(SynExpr.applyFunction
(SynExpr.createLongIdent [ "node" ; "ToJsonString" ])
(SynExpr.CreateConst ()))
]
else
(SynExpr.applyFunction
(SynExpr.createLongIdent [ "node" ; "ToJsonString" ])
(SynExpr.CreateConst ())))
) )
) )
) )
@@ -607,24 +568,6 @@ module internal HttpClientGenerator =
) )
) )
let jsonNodeWithoutNull =
match JsonNodeWithNullability.Identify info.TaskReturnType with
| Nullable ->
Let (
"jsonNode",
SynExpr.createIdent "jsonNode"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "ofObj" ])
)
| CannotBeNull ->
Let (
"jsonNode",
JsonSerializeGenerator.assertNotNull
(Ident.create "jsonNode")
(SynExpr.CreateConst
$"Response from server was the JSON null object; expected a non-nullable type %s{SynType.toHumanReadableString info.TaskReturnType}")
(SynExpr.createIdent "jsonNode")
)
let setVariableHeaders = let setVariableHeaders =
variableHeaders variableHeaders
|> List.map (fun (headerName, callToGetValue) -> |> List.map (fun (headerName, callToGetValue) ->
@@ -699,7 +642,6 @@ module internal HttpClientGenerator =
yield responseString yield responseString
yield responseStream yield responseStream
yield jsonNode yield jsonNode
yield jsonNodeWithoutNull
| String -> yield responseString | String -> yield responseString
| Stream -> yield responseStream | Stream -> yield responseStream
| UnitType -> | UnitType ->
@@ -708,7 +650,6 @@ module internal HttpClientGenerator =
| _ -> | _ ->
yield responseStream yield responseStream
yield jsonNode yield jsonNode
yield jsonNodeWithoutNull
] ]
|> SynExpr.createCompExpr "async" returnExpr |> SynExpr.createCompExpr "async" returnExpr
|> SynExpr.startAsTask cancellationTokenArg |> SynExpr.startAsTask cancellationTokenArg
@@ -1055,7 +996,7 @@ type HttpClientGenerator () =
let ast, _ = let ast, _ =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let types = Ast.getTypes ast let types = Ast.extractTypeDefn ast
let opens = AstHelper.extractOpens ast let opens = AstHelper.extractOpens ast

View File

@@ -89,7 +89,7 @@ module internal InterfaceMockGenerator =
[] []
else else
[ SynPat.unit ]) [ SynPat.unit ])
(SynExpr.createRecord None constructorFields) (AstHelper.instantiateRecord constructorFields)
|> SynBinding.withXmlDoc (PreXmlDoc.create "An implementation where every method throws.") |> SynBinding.withXmlDoc (PreXmlDoc.create "An implementation where every method throws.")
|> SynBinding.withReturnAnnotation constructorReturnType |> SynBinding.withReturnAnnotation constructorReturnType
|> SynMemberDefn.staticMember |> SynMemberDefn.staticMember
@@ -159,15 +159,6 @@ module internal InterfaceMockGenerator =
|> SynMemberDefn.memberImplementation |> SynMemberDefn.memberImplementation
) )
let properties =
interfaceType.Properties
|> List.map (fun pi ->
SynExpr.createLongIdent' [ Ident.create "this" ; pi.Identifier ]
|> SynExpr.applyTo (SynExpr.CreateConst ())
|> SynBinding.basic [ Ident.create "this" ; pi.Identifier ] []
|> SynMemberDefn.memberImplementation
)
let interfaceName = let interfaceName =
let baseName = SynType.createLongIdent interfaceType.Name let baseName = SynType.createLongIdent interfaceType.Name
@@ -183,7 +174,7 @@ module internal InterfaceMockGenerator =
SynType.app' baseName generics SynType.app' baseName generics
SynMemberDefn.Interface (interfaceName, Some range0, Some (members @ properties), range0) SynMemberDefn.Interface (interfaceName, Some range0, Some members, range0)
let access = let access =
match interfaceType.Accessibility, spec.IsInternal with match interfaceType.Accessibility, spec.IsInternal with
@@ -257,15 +248,6 @@ module internal InterfaceMockGenerator =
|> SynField.make |> SynField.make
|> SynField.withDocString (mem.XmlDoc |> Option.defaultValue PreXmlDoc.Empty) |> SynField.withDocString (mem.XmlDoc |> Option.defaultValue PreXmlDoc.Empty)
let constructProperty (prop : PropertyInfo) : SynField =
{
Attrs = []
Ident = Some prop.Identifier
Type = SynType.toFun [ SynType.unit ] prop.Type
}
|> SynField.make
|> SynField.withDocString (prop.XmlDoc |> Option.defaultValue PreXmlDoc.Empty)
let createRecord let createRecord
(namespaceId : LongIdent) (namespaceId : LongIdent)
(opens : SynOpenDeclTarget list) (opens : SynOpenDeclTarget list)
@@ -273,12 +255,7 @@ module internal InterfaceMockGenerator =
: SynModuleOrNamespace : SynModuleOrNamespace
= =
let interfaceType = AstHelper.parseInterface interfaceType let interfaceType = AstHelper.parseInterface interfaceType
let fields = interfaceType.Members |> List.map constructMember
let fields =
interfaceType.Members
|> List.map constructMember
|> List.append (interfaceType.Properties |> List.map constructProperty)
let docString = PreXmlDoc.create "Mock record type for an interface" let docString = PreXmlDoc.create "Mock record type for an interface"
let name = let name =
@@ -314,14 +291,14 @@ type InterfaceMockGenerator () =
let ast, _ = let ast, _ =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let types = Ast.getTypes ast let types = Ast.extractTypeDefn ast
let namespaceAndInterfaces = let namespaceAndInterfaces =
types types
|> List.choose (fun (ns, types) -> |> List.choose (fun (ns, types) ->
types types
|> List.choose (fun typeDef -> |> List.choose (fun typeDef ->
match SynTypeDefn.getAttribute typeof<GenerateMockAttribute>.Name typeDef with match Ast.getAttribute<GenerateMockAttribute> typeDef with
| None -> | None ->
let name = SynTypeDefn.getName typeDef |> List.map _.idText |> String.concat "." let name = SynTypeDefn.getName typeDef |> List.map _.idText |> String.concat "."

View File

@@ -26,7 +26,7 @@ module internal JsonParseGenerator =
} }
/// (match {indexed} with | null -> raise (System.Collections.Generic.KeyNotFoundException ({propertyName} not found)) | v -> v) /// (match {indexed} with | null -> raise (System.Collections.Generic.KeyNotFoundException ({propertyName} not found)) | v -> v)
let assertPropertyExists (propertyName : SynExpr) (indexed : SynExpr) = let assertNotNull (propertyName : SynExpr) (indexed : SynExpr) =
let raiseExpr = let raiseExpr =
SynExpr.applyFunction SynExpr.applyFunction
(SynExpr.createIdent "sprintf") (SynExpr.createIdent "sprintf")
@@ -40,34 +40,34 @@ module internal JsonParseGenerator =
|> SynExpr.applyFunction (SynExpr.createIdent "raise") |> SynExpr.applyFunction (SynExpr.createIdent "raise")
[ [
SynMatchClause.create (SynPat.named "None") raiseExpr SynMatchClause.create SynPat.createNull raiseExpr
SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "v" ]) (SynExpr.createIdent "v") SynMatchClause.create (SynPat.named "v") (SynExpr.createIdent "v")
] ]
|> SynExpr.createMatch indexed |> SynExpr.createMatch indexed
|> SynExpr.paren |> SynExpr.paren
/// {node}.AsValue().GetValue<{typeName}> () /// {node}.AsValue().GetValue<{typeName}> ()
/// If `propertyName` is Some, uses `assertPropertyExists {node}` instead of `{node}`. /// If `propertyName` is Some, uses `assertNotNull {node}` instead of `{node}`.
let asValueGetValue (propertyName : SynExpr option) (typeName : string) (node : SynExpr) : SynExpr = let asValueGetValue (propertyName : SynExpr option) (typeName : string) (node : SynExpr) : SynExpr =
match propertyName with match propertyName with
| None -> node | None -> node
| Some propertyName -> assertPropertyExists propertyName node | Some propertyName -> assertNotNull propertyName node
|> SynExpr.callMethod "AsValue" |> SynExpr.callMethod "AsValue"
|> SynExpr.callGenericMethod' "GetValue" typeName |> SynExpr.callGenericMethod' "GetValue" typeName
let asValueGetValueIdent (propertyName : SynExpr option) (typeName : LongIdent) (node : SynExpr) : SynExpr = let asValueGetValueIdent (propertyName : SynExpr option) (typeName : LongIdent) (node : SynExpr) : SynExpr =
match propertyName with match propertyName with
| None -> node | None -> node
| Some propertyName -> assertPropertyExists propertyName node | Some propertyName -> assertNotNull propertyName node
|> SynExpr.callMethod "AsValue" |> SynExpr.callMethod "AsValue"
|> SynExpr.callGenericMethod (SynLongIdent.createS "GetValue") [ SynType.createLongIdent typeName ] |> SynExpr.callGenericMethod (SynLongIdent.createS "GetValue") [ SynType.createLongIdent typeName ]
/// {node}.AsObject() /// {node}.AsObject()
/// If `propertyName` is Some, uses `assertPropertyExists {node}` instead of `{node}`. /// If `propertyName` is Some, uses `assertNotNull {node}` instead of `{node}`.
let asObject (propertyName : SynExpr option) (node : SynExpr) : SynExpr = let asObject (propertyName : SynExpr option) (node : SynExpr) : SynExpr =
match propertyName with match propertyName with
| None -> node | None -> node
| Some propertyName -> assertPropertyExists propertyName node | Some propertyName -> assertNotNull propertyName node
|> SynExpr.callMethod "AsObject" |> SynExpr.callMethod "AsObject"
/// {type}.jsonParse {node} /// {type}.jsonParse {node}
@@ -77,12 +77,11 @@ module internal JsonParseGenerator =
/// collectionType is e.g. "List"; we'll be calling `ofSeq` on it. /// collectionType is e.g. "List"; we'll be calling `ofSeq` on it.
/// body is the body of a lambda which takes a parameter `elt`. /// body is the body of a lambda which takes a parameter `elt`.
/// {assertPropertyExists node}.AsArray() /// {assertNotNull node}.AsArray()
/// |> Seq.map (fun elt -> {assertNotNull} {body}) /// |> Seq.map (fun elt -> {body})
/// |> {collectionType}.ofSeq /// |> {collectionType}.ofSeq
let asArrayMapped let asArrayMapped
(propertyName : SynExpr option) (propertyName : SynExpr option)
(elementType : SynType)
(collectionType : string) (collectionType : string)
(node : SynExpr) (node : SynExpr)
(body : SynExpr) (body : SynExpr)
@@ -90,23 +89,10 @@ module internal JsonParseGenerator =
= =
match propertyName with match propertyName with
| None -> node | None -> node
| Some propertyName -> assertPropertyExists propertyName node | Some propertyName -> assertNotNull propertyName node
|> SynExpr.callMethod "AsArray" |> SynExpr.callMethod "AsArray"
|> SynExpr.pipeThroughFunction ( |> SynExpr.pipeThroughFunction (
body SynExpr.applyFunction (SynExpr.createLongIdent [ "Seq" ; "map" ]) (SynExpr.createLambda "elt" body)
|> JsonSerializeGenerator.assertNotNull
(Ident.create "elt")
(match propertyName with
| None ->
SynExpr.CreateConst
$"Expected element of array (element type %s{SynType.toHumanReadableString elementType}) to be non-null, but found a null element"
| Some propertyName ->
SynExpr.CreateConst
$"Expected element of array (element type %s{SynType.toHumanReadableString elementType}) to be non-null, but found a null element, at %%s"
|> SynExpr.applyFunction (SynExpr.createIdent "sprintf")
|> SynExpr.applyTo propertyName)
|> SynExpr.createLambda "elt"
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "Seq" ; "map" ])
) )
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ collectionType ; "ofSeq" ]) |> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ collectionType ; "ofSeq" ])
@@ -115,41 +101,14 @@ module internal JsonParseGenerator =
/// fun kvp -> let key = {key(kvp)} in let value = {value(kvp)} in (key, value)) /// fun kvp -> let key = {key(kvp)} in let value = {value(kvp)} in (key, value))
/// The inputs will be fed with appropriate SynExprs to apply them to the `kvp.Key` and `kvp.Value` args. /// The inputs will be fed with appropriate SynExprs to apply them to the `kvp.Key` and `kvp.Value` args.
let dictionaryMapper let dictionaryMapper (key : SynExpr -> SynExpr) (value : SynExpr -> SynExpr) : SynExpr =
(propertyName : SynExpr option)
(valueTypeIsNullable : bool)
(key : SynExpr -> SynExpr)
(valueType : SynType)
(value : SynExpr -> SynExpr)
: SynExpr
=
let keyArg = SynExpr.createLongIdent [ "kvp" ; "Key" ] |> SynExpr.paren let keyArg = SynExpr.createLongIdent [ "kvp" ; "Key" ] |> SynExpr.paren
let valueArg = SynExpr.createLongIdent [ "kvp" ; "Value" ] let valueArg = SynExpr.createLongIdent [ "kvp" ; "Value" ] |> SynExpr.paren
let value =
if valueTypeIsNullable then
(value (SynExpr.createIdent "value"))
else
let errorMessage =
match propertyName with
| None ->
SynExpr.CreateConst
$"Expected dictionary value of type %s{SynType.toHumanReadableString valueType} to be non-null, but it was null"
| Some propertyName ->
SynExpr.CreateConst
$"Expected dictionary value of type %s{SynType.toHumanReadableString valueType} to be non-null, but it was null, at key %%s"
|> SynExpr.applyFunction (SynExpr.createIdent "sprintf")
|> SynExpr.applyTo propertyName
JsonSerializeGenerator.assertNotNull
(Ident.create "value")
errorMessage
(value (SynExpr.createIdent "value"))
// No need to paren here, we're on the LHS of a `let` // No need to paren here, we're on the LHS of a `let`
SynExpr.tupleNoParen [ SynExpr.createIdent "key" ; value ] SynExpr.tupleNoParen [ SynExpr.createIdent "key" ; SynExpr.createIdent "value" ]
|> SynExpr.createLet [ SynBinding.basic [ Ident.create "value" ] [] valueArg ] |> SynExpr.createLet [ SynBinding.basic [ Ident.create "value" ] [] (value valueArg) ]
|> SynExpr.createLet [ SynBinding.basic [ Ident.create "key" ] [] (key keyArg) ] |> SynExpr.createLet [ SynBinding.basic [ Ident.create "key" ] [] (key keyArg) ]
|> SynExpr.createLambda "kvp" |> SynExpr.createLambda "kvp"
@@ -206,61 +165,10 @@ module internal JsonParseGenerator =
)) ))
handler handler
let rec parseNullableNode
// TODO: unused?!
(propertyName : SynExpr option)
(options : JsonParseOption)
(fieldType : SynType)
(node : SynExpr)
: SynExpr
=
match fieldType with
| OptionType ty ->
match ty with
| OptionType _
| NullableType _ ->
failwith
$"Nested nullable types are not supported, because we can't distinguish between None and Some None. %s{SynType.toHumanReadableString ty}"
| _ ->
let someClause =
parseNonNullableNode None options ty (SynExpr.createIdent "v")
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "Some")
|> SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "v" ])
[
SynMatchClause.create (SynPat.named "None") (SynExpr.createIdent "None")
someClause
]
|> SynExpr.createMatch node
| NullableType ty ->
match ty with
| OptionType _
| NullableType _ ->
failwith
$"Nested nullable types are not supported, because we can't distinguish between None and Some None. %s{SynType.toHumanReadableString ty}"
| _ ->
let someClause =
parseNonNullableNode None options ty (SynExpr.createIdent "v")
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Nullable" ])
|> SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "v" ])
[
SynMatchClause.create
(SynPat.named "None")
(SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "Nullable" ]) (SynExpr.CreateConst ()))
someClause
]
|> SynExpr.createMatch node
| _ ->
failwith
$"Encountered type %s{SynType.toHumanReadableString fieldType} which is expected to be nullable, but couldn't identify it"
/// Given `node.["town"]`, for example, choose how to obtain a JSON value from it. /// Given `node.["town"]`, for example, choose how to obtain a JSON value from it.
/// The property name is used in error messages at runtime to show where a JSON /// The property name is used in error messages at runtime to show where a JSON
/// parse error occurred; supply `None` to indicate "don't validate". /// parse error occurred; supply `None` to indicate "don't validate".
and parseNonNullableNode let rec parseNode
(propertyName : SynExpr option) (propertyName : SynExpr option)
(options : JsonParseOption) (options : JsonParseOption)
(fieldType : SynType) (fieldType : SynType)
@@ -269,184 +177,101 @@ module internal JsonParseGenerator =
= =
// TODO: parsing format for DateTime etc // TODO: parsing format for DateTime etc
match fieldType with match fieldType with
| OptionType _
| NullableType _ ->
failwith
$"Unexpectedly parsing nullable type %s{SynType.toHumanReadableString fieldType} as if it were non-nullable."
// Struct types
| DateOnly -> | DateOnly ->
node node
|> asValueGetValue propertyName "string" |> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateOnly" ; "Parse" ]) |> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateOnly" ; "Parse" ])
| DateTime ->
node
|> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateTime" ; "Parse" ])
| NumberType typeName -> parseNumberType options propertyName node typeName
| Guid ->
node
|> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Guid" ; "Parse" ])
// Reference types
| Uri -> | Uri ->
node node
|> asValueGetValue propertyName "string" |> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Uri" ]) |> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Uri" ])
| Guid ->
node
|> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Guid" ; "Parse" ])
| DateTime ->
node
|> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateTime" ; "Parse" ])
| DateTimeOffset -> | DateTimeOffset ->
node node
|> asValueGetValue propertyName "string" |> asValueGetValue propertyName "string"
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateTimeOffset" ; "Parse" ]) |> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "DateTimeOffset" ; "Parse" ])
| NumberType typeName -> parseNumberType options propertyName node typeName
| PrimitiveType typeName -> asValueGetValueIdent propertyName typeName node | PrimitiveType typeName -> asValueGetValueIdent propertyName typeName node
| OptionType ty ->
let someClause =
parseNode None options ty (SynExpr.createIdent "v")
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "Some")
|> SynMatchClause.create (SynPat.named "v")
[
SynMatchClause.create SynPat.createNull (SynExpr.createIdent "None")
someClause
]
|> SynExpr.createMatch node
| NullableType ty ->
let someClause =
parseNode None options ty (SynExpr.createIdent "v")
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "System" ; "Nullable" ])
|> SynMatchClause.create (SynPat.named "v")
[
SynMatchClause.create
SynPat.createNull
(SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "Nullable" ]) (SynExpr.CreateConst ()))
someClause
]
|> SynExpr.createMatch node
| ListType ty -> | ListType ty ->
match JsonNodeWithNullability.Identify ty with parseNode None options ty (SynExpr.createIdent "elt")
| CannotBeNull -> |> asArrayMapped propertyName "List" node
parseNonNullableNode None options ty (SynExpr.createIdent "elt")
|> asArrayMapped propertyName ty "List" node
| Nullable ->
parseNullableNode None options ty (SynExpr.createIdent "elt")
|> asArrayMapped propertyName ty "List" node
| ArrayType ty -> | ArrayType ty ->
match JsonNodeWithNullability.Identify ty with parseNode None options ty (SynExpr.createIdent "elt")
| CannotBeNull -> |> asArrayMapped propertyName "Array" node
parseNonNullableNode None options ty (SynExpr.createIdent "elt")
|> asArrayMapped propertyName ty "Array" node
| Nullable ->
parseNullableNode None options ty (SynExpr.createIdent "elt")
|> asArrayMapped propertyName ty "Array" node
| IDictionaryType (keyType, valueType) -> | IDictionaryType (keyType, valueType) ->
match JsonNodeWithNullability.Identify valueType with node
| CannotBeNull -> |> asObject propertyName
node |> SynExpr.pipeThroughFunction (
|> asObject propertyName SynExpr.applyFunction
|> SynExpr.pipeThroughFunction ( (SynExpr.createLongIdent [ "Seq" ; "map" ])
SynExpr.applyFunction (dictionaryMapper (parseKeyString keyType) (parseNode None options valueType))
(SynExpr.createLongIdent [ "Seq" ; "map" ]) )
(dictionaryMapper |> SynExpr.pipeThroughFunction (SynExpr.createIdent "dict")
propertyName
false
(parseKeyString keyType)
valueType
(parseNonNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "dict")
| Nullable ->
node
|> asObject propertyName
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(dictionaryMapper
propertyName
true
(parseKeyString keyType)
valueType
(parseNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "dict")
| DictionaryType (keyType, valueType) -> | DictionaryType (keyType, valueType) ->
match JsonNodeWithNullability.Identify valueType with node
| CannotBeNull -> |> asObject propertyName
node |> SynExpr.pipeThroughFunction (
|> asObject propertyName SynExpr.applyFunction
|> SynExpr.pipeThroughFunction ( (SynExpr.createLongIdent [ "Seq" ; "map" ])
SynExpr.applyFunction (dictionaryMapper (parseKeyString keyType) (parseNode None options valueType))
(SynExpr.createLongIdent [ "Seq" ; "map" ]) )
(dictionaryMapper |> SynExpr.pipeThroughFunction (
propertyName SynExpr.applyFunction
false (SynExpr.createLongIdent [ "Seq" ; "map" ])
(parseKeyString keyType) (SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "KeyValuePair" ])
valueType )
(parseNonNullableNode None options valueType)) |> SynExpr.pipeThroughFunction (
) SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "Dictionary" ]
|> SynExpr.pipeThroughFunction ( )
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "KeyValuePair" ])
)
|> SynExpr.pipeThroughFunction (
SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "Dictionary" ]
)
| Nullable ->
node
|> asObject propertyName
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(dictionaryMapper
propertyName
true
(parseKeyString keyType)
valueType
(parseNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "KeyValuePair" ])
)
|> SynExpr.pipeThroughFunction (
SynExpr.createLongIdent [ "System" ; "Collections" ; "Generic" ; "Dictionary" ]
)
| IReadOnlyDictionaryType (keyType, valueType) -> | IReadOnlyDictionaryType (keyType, valueType) ->
match JsonNodeWithNullability.Identify valueType with node
| CannotBeNull -> |> asObject propertyName
node |> SynExpr.pipeThroughFunction (
|> asObject propertyName SynExpr.applyFunction
|> SynExpr.pipeThroughFunction ( (SynExpr.createLongIdent [ "Seq" ; "map" ])
SynExpr.applyFunction (dictionaryMapper (parseKeyString keyType) (parseNode None options valueType))
(SynExpr.createLongIdent [ "Seq" ; "map" ]) )
(dictionaryMapper |> SynExpr.pipeThroughFunction (SynExpr.createIdent "readOnlyDict")
propertyName
false
(parseKeyString keyType)
valueType
(parseNonNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "readOnlyDict")
| Nullable ->
node
|> asObject propertyName
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(dictionaryMapper
propertyName
true
(parseKeyString keyType)
valueType
(parseNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "readOnlyDict")
| MapType (keyType, valueType) -> | MapType (keyType, valueType) ->
match JsonNodeWithNullability.Identify valueType with node
| CannotBeNull -> |> asObject propertyName
node |> SynExpr.pipeThroughFunction (
|> asObject propertyName SynExpr.applyFunction
|> SynExpr.pipeThroughFunction ( (SynExpr.createLongIdent [ "Seq" ; "map" ])
SynExpr.applyFunction (dictionaryMapper (parseKeyString keyType) (parseNode None options valueType))
(SynExpr.createLongIdent [ "Seq" ; "map" ]) )
(dictionaryMapper |> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
propertyName
false
(parseKeyString keyType)
valueType
(parseNonNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
| Nullable ->
node
|> asObject propertyName
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Seq" ; "map" ])
(dictionaryMapper
propertyName
true
(parseKeyString keyType)
valueType
(parseNullableNode None options valueType))
)
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Map" ; "ofSeq" ])
| BigInt -> | BigInt ->
node node
|> SynExpr.callMethod "ToJsonString" |> SynExpr.callMethod "ToJsonString"
@@ -457,7 +282,7 @@ module internal JsonParseGenerator =
|> SynExpr.pipeThroughFunction (Measure.getLanguagePrimitivesMeasure primType) |> SynExpr.pipeThroughFunction (Measure.getLanguagePrimitivesMeasure primType)
| JsonNode -> node | JsonNode -> node
| UnitType -> SynExpr.CreateConst () | UnitType -> SynExpr.CreateConst ()
| fieldType -> | _ ->
// Let's just hope that we've also got our own type annotation! // Let's just hope that we've also got our own type annotation!
let typeName = let typeName =
match fieldType with match fieldType with
@@ -466,45 +291,14 @@ module internal JsonParseGenerator =
match propertyName with match propertyName with
| None -> node | None -> node
| Some propertyName -> assertPropertyExists propertyName node | Some propertyName -> assertNotNull propertyName node
|> typeJsonParse typeName |> typeJsonParse typeName
/// propertyName is probably a string literal, but it could be a [<Literal>] variable /// propertyName is probably a string literal, but it could be a [<Literal>] variable
/// The result of this function is the body of a let-binding (not including the LHS of that let-binding). /// The result of this function is the body of a let-binding (not including the LHS of that let-binding).
let createParseRhs (options : JsonParseOption) (propertyName : SynExpr) (fieldType : SynType) : SynExpr = let createParseRhs (options : JsonParseOption) (propertyName : SynExpr) (fieldType : SynType) : SynExpr =
match JsonNodeWithNullability.Identify fieldType with let objectToParse = SynExpr.createIdent "node" |> SynExpr.index propertyName
| Nullable -> parseNode (Some propertyName) options fieldType objectToParse
let objectToParse =
SynExpr.createIdent "node"
|> SynExpr.index propertyName
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "ofObj" ])
parseNullableNode (Some propertyName) options fieldType objectToParse
| CannotBeNull ->
[
SynMatchClause.create
(SynPat.named "None")
(SynExpr.applyFunction
(SynExpr.createIdent "raise")
(SynExpr.paren (
SynExpr.applyFunction
(SynExpr.createLongIdent
[ "System" ; "Collections" ; "Generic" ; "KeyNotFoundException" ])
(SynExpr.applyFunction
(SynExpr.createIdent "sprintf")
(SynExpr.CreateConst "Required key '%s' not found on JSON object")
|> SynExpr.applyTo (SynExpr.paren propertyName)
|> SynExpr.paren)
)))
SynMatchClause.create
(SynPat.nameWithArgs "Some" [ SynPat.named "node" ])
(parseNonNullableNode None options fieldType (SynExpr.createIdent "node"))
]
|> SynExpr.createMatch (
SynExpr.createIdent "node"
|> SynExpr.index propertyName
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "ofObj" ])
)
let isJsonNumberHandling (literal : LongIdent) : bool = let isJsonNumberHandling (literal : LongIdent) : bool =
match List.rev literal |> List.map (fun ident -> ident.idText) with match List.rev literal |> List.map (fun ident -> ident.idText) with
@@ -557,7 +351,10 @@ module internal JsonParseGenerator =
let getParseOptions (fieldAttrs : SynAttribute list) = let getParseOptions (fieldAttrs : SynAttribute list) =
(JsonParseOption.None, fieldAttrs) (JsonParseOption.None, fieldAttrs)
||> List.fold (fun options attr -> ||> List.fold (fun options attr ->
if (SynLongIdent.toString attr.TypeName).EndsWith ("JsonNumberHandling", StringComparison.Ordinal) then if
(SynLongIdent.toString attr.TypeName)
.EndsWith ("JsonNumberHandling", StringComparison.Ordinal)
then
let qualifiedEnumValue = let qualifiedEnumValue =
match SynExpr.stripOptionalParen attr.ArgExpr with match SynExpr.stripOptionalParen attr.ArgExpr with
| SynExpr.LongIdent (_, SynLongIdent (ident, _, _), _, _) when isJsonNumberHandling ident -> | SynExpr.LongIdent (_, SynLongIdent (ident, _, _), _, _) when isJsonNumberHandling ident ->
@@ -587,13 +384,15 @@ module internal JsonParseGenerator =
let propertyNameAttr = let propertyNameAttr =
fieldData.Attrs fieldData.Attrs
|> List.tryFind (fun attr -> |> List.tryFind (fun attr ->
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonPropertyName", StringComparison.Ordinal) (SynLongIdent.toString attr.TypeName)
.EndsWith ("JsonPropertyName", StringComparison.Ordinal)
) )
let extensionDataAttr = let extensionDataAttr =
fieldData.Attrs fieldData.Attrs
|> List.tryFind (fun attr -> |> List.tryFind (fun attr ->
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonExtensionData", StringComparison.Ordinal) (SynLongIdent.toString attr.TypeName)
.EndsWith ("JsonExtensionData", StringComparison.Ordinal)
) )
let propertyName = let propertyName =
@@ -686,7 +485,7 @@ module internal JsonParseGenerator =
let finalConstruction = let finalConstruction =
fields fields
|> List.mapi (fun i fieldData -> SynLongIdent.createI fieldData.Ident, SynExpr.createIdent $"arg_%i{i}") |> List.mapi (fun i fieldData -> SynLongIdent.createI fieldData.Ident, SynExpr.createIdent $"arg_%i{i}")
|> SynExpr.createRecord None |> AstHelper.instantiateRecord
(finalConstruction, assignments) (finalConstruction, assignments)
||> List.fold (fun final assignment -> SynExpr.createLet [ assignment ] final) ||> List.fold (fun final assignment -> SynExpr.createLet [ assignment ] final)
@@ -711,8 +510,7 @@ module internal JsonParseGenerator =
|> SynExpr.createLet |> SynExpr.createLet
[ [
SynExpr.index (SynExpr.CreateConst "data") (SynExpr.createIdent "node") SynExpr.index (SynExpr.CreateConst "data") (SynExpr.createIdent "node")
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "ofObj" ]) |> assertNotNull (SynExpr.CreateConst "data")
|> assertPropertyExists (SynExpr.CreateConst "data")
|> SynBinding.basic [ Ident.create "node" ] [] |> SynBinding.basic [ Ident.create "node" ] []
] ]
@@ -760,8 +558,7 @@ module internal JsonParseGenerator =
SynExpr.createIdent "node" SynExpr.createIdent "node"
|> SynExpr.index property |> SynExpr.index property
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "ofObj" ]) |> assertNotNull property
|> assertPropertyExists property
|> SynExpr.pipeThroughFunction ( |> SynExpr.pipeThroughFunction (
SynExpr.createLambda "v" (SynExpr.callGenericMethod' "GetValue" "string" (SynExpr.createIdent "v")) SynExpr.createLambda "v" (SynExpr.callGenericMethod' "GetValue" "string" (SynExpr.createIdent "v"))
) )
@@ -914,13 +711,13 @@ type JsonParseGenerator () =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let relevantTypes = let relevantTypes =
Ast.getTypes ast Ast.extractTypeDefn ast
|> List.map (fun (name, defns) -> |> List.map (fun (name, defns) ->
defns defns
|> List.choose (fun defn -> |> List.choose (fun defn ->
if SynTypeDefn.isRecord defn then Some defn if Ast.isRecord defn then Some defn
elif SynTypeDefn.isDu defn then Some defn elif Ast.isDu defn then Some defn
elif SynTypeDefn.isEnum defn then Some defn elif AstHelper.isEnum defn then Some defn
else None else None
) )
|> fun defns -> name, defns |> fun defns -> name, defns

View File

@@ -10,100 +10,24 @@ type internal JsonSerializeOutputSpec =
ExtensionMethods : bool ExtensionMethods : bool
} }
/// https://github.com/Smaug123/WoofWare.Myriad/issues/364
/// The insane design of System.Text.Json is finally causing us to
/// do vast amounts of coding rather than merely being very annoying.
type internal JsonNodeWithNullability =
| CannotBeNull
| Nullable
static member Identify (ty : SynType) : JsonNodeWithNullability =
match ty with
| OptionType _
| NullableType _ -> JsonNodeWithNullability.Nullable
| _ -> JsonNodeWithNullability.CannotBeNull
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module internal JsonSerializeGenerator = module internal JsonSerializeGenerator =
open Fantomas.FCS.Text.Range open Fantomas.FCS.Text.Range
// The absolutely galaxy-brained implementation of JsonValue has `JsonValue.Parse "null"` // The absolutely galaxy-brained implementation of JsonValue has `JsonValue.Parse "null"`
// identically equal to null, so it's hard to use that type. We use `None` instead to represent // identically equal to null. We have to work around this later, but we might as well just
// the JSON null value. // be efficient here and whip up the null directly.
let private jsonNull () = SynExpr.createIdent "None" let private jsonNull () =
SynExpr.createNull ()
let assertNotNull (boundIdent : Ident) (message : SynExpr) (body : SynExpr) : SynExpr = |> SynExpr.upcast' (SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ])
let raiseExpr =
message
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "System" ; "ArgumentNullException" ])
|> SynExpr.paren
|> SynExpr.applyFunction (SynExpr.createIdent "raise")
[
SynMatchClause.create SynPat.createNull raiseExpr
SynMatchClause.create (SynPat.namedI boundIdent) body
]
|> SynExpr.createMatch (SynExpr.createIdent' boundIdent)
|> SynExpr.paren
/// The output of this will be an *optional* JsonNode.
let rec serializeNodeNullable (fieldType : SynType) : SynExpr * bool =
match fieldType with
| NullableType ty ->
// fun field -> if field.HasValue then {serializeNode ty} field.Value else JsonValue.Create null
match JsonNodeWithNullability.Identify ty with
| JsonNodeWithNullability.Nullable ->
failwith
$"We don't support nested nullable types, because we can't tell the difference between None and Some None: %s{SynType.toHumanReadableString ty}"
| JsonNodeWithNullability.CannotBeNull ->
let inner, innerIsJsonNode = serializeNodeNonNullable ty
SynExpr.applyFunction inner (SynExpr.createLongIdent [ "field" ; "Value" ])
|> SynExpr.upcast' (SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ])
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "Some")
|> SynExpr.ifThenElse (SynExpr.createLongIdent [ "field" ; "HasValue" ]) (jsonNull ())
|> SynExpr.createLambda "field"
|> fun e -> e, innerIsJsonNode
| OptionType ty ->
// fun field -> match field with | None -> None | Some v -> {serializeNode ty} field |> Some
match JsonNodeWithNullability.Identify ty with
| JsonNodeWithNullability.Nullable ->
failwith
$"We don't support nested nullable types, because we can't tell the difference between None and Some None: %s{SynType.toHumanReadableString ty}"
| JsonNodeWithNullability.CannotBeNull ->
let noneClause = jsonNull () |> SynMatchClause.create (SynPat.named "None")
let someClause =
let inner, innerIsJsonNode = serializeNodeNonNullable ty
let target = SynExpr.pipeThroughFunction inner (SynExpr.createIdent "field")
if innerIsJsonNode then
target
else
target
|> SynExpr.paren
|> SynExpr.upcast' (SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ])
|> SynExpr.pipeThroughFunction (SynExpr.createIdent "Some")
|> SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "field" ])
[ noneClause ; someClause ]
|> SynExpr.createMatch (SynExpr.createIdent "field")
|> SynExpr.createLambda "field"
|> fun e -> e, true
| _ -> failwith $"Did not recognise type %s{SynType.toHumanReadableString fieldType} as nullable"
/// Given `input.Ident`, for example, choose how to add it to the ambient `node`. /// Given `input.Ident`, for example, choose how to add it to the ambient `node`.
/// The result is a line like `(fun ident -> InnerType.toJsonNode ident)` or `(fun ident -> JsonValue.Create ident)`. /// The result is a line like `(fun ident -> InnerType.toJsonNode ident)` or `(fun ident -> JsonValue.Create ident)`.
/// Returns also a bool which is true if the resulting SynExpr represents something of type JsonNode. /// Returns also a bool which is true if the resulting SynExpr represents something of type JsonNode.
and serializeNodeNonNullable (fieldType : SynType) : SynExpr * bool = let rec serializeNode (fieldType : SynType) : SynExpr * bool =
// TODO: serialization format for DateTime etc // TODO: serialization format for DateTime etc
match fieldType with match fieldType with
| OptionType _
| NullableType _ ->
failwith $"Tried to treat the type %s{SynType.toHumanReadableString fieldType} as non-nullable"
| DateOnly | DateOnly
| DateTime | DateTime
| NumberType _ | NumberType _
@@ -112,21 +36,8 @@ module internal JsonSerializeGenerator =
| Guid | Guid
| Uri -> | Uri ->
// JsonValue.Create<type> // JsonValue.Create<type>
(SynExpr.createIdent "field") SynExpr.createLongIdent [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonValue" ; "Create" ]
|> assertNotNull |> SynExpr.typeApp [ fieldType ]
(Ident.create "field")
(SynExpr.CreateConst
$"Expected type %s{SynType.toHumanReadableString fieldType} to be non-null, but received a null value when serialising")
|> SynExpr.createLet
[
SynBinding.basic
[ Ident.create "field" ]
[]
(SynExpr.createLongIdent [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonValue" ; "Create" ]
|> SynExpr.typeApp [ fieldType ]
|> SynExpr.applyTo (SynExpr.createIdent "field"))
]
|> SynExpr.createLambda "field"
|> fun e -> e, false |> fun e -> e, false
| DateTimeOffset -> | DateTimeOffset ->
// fun field -> field.ToString("o") |> JsonValue.Create<string> // fun field -> field.ToString("o") |> JsonValue.Create<string>
@@ -139,17 +50,41 @@ module internal JsonSerializeGenerator =
|> SynExpr.pipeThroughFunction create |> SynExpr.pipeThroughFunction create
|> SynExpr.createLambda "field" |> SynExpr.createLambda "field"
|> fun e -> e, false |> fun e -> e, false
| NullableType ty ->
// fun field -> if field.HasValue then {serializeNode ty} field.Value else JsonValue.Create null
let inner, innerIsJsonNode = serializeNode ty
SynExpr.applyFunction inner (SynExpr.createLongIdent [ "field" ; "Value" ])
|> SynExpr.upcast' (SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ])
|> SynExpr.ifThenElse (SynExpr.createLongIdent [ "field" ; "HasValue" ]) (jsonNull ())
|> SynExpr.createLambda "field"
|> fun e -> e, innerIsJsonNode
| OptionType ty ->
// fun field -> match field with | None -> JsonValue.Create null | Some v -> {serializeNode ty} field
let noneClause = jsonNull () |> SynMatchClause.create (SynPat.named "None")
let someClause =
let inner, innerIsJsonNode = serializeNode ty
let target = SynExpr.applyFunction inner (SynExpr.createIdent "field")
if innerIsJsonNode then
target
else
target
|> SynExpr.paren
|> SynExpr.upcast' (SynType.createLongIdent' [ "System" ; "Text" ; "Json" ; "Nodes" ; "JsonNode" ])
|> SynMatchClause.create (SynPat.nameWithArgs "Some" [ SynPat.named "field" ])
[ noneClause ; someClause ]
|> SynExpr.createMatch (SynExpr.createIdent "field")
|> SynExpr.createLambda "field"
|> fun e -> e, true
| ArrayType ty | ArrayType ty
| ListType ty -> | ListType ty ->
// fun field -> // fun field ->
// let arr = JsonArray () // let arr = JsonArray ()
// for mem in field do arr.Add ({serializeNode} mem) // for mem in field do arr.Add ({serializeNode} mem)
// arr // arr
let isNullableChild =
match JsonNodeWithNullability.Identify ty with
| CannotBeNull -> false
| Nullable -> true
[ [
SynExpr.ForEach ( SynExpr.ForEach (
DebugPointAtFor.Yes range0, DebugPointAtFor.Yes range0,
@@ -160,17 +95,7 @@ module internal JsonSerializeGenerator =
SynExpr.createIdent "field", SynExpr.createIdent "field",
SynExpr.applyFunction SynExpr.applyFunction
(SynExpr.createLongIdent [ "arr" ; "Add" ]) (SynExpr.createLongIdent [ "arr" ; "Add" ])
(SynExpr.paren ( (SynExpr.paren (SynExpr.applyFunction (fst (serializeNode ty)) (SynExpr.createIdent "mem"))),
SynExpr.applyFunction
(fst (
(if isNullableChild then
serializeNodeNullable
else
serializeNodeNonNullable)
ty
))
(SynExpr.createIdent "mem")
)),
range0 range0
) )
SynExpr.createIdent "arr" SynExpr.createIdent "arr"
@@ -184,28 +109,15 @@ module internal JsonSerializeGenerator =
] ]
|> SynExpr.createLambda "field" |> SynExpr.createLambda "field"
|> fun e -> e, false |> fun e -> e, false
| IDictionaryType (keyType, valueType) | IDictionaryType (_keyType, valueType)
| DictionaryType (keyType, valueType) | DictionaryType (_keyType, valueType)
| IReadOnlyDictionaryType (keyType, valueType) | IReadOnlyDictionaryType (_keyType, valueType)
| MapType (keyType, valueType) -> | MapType (_keyType, valueType) ->
// fun field -> // fun field ->
// let ret = JsonObject () // let ret = JsonObject ()
// for (KeyValue(key, value)) in field do // for (KeyValue(key, value)) in field do
// ret.Add (key.ToString (), {serializeNode} value) // ret.Add (key.ToString (), {serializeNode} value)
// ret // ret
let isNullableValueField =
match JsonNodeWithNullability.Identify valueType with
| CannotBeNull -> false
| Nullable -> true
// TODO: this is a bit dubious, because user-defined types will
// by default have non-null ToString
let keyTypeHasNonNullToString =
match keyType with
| String
| Uri -> true
| _ -> false
[ [
SynExpr.ForEach ( SynExpr.ForEach (
DebugPointAtFor.Yes range0, DebugPointAtFor.Yes range0,
@@ -218,33 +130,10 @@ module internal JsonSerializeGenerator =
(SynExpr.createLongIdent [ "ret" ; "Add" ]) (SynExpr.createLongIdent [ "ret" ; "Add" ])
(SynExpr.tuple (SynExpr.tuple
[ [
SynExpr.createIdent "key" SynExpr.createLongIdent [ "key" ; "ToString" ]
|> if keyTypeHasNonNullToString then |> SynExpr.applyTo (SynExpr.CreateConst ())
id SynExpr.applyFunction (fst (serializeNode valueType)) (SynExpr.createIdent "value")
else ]),
assertNotNull
(Ident.create "key")
(SynExpr.CreateConst
"A map key unexpectedly yielded null when we `ToString`'ed it. Map keys must yield non-null strings on `ToString`.")
SynExpr.applyFunction
(fst (
(if isNullableValueField then
serializeNodeNullable
else
serializeNodeNonNullable)
valueType
))
(SynExpr.createIdent "value")
])
|> SynExpr.createLet
[
SynBinding.basic
[ Ident.create "key" ]
[]
(SynExpr.createLongIdent [ "key" ; "ToString" ]
|> SynExpr.applyTo (SynExpr.CreateConst ()))
],
range0 range0
) )
SynExpr.createIdent "ret" SynExpr.createIdent "ret"
@@ -277,24 +166,13 @@ module internal JsonSerializeGenerator =
/// propertyName is probably a string literal, but it could be a [<Literal>] variable /// propertyName is probably a string literal, but it could be a [<Literal>] variable
/// `node.Add ({propertyName}, {toJsonNode})` /// `node.Add ({propertyName}, {toJsonNode})`
let createSerializeRhsRecord (propertyName : SynExpr) (fieldId : Ident) (fieldType : SynType) : SynExpr = let createSerializeRhsRecord (propertyName : SynExpr) (fieldId : Ident) (fieldType : SynType) : SynExpr =
let isNullableField = [
match JsonNodeWithNullability.Identify fieldType with propertyName
| CannotBeNull -> false SynExpr.pipeThroughFunction
| Nullable -> true (fst (serializeNode fieldType))
(SynExpr.createLongIdent' [ Ident.create "input" ; fieldId ])
let serialised = |> SynExpr.paren
if isNullableField then ]
let value =
serializeNodeNullable fieldType
|> fst
|> SynExpr.pipeThroughFunction (SynExpr.createLongIdent [ "Option" ; "toObj" ])
SynExpr.pipeThroughFunction value (SynExpr.createLongIdent' [ Ident.create "input" ; fieldId ])
else
let value = serializeNodeNonNullable fieldType |> fst
SynExpr.pipeThroughFunction value (SynExpr.createLongIdent' [ Ident.create "input" ; fieldId ])
[ propertyName ; SynExpr.paren serialised ]
|> SynExpr.tuple |> SynExpr.tuple
|> SynExpr.applyFunction (SynExpr.createLongIdent [ "node" ; "Add" ]) |> SynExpr.applyFunction (SynExpr.createLongIdent [ "node" ; "Add" ])
@@ -302,7 +180,8 @@ module internal JsonSerializeGenerator =
let propertyNameAttr = let propertyNameAttr =
attrs attrs
|> List.tryFind (fun attr -> |> List.tryFind (fun attr ->
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonPropertyName", StringComparison.Ordinal) (SynLongIdent.toString attr.TypeName)
.EndsWith ("JsonPropertyName", StringComparison.Ordinal)
) )
match propertyNameAttr with match propertyNameAttr with
@@ -319,7 +198,8 @@ module internal JsonSerializeGenerator =
let getIsJsonExtension (attrs : SynAttribute list) : bool = let getIsJsonExtension (attrs : SynAttribute list) : bool =
attrs attrs
|> List.tryFind (fun attr -> |> List.tryFind (fun attr ->
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonExtensionData", StringComparison.Ordinal) (SynLongIdent.toString attr.TypeName)
.EndsWith ("JsonExtensionData", StringComparison.Ordinal)
) )
|> Option.isSome |> Option.isSome
@@ -400,10 +280,7 @@ module internal JsonSerializeGenerator =
| DictionaryType (String, v) -> v | DictionaryType (String, v) -> v
| _ -> failwith "Expected JsonExtensionData to be a Dictionary<string, something>" | _ -> failwith "Expected JsonExtensionData to be a Dictionary<string, something>"
let serialise = let serialise = fst (serializeNode valType)
match JsonNodeWithNullability.Identify valType with
| CannotBeNull -> fst (serializeNodeNonNullable valType)
| Nullable -> fst (serializeNodeNullable valType)
SynExpr.createIdent "node" SynExpr.createIdent "node"
|> SynExpr.callMethodArg |> SynExpr.callMethodArg
@@ -468,15 +345,7 @@ module internal JsonSerializeGenerator =
let propertyName = getPropertyName (Option.get fieldData.Ident) fieldData.Attrs let propertyName = getPropertyName (Option.get fieldData.Ident) fieldData.Attrs
let node = let node =
match JsonNodeWithNullability.Identify fieldData.Type with SynExpr.applyFunction (fst (serializeNode fieldData.Type)) (SynExpr.createIdent caseName)
| CannotBeNull ->
SynExpr.applyFunction
(fst (serializeNodeNonNullable fieldData.Type))
(SynExpr.createIdent caseName)
| Nullable ->
SynExpr.applyFunction
(fst (serializeNodeNullable fieldData.Type))
(SynExpr.createIdent caseName)
[ propertyName ; node ] [ propertyName ; node ]
|> SynExpr.tuple |> SynExpr.tuple
@@ -659,13 +528,13 @@ type JsonSerializeGenerator () =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let relevantTypes = let relevantTypes =
Ast.getTypes ast Ast.extractTypeDefn ast
|> List.map (fun (name, defns) -> |> List.map (fun (name, defns) ->
defns defns
|> List.choose (fun defn -> |> List.choose (fun defn ->
if SynTypeDefn.isRecord defn then Some defn if Ast.isRecord defn then Some defn
elif SynTypeDefn.isDu defn then Some defn elif Ast.isDu defn then Some defn
elif SynTypeDefn.isEnum defn then Some defn elif AstHelper.isEnum defn then Some defn
else None else None
) )
|> fun defns -> name, defns |> fun defns -> name, defns

View File

@@ -2,6 +2,28 @@ namespace WoofWare.Myriad.Plugins
open System.Collections.Generic open System.Collections.Generic
type internal DesiredGenerator =
| InterfaceMock of isInternal : bool option
| JsonParse of extensionMethod : bool option
| JsonSerialize of extensionMethod : bool option
| HttpClient of extensionMethod : bool option
static member Parse (s : string) =
match s with
| "GenerateMock" -> DesiredGenerator.InterfaceMock None
| "GenerateMock(true)" -> DesiredGenerator.InterfaceMock (Some true)
| "GenerateMock(false)" -> DesiredGenerator.InterfaceMock (Some false)
| "JsonParse" -> DesiredGenerator.JsonParse None
| "JsonParse(true)" -> DesiredGenerator.JsonParse (Some true)
| "JsonParse(false)" -> DesiredGenerator.JsonParse (Some false)
| "JsonSerialize" -> DesiredGenerator.JsonSerialize None
| "JsonSerialize(true)" -> DesiredGenerator.JsonSerialize (Some true)
| "JsonSerialize(false)" -> DesiredGenerator.JsonSerialize (Some false)
| "HttpClient" -> DesiredGenerator.HttpClient None
| "HttpClient(true)" -> DesiredGenerator.HttpClient (Some true)
| "HttpClient(false)" -> DesiredGenerator.HttpClient (Some false)
| _ -> failwith $"Failed to parse as a generator specification: %s{s}"
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module internal MyriadParamParser = module internal MyriadParamParser =
(* (*

View File

@@ -1,23 +0,0 @@
namespace WoofWare.Myriad.Plugins
type internal DesiredGenerator =
| InterfaceMock of isInternal : bool option
| JsonParse of extensionMethod : bool option
| JsonSerialize of extensionMethod : bool option
| HttpClient of extensionMethod : bool option
static member Parse (s : string) =
match s with
| "GenerateMock" -> DesiredGenerator.InterfaceMock None
| "GenerateMock(true)" -> DesiredGenerator.InterfaceMock (Some true)
| "GenerateMock(false)" -> DesiredGenerator.InterfaceMock (Some false)
| "JsonParse" -> DesiredGenerator.JsonParse None
| "JsonParse(true)" -> DesiredGenerator.JsonParse (Some true)
| "JsonParse(false)" -> DesiredGenerator.JsonParse (Some false)
| "JsonSerialize" -> DesiredGenerator.JsonSerialize None
| "JsonSerialize(true)" -> DesiredGenerator.JsonSerialize (Some true)
| "JsonSerialize(false)" -> DesiredGenerator.JsonSerialize (Some false)
| "HttpClient" -> DesiredGenerator.HttpClient None
| "HttpClient(true)" -> DesiredGenerator.HttpClient (Some true)
| "HttpClient(false)" -> DesiredGenerator.HttpClient (Some false)
| _ -> failwith $"Failed to parse as a generator specification: %s{s}"

View File

@@ -1,6 +1,5 @@
namespace WoofWare.Myriad.Plugins namespace WoofWare.Myriad.Plugins
open System
open Fantomas.FCS.Syntax open Fantomas.FCS.Syntax
open Fantomas.FCS.Xml open Fantomas.FCS.Xml
open WoofWare.Whippet.Fantomas open WoofWare.Whippet.Fantomas
@@ -60,7 +59,7 @@ module internal RemoveOptionsGenerator =
Attributes = [] Attributes = []
} }
let typeDecl = RecordType.ToAst record let typeDecl = AstHelper.defineRecordType record
SynModuleDecl.Types ([ typeDecl ], range0) SynModuleDecl.Types ([ typeDecl ], range0)
@@ -97,7 +96,7 @@ module internal RemoveOptionsGenerator =
SynLongIdent.createI fieldData.Ident, body SynLongIdent.createI fieldData.Ident, body
) )
|> SynExpr.createRecord None |> AstHelper.instantiateRecord
SynBinding.basic SynBinding.basic
[ functionName ] [ functionName ]
@@ -147,31 +146,44 @@ type RemoveOptionsGenerator () =
let ast, _ = let ast, _ =
Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head Ast.fromFilename context.InputFilename |> Async.RunSynchronously |> Array.head
let records = Ast.getRecords ast let records = Ast.extractRecords ast
let namespaceAndRecords = let namespaceAndRecords =
records records
|> List.collect (fun (ns, ty) -> |> List.choose (fun (ns, types) ->
ty match
|> List.filter (fun record -> types
record.Attributes |> List.filter (SynTypeDefn.hasAttribute typeof<RemoveOptionsAttribute>.Name)
|> List.exists (fun attr -> with
attr.TypeName.LongIdent | [] -> None
|> List.last | types ->
|> _.idText let types =
|> fun s -> types
if s.EndsWith ("Attribute", StringComparison.Ordinal) then |> List.map (fun ty ->
s match ty with
else | SynTypeDefn.SynTypeDefn (sci,
$"%s{s}Attribute" SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Record (access,
|> (=) typeof<RemoveOptionsAttribute>.Name fields,
) _),
) _),
|> List.map (fun ty -> ns, ty) smd,
smdo,
_,
_) -> RecordType.OfRecord sci smd access fields
| _ -> failwith "unexpectedly not a record"
)
Some (ns, types)
) )
let modules = let modules =
namespaceAndRecords namespaceAndRecords
|> List.map (fun (ns, record) -> RemoveOptionsGenerator.createRecordModule ns record) |> List.collect (fun (ns, records) ->
records
|> List.map (fun record ->
let recordModule = RemoveOptionsGenerator.createRecordModule ns record
recordModule
)
)
Output.Ast modules Output.Ast modules

View File

@@ -15,14 +15,13 @@
<WarnOn>FS3559</WarnOn> <WarnOn>FS3559</WarnOn>
<PackageId>WoofWare.Myriad.Plugins</PackageId> <PackageId>WoofWare.Myriad.Plugins</PackageId>
<PackageIcon>logo.png</PackageIcon> <PackageIcon>logo.png</PackageIcon>
<NoWarn>NU5118</NoWarn>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Myriad.Core" Version="0.8.3" /> <PackageReference Include="Myriad.Core" Version="0.8.3" />
<PackageReference Include="TypeEquality" Version="0.3.0" /> <PackageReference Include="TypeEquality" Version="0.3.0" />
<PackageReference Include="WoofWare.Whippet.Fantomas" Version="0.6.2" /> <PackageReference Include="WoofWare.Whippet.Fantomas" Version="0.2.1" />
<!-- the lowest version allowed by Myriad.Core --> <!-- the lowest version allowed by Myriad.Core -->
<PackageReference Update="FSharp.Core" Version="6.0.1" PrivateAssets="all"/> <PackageReference Update="FSharp.Core" Version="6.0.1" PrivateAssets="all"/>
</ItemGroup> </ItemGroup>
@@ -32,7 +31,6 @@
<Compile Include="Text.fs" /> <Compile Include="Text.fs" />
<Compile Include="Measure.fs" /> <Compile Include="Measure.fs" />
<Compile Include="AstHelper.fs" /> <Compile Include="AstHelper.fs" />
<Compile Include="Parameters.fs" />
<Compile Include="RemoveOptionsGenerator.fs"/> <Compile Include="RemoveOptionsGenerator.fs"/>
<Compile Include="MyriadParamParser.fs" /> <Compile Include="MyriadParamParser.fs" />
<Compile Include="InterfaceMockGenerator.fs"/> <Compile Include="InterfaceMockGenerator.fs"/>
@@ -60,7 +58,7 @@
<ProjectReference Include="..\WoofWare.Myriad.Plugins.Attributes\WoofWare.Myriad.Plugins.Attributes.fsproj"/> <ProjectReference Include="..\WoofWare.Myriad.Plugins.Attributes\WoofWare.Myriad.Plugins.Attributes.fsproj"/>
<!-- NuGet is such a clown package manager! Get the DLLs into the Nupkg artefact, I have no idea why this is needed, <!-- NuGet is such a clown package manager! Get the DLLs into the Nupkg artefact, I have no idea why this is needed,
but without this line, we don't get any dependency at all packaged into the resulting artefact. --> but without this line, we don't get any dependency at all packaged into the resulting artefact. -->
<None Include="$(OutputPath)\*.dll" Pack="true" PackagePath="lib\$(TargetFramework)"/> <None Include="$(OutputPath)\WoofWare.Myriad.Plugins.Attributes.dll" Pack="true" PackagePath="lib\$(TargetFramework)"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,5 +1,5 @@
{ {
"version": "7.0", "version": "4.0",
"publicReleaseRefSpec": [ "publicReleaseRefSpec": [
"^refs/heads/main$" "^refs/heads/main$"
], ],
@@ -11,4 +11,4 @@
":/README.md", ":/README.md",
":/Directory.Build.props" ":/Directory.Build.props"
] ]
} }

View File

@@ -10,7 +10,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageDownload Include="G-Research.FSharp.Analyzers" Version="[0.14.0]" /> <PackageDownload Include="G-Research.FSharp.Analyzers" Version="[0.11.0]" />
</ItemGroup> </ItemGroup>
</Project> </Project>

12
flake.lock generated
View File

@@ -5,11 +5,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1731533236, "lastModified": 1726560853,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1744868846, "lastModified": 1728093190,
"narHash": "sha256-5RJTdUHDmj12Qsv7XOhuospjAjATNiTMElplWnJE9Hs=", "narHash": "sha256-CAZF2NRuHmqTtRTNAruWpHA43Gg2UvuCNEIzabP0l6M=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "ebe4301cbd8f81c4f8d3244b3632338bbeb6d49c", "rev": "e2f08f4d8b3ecb5cf5c9fd9cb2d53bb3c71807da",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -14,8 +14,8 @@
flake-utils.lib.eachDefaultSystem (system: let flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
pname = "WoofWare.Myriad.Plugins"; pname = "WoofWare.Myriad.Plugins";
dotnet-sdk = pkgs.dotnetCorePackages.sdk_9_0; dotnet-sdk = pkgs.dotnet-sdk_8;
dotnet-runtime = pkgs.dotnetCorePackages.runtime_9_0; dotnet-runtime = pkgs.dotnetCorePackages.runtime_8_0;
version = "0.1"; version = "0.1";
dotnetTool = dllOverride: toolName: toolVersion: hash: dotnetTool = dllOverride: toolName: toolVersion: hash:
pkgs.stdenvNoCC.mkDerivation rec { pkgs.stdenvNoCC.mkDerivation rec {
@@ -26,29 +26,25 @@
pname = name; pname = name;
version = version; version = version;
hash = hash; hash = hash;
installPhase = ''mkdir -p $out/bin && cp -r tools/net*/any/* $out/bin''; installPhase = ''mkdir -p $out/bin && cp -r tools/net6.0/any/* $out/bin'';
}; };
installPhase = let installPhase = let
dll = dll =
if isNull dllOverride if isNull dllOverride
then name then name
else dllOverride; else dllOverride;
in in ''
# fsharp-analyzers requires the .NET SDK at runtime, so we use that instead of dotnet-runtime. runHook preInstall
'' mkdir -p "$out/lib"
runHook preInstall cp -r ./bin/* "$out/lib"
mkdir -p "$out/lib" makeWrapper "${dotnet-runtime}/bin/dotnet" "$out/bin/${name}" --add-flags "$out/lib/${dll}.dll"
cp -r ./bin/* "$out/lib" runHook postInstall
makeWrapper "${dotnet-sdk}/bin/dotnet" "$out/bin/${name}" --set DOTNET_HOST_PATH "${dotnet-sdk}/bin/dotnet" --add-flags "$out/lib/${dll}.dll" '';
runHook postInstall
'';
}; };
in { in {
packages = let packages = {
deps = builtins.fromJSON (builtins.readFile ./nix/deps.json); fantomas = dotnetTool null "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version (builtins.head (builtins.filter (elem: elem.pname == "fantomas") ((import ./nix/deps.nix) {fetchNuGet = x: x;}))).hash;
in { fsharp-analyzers = dotnetTool "FSharp.Analyzers.Cli" "fsharp-analyzers" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fsharp-analyzers.version (builtins.head (builtins.filter (elem: elem.pname == "fsharp-analyzers") ((import ./nix/deps.nix) {fetchNuGet = x: x;}))).hash;
fantomas = dotnetTool null "fantomas" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fantomas.version (builtins.head (builtins.filter (elem: elem.pname == "fantomas") deps)).hash;
fsharp-analyzers = dotnetTool "FSharp.Analyzers.Cli" "fsharp-analyzers" (builtins.fromJSON (builtins.readFile ./.config/dotnet-tools.json)).tools.fsharp-analyzers.version (builtins.head (builtins.filter (elem: elem.pname == "fsharp-analyzers") deps)).hash;
default = pkgs.buildDotnetModule { default = pkgs.buildDotnetModule {
inherit pname version dotnet-sdk dotnet-runtime; inherit pname version dotnet-sdk dotnet-runtime;
name = "WoofWare.Myriad.Plugins"; name = "WoofWare.Myriad.Plugins";
@@ -56,7 +52,7 @@
projectFile = "./WoofWare.Myriad.Plugins/WoofWare.Myriad.Plugins.fsproj"; projectFile = "./WoofWare.Myriad.Plugins/WoofWare.Myriad.Plugins.fsproj";
testProjectFile = "./WoofWare.Myriad.Plugins.Test/WoofWare.Myriad.Plugins.Test.fsproj"; testProjectFile = "./WoofWare.Myriad.Plugins.Test/WoofWare.Myriad.Plugins.Test.fsproj";
disabledTests = ["WoofWare.Myriad.Plugins.Test.TestSurface.CheckVersionAgainstRemote"]; disabledTests = ["WoofWare.Myriad.Plugins.Test.TestSurface.CheckVersionAgainstRemote"];
nugetDeps = ./nix/deps.json; # `nix build .#default.fetch-deps && ./result nix/deps.json` nugetDeps = ./nix/deps.nix; # `nix build .#default.passthru.fetch-deps && ./result nix/deps.nix`
doCheck = true; doCheck = true;
}; };
}; };

View File

@@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "9.0.100", "version": "8.0.100",
"rollForward": "latestMajor" "rollForward": "latestMajor"
} }
} }

View File

@@ -1,387 +0,0 @@
[
{
"pname": "ApiSurface",
"version": "4.1.20",
"hash": "sha256-koWgO9FC9ax+Ij56ug8kxeyknl0yhLqnNLOUdxtqqo4="
},
{
"pname": "fantomas",
"version": "7.0.1",
"hash": "sha256-2aGD6Kjh83gmssRqqZ/Uihi7VbNqNUelX4otIfCuhTI="
},
{
"pname": "Fantomas.Core",
"version": "6.1.1",
"hash": "sha256-FcTLHQFvKkQY/kV08jhhy/St/+FmXpp3epp/R3zUXMA="
},
{
"pname": "Fantomas.FCS",
"version": "6.1.1",
"hash": "sha256-NuZ8msPEHYA8T3EYREB28F1RcNgUU8V54eg2+UttYxw="
},
{
"pname": "FsCheck",
"version": "3.2.0",
"hash": "sha256-ksZ4vLgWwyQOzFuK2BczdtDtWWYmedG7UBAg4pYuI8g="
},
{
"pname": "fsharp-analyzers",
"version": "0.30.0",
"hash": "sha256-7oaSwpHAU1opzpz4szLU/gDaJC/ww9eiFkPu0nr4Mj4="
},
{
"pname": "FSharp.Core",
"version": "4.3.4",
"hash": "sha256-styyo+6mJy+yxE0NZG/b1hxkAjPOnJfMgd9zWzCJ5uk="
},
{
"pname": "FSharp.Core",
"version": "6.0.1",
"hash": "sha256-Ehsgt3nCJijpaVuJguC1TPVEKSkJd6PSc07D2ZQSemI="
},
{
"pname": "FSharp.Core",
"version": "9.0.202",
"hash": "sha256-64Gub0qemmCoMa1tDus6TeTuB1+5sHfE6KD2j4o84mA="
},
{
"pname": "FsUnit",
"version": "7.0.1",
"hash": "sha256-K85CIdxMeFSHEKZk6heIXp/oFjWAn7dBILKrw49pJUY="
},
{
"pname": "Microsoft.ApplicationInsights",
"version": "2.22.0",
"hash": "sha256-mUQ63atpT00r49ca50uZu2YCiLg3yd6r3HzTryqcuEA="
},
{
"pname": "Microsoft.AspNetCore.App.Ref",
"version": "6.0.36",
"hash": "sha256-9jDkWbjw/nd8yqdzVTagCuqr6owJ/DUMi4BlUZT4hWU="
},
{
"pname": "Microsoft.AspNetCore.App.Runtime.linux-arm64",
"version": "6.0.36",
"hash": "sha256-JQULJyF0ivLoUU1JaFfK/HHg+/qzpN7V2RR2Cc+WlQ4="
},
{
"pname": "Microsoft.AspNetCore.App.Runtime.linux-x64",
"version": "6.0.36",
"hash": "sha256-zUsVIpV481vMLAXaLEEUpEMA9/f1HGOnvaQnaWdzlyY="
},
{
"pname": "Microsoft.AspNetCore.App.Runtime.osx-arm64",
"version": "6.0.36",
"hash": "sha256-2seqZcz0JeUjkzh3QcGa9TcJ4LUafpFjTRk+Nm8T6T0="
},
{
"pname": "Microsoft.AspNetCore.App.Runtime.osx-x64",
"version": "6.0.36",
"hash": "sha256-yxLafxiBKkvfkDggPk0P9YZIHBkDJOsFTO7/V9mEHuU="
},
{
"pname": "Microsoft.CodeCoverage",
"version": "17.13.0",
"hash": "sha256-GKrIxeyQo5Az1mztfQgea1kGtJwonnNOrXK/0ULfu8o="
},
{
"pname": "Microsoft.NET.Test.Sdk",
"version": "17.13.0",
"hash": "sha256-sc2wvyV8cGm1FrNP2GGHEI584RCvRPu15erYCsgw5QY="
},
{
"pname": "Microsoft.NETCore.App.Host.linux-arm64",
"version": "6.0.36",
"hash": "sha256-9lC/LYnthYhjkWWz2kkFCvlA5LJOv11jdt59SDnpdy0="
},
{
"pname": "Microsoft.NETCore.App.Host.linux-x64",
"version": "6.0.36",
"hash": "sha256-VFRDzx7LJuvI5yzKdGmw/31NYVbwHWPKQvueQt5xc10="
},
{
"pname": "Microsoft.NETCore.App.Host.osx-arm64",
"version": "6.0.36",
"hash": "sha256-DaSWwYACJGolEBuMhzDVCj/rQTdDt061xCVi+gyQnuo="
},
{
"pname": "Microsoft.NETCore.App.Host.osx-x64",
"version": "6.0.36",
"hash": "sha256-FrRny9EI6HKCKQbu6mcLj5w4ooSRrODD4Vj2ZMGnMd4="
},
{
"pname": "Microsoft.NETCore.App.Ref",
"version": "6.0.36",
"hash": "sha256-9LZgVoIFF8qNyUu8kdJrYGLutMF/cL2K82HN2ywwlx8="
},
{
"pname": "Microsoft.NETCore.App.Runtime.linux-arm64",
"version": "6.0.36",
"hash": "sha256-k3rxvUhCEU0pVH8KgEMtkPiSOibn+nBh+0zT2xIfId8="
},
{
"pname": "Microsoft.NETCore.App.Runtime.linux-x64",
"version": "6.0.36",
"hash": "sha256-U8wJ2snSDFqeAgDVLXjnniidC7Cr5aJ1/h/BMSlyu0c="
},
{
"pname": "Microsoft.NETCore.App.Runtime.osx-arm64",
"version": "6.0.36",
"hash": "sha256-UfLcrL2Gj/OLz0s92Oo+OCJeDpZFAcQLPLiSNND8D5Y="
},
{
"pname": "Microsoft.NETCore.App.Runtime.osx-x64",
"version": "6.0.36",
"hash": "sha256-0xIJYFzxdMcnCj3wzkFRQZSnQcPHzPHMzePRIOA3oJs="
},
{
"pname": "Microsoft.NETCore.Platforms",
"version": "1.1.0",
"hash": "sha256-FeM40ktcObQJk4nMYShB61H/E8B7tIKfl9ObJ0IOcCM="
},
{
"pname": "Microsoft.NETCore.Platforms",
"version": "1.1.1",
"hash": "sha256-8hLiUKvy/YirCWlFwzdejD2Db3DaXhHxT7GSZx/znJg="
},
{
"pname": "Microsoft.NETCore.Platforms",
"version": "2.0.0",
"hash": "sha256-IEvBk6wUXSdyCnkj6tHahOJv290tVVT8tyemYcR0Yro="
},
{
"pname": "Microsoft.NETCore.Targets",
"version": "1.1.0",
"hash": "sha256-0AqQ2gMS8iNlYkrD+BxtIg7cXMnr9xZHtKAuN4bjfaQ="
},
{
"pname": "Microsoft.NETCore.Targets",
"version": "1.1.3",
"hash": "sha256-WLsf1NuUfRWyr7C7Rl9jiua9jximnVvzy6nk2D2bVRc="
},
{
"pname": "Microsoft.Testing.Extensions.Telemetry",
"version": "1.5.3",
"hash": "sha256-bIXwPSa3jkr2b6xINOqMUs6/uj/r4oVFM7xq3uVIZDU="
},
{
"pname": "Microsoft.Testing.Extensions.TrxReport.Abstractions",
"version": "1.5.3",
"hash": "sha256-IfMRfcyaIKEMRtx326ICKtinDBEfGw/Sv8ZHawJ96Yc="
},
{
"pname": "Microsoft.Testing.Extensions.VSTestBridge",
"version": "1.5.3",
"hash": "sha256-XpM/yFjhLSsuzyDV+xKubs4V1zVVYiV05E0+N4S1h0g="
},
{
"pname": "Microsoft.Testing.Platform",
"version": "1.5.3",
"hash": "sha256-y61Iih6w5D79dmrj2V675mcaeIiHoj1HSa1FRit2BLM="
},
{
"pname": "Microsoft.Testing.Platform.MSBuild",
"version": "1.5.3",
"hash": "sha256-YspvjE5Jfi587TAfsvfDVJXNrFOkx1B3y1CKV6m7YLY="
},
{
"pname": "Microsoft.TestPlatform.ObjectModel",
"version": "17.12.0",
"hash": "sha256-3XBHBSuCxggAIlHXmKNQNlPqMqwFlM952Av6RrLw1/w="
},
{
"pname": "Microsoft.TestPlatform.ObjectModel",
"version": "17.13.0",
"hash": "sha256-6S0fjfj8vA+h6dJVNwLi6oZhYDO/I/6hBZaq2VTW+Uk="
},
{
"pname": "Microsoft.TestPlatform.TestHost",
"version": "17.13.0",
"hash": "sha256-L/CJzou7dhmShUgXq3aXL3CaLTJll17Q+JY2DBdUUpo="
},
{
"pname": "Myriad.Core",
"version": "0.8.3",
"hash": "sha256-vBOxfq8QriX/yUtaXN69rEQaY/psRNJWxqATLidrt2g="
},
{
"pname": "Myriad.Sdk",
"version": "0.8.3",
"hash": "sha256-7O397WKhskKOvE3MkJT37BvxorDWngDR6gTUogtDZ2M="
},
{
"pname": "Nerdbank.GitVersioning",
"version": "3.8.38-alpha",
"hash": "sha256-gPMrVbjOZxXoofczF/pn6eVkLhjVSJIyQrLO2oljrDc="
},
{
"pname": "NETStandard.Library",
"version": "2.0.3",
"hash": "sha256-Prh2RPebz/s8AzHb2sPHg3Jl8s31inv9k+Qxd293ybo="
},
{
"pname": "Newtonsoft.Json",
"version": "13.0.1",
"hash": "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo="
},
{
"pname": "Newtonsoft.Json",
"version": "13.0.3",
"hash": "sha256-hy/BieY4qxBWVVsDqqOPaLy1QobiIapkbrESm6v2PHc="
},
{
"pname": "NuGet.Common",
"version": "6.13.2",
"hash": "sha256-ASLa/Jigg5Eop0ZrXPl98RW2rxnJRC7pbbxhuV74hFw="
},
{
"pname": "NuGet.Configuration",
"version": "6.13.2",
"hash": "sha256-z8VW1YdRDanyyRTDYRvRkSv/XPR3c/hMM1y8cNNjx0Y="
},
{
"pname": "NuGet.Frameworks",
"version": "6.13.2",
"hash": "sha256-caDyc+WgYOo43AUTjtbP0MyvYDb6JweEKDdIul61Cac="
},
{
"pname": "NuGet.Packaging",
"version": "6.13.2",
"hash": "sha256-lhO+SFwIYZ4aPHxIGm5ubkkE2a5Ve2xgtroRbNh7hpw="
},
{
"pname": "NuGet.Protocol",
"version": "6.13.2",
"hash": "sha256-5lnAHHZjy7A4vgv65AeBAs64mSNpuoUjxW3HnrMpuzY="
},
{
"pname": "NuGet.Versioning",
"version": "6.13.2",
"hash": "sha256-gmpyBpKnt+GHqgx/2uFKp+J2csbxEAy1E7WdVT117sw="
},
{
"pname": "NUnit",
"version": "4.3.2",
"hash": "sha256-0RWe8uFoxYp6qhPlDDEghOMcKJgyw2ybvEoAqBLebeE="
},
{
"pname": "NUnit3TestAdapter",
"version": "5.0.0",
"hash": "sha256-7jZM4qAbIzne3AcdFfMbvbgogqpxvVe6q2S7Ls8xQy0="
},
{
"pname": "RestEase",
"version": "1.6.4",
"hash": "sha256-FFmqFwlHhIln46k56Z8KM1G+xuPEh/bceKCQnJcdcdc="
},
{
"pname": "runtime.any.System.Runtime",
"version": "4.3.0",
"hash": "sha256-qwhNXBaJ1DtDkuRacgHwnZmOZ1u9q7N8j0cWOLYOELM="
},
{
"pname": "runtime.native.System",
"version": "4.3.0",
"hash": "sha256-ZBZaodnjvLXATWpXXakFgcy6P+gjhshFXmglrL5xD5Y="
},
{
"pname": "runtime.unix.System.Private.Uri",
"version": "4.3.0",
"hash": "sha256-c5tXWhE/fYbJVl9rXs0uHh3pTsg44YD1dJvyOA0WoMs="
},
{
"pname": "System.Collections.Immutable",
"version": "8.0.0",
"hash": "sha256-F7OVjKNwpqbUh8lTidbqJWYi476nsq9n+6k0+QVRo3w="
},
{
"pname": "System.Diagnostics.DiagnosticSource",
"version": "5.0.0",
"hash": "sha256-6mW3N6FvcdNH/pB58pl+pFSCGWgyaP4hfVtC/SMWDV4="
},
{
"pname": "System.Diagnostics.DiagnosticSource",
"version": "7.0.0",
"hash": "sha256-9Wk8cHSkjKtqkN6xW7KnXoQVtF/VNbKeBq79WqDesMs="
},
{
"pname": "System.Formats.Asn1",
"version": "6.0.0",
"hash": "sha256-KaMHgIRBF7Nf3VwOo+gJS1DcD+41cJDPWFh+TDQ8ee8="
},
{
"pname": "System.Formats.Asn1",
"version": "8.0.1",
"hash": "sha256-may/Wg+esmm1N14kQTG4ESMBi+GQKPp0ZrrBo/o6OXM="
},
{
"pname": "System.IO.Abstractions",
"version": "4.2.13",
"hash": "sha256-nkC/PiqE6+c1HJ2yTwg3x+qdBh844Z8n3ERWDW8k6Gg="
},
{
"pname": "System.IO.FileSystem.AccessControl",
"version": "4.5.0",
"hash": "sha256-ck44YBQ0M+2Im5dw0VjBgFD1s0XuY54cujrodjjSBL8="
},
{
"pname": "System.Memory",
"version": "4.5.5",
"hash": "sha256-EPQ9o1Kin7KzGI5O3U3PUQAZTItSbk9h/i4rViN3WiI="
},
{
"pname": "System.Private.Uri",
"version": "4.3.0",
"hash": "sha256-fVfgcoP4AVN1E5wHZbKBIOPYZ/xBeSIdsNF+bdukIRM="
},
{
"pname": "System.Reflection.Metadata",
"version": "1.6.0",
"hash": "sha256-JJfgaPav7UfEh4yRAQdGhLZF1brr0tUWPl6qmfNWq/E="
},
{
"pname": "System.Runtime",
"version": "4.3.1",
"hash": "sha256-R9T68AzS1PJJ7v6ARz9vo88pKL1dWqLOANg4pkQjkA0="
},
{
"pname": "System.Runtime.CompilerServices.Unsafe",
"version": "6.0.0",
"hash": "sha256-bEG1PnDp7uKYz/OgLOWs3RWwQSVYm+AnPwVmAmcgp2I="
},
{
"pname": "System.Security.AccessControl",
"version": "4.5.0",
"hash": "sha256-AFsKPb/nTk2/mqH/PYpaoI8PLsiKKimaXf+7Mb5VfPM="
},
{
"pname": "System.Security.Cryptography.Pkcs",
"version": "6.0.4",
"hash": "sha256-2e0aRybote+OR66bHaNiYpF//4fCiaO3zbR2e9GABUI="
},
{
"pname": "System.Security.Cryptography.ProtectedData",
"version": "4.4.0",
"hash": "sha256-Ri53QmFX8I8UH0x4PikQ1ZA07ZSnBUXStd5rBfGWFOE="
},
{
"pname": "System.Security.Principal.Windows",
"version": "4.5.0",
"hash": "sha256-BkUYNguz0e4NJp1kkW7aJBn3dyH9STwB5N8XqnlCsmY="
},
{
"pname": "System.Text.Json",
"version": "8.0.5",
"hash": "sha256-yKxo54w5odWT6nPruUVsaX53oPRe+gKzGvLnnxtwP68="
},
{
"pname": "TypeEquality",
"version": "0.3.0",
"hash": "sha256-V50xAOzzyUJrY+MYPRxtnqW5MVeATXCes89wPprv1r4="
},
{
"pname": "WoofWare.Whippet.Fantomas",
"version": "0.6.2",
"hash": "sha256-nDT/W5eBwM/E+Z2oQ80maAGYrEyRJQXL1unxR9q6ztU="
}
]

339
nix/deps.nix Normal file
View File

@@ -0,0 +1,339 @@
# This file was automatically generated by passthru.fetch-deps.
# Please dont edit it manually, your changes might get overwritten!
{fetchNuGet}: [
(fetchNuGet {
pname = "ApiSurface";
version = "4.1.5";
hash = "sha256-Kbt18XLk1gvZfzGca885HaXZB119APay85KzI546PYM=";
})
(fetchNuGet {
pname = "fantomas";
version = "6.3.15";
hash = "sha256-Gjw7MxjUNckMWSfnOye4UTe5fZWnor6RHCls3PNsuG8=";
})
(fetchNuGet {
pname = "Fantomas.Core";
version = "6.1.1";
hash = "sha256-FcTLHQFvKkQY/kV08jhhy/St/+FmXpp3epp/R3zUXMA=";
})
(fetchNuGet {
pname = "Fantomas.FCS";
version = "6.1.1";
hash = "sha256-NuZ8msPEHYA8T3EYREB28F1RcNgUU8V54eg2+UttYxw=";
})
(fetchNuGet {
pname = "FsCheck";
version = "2.16.6";
hash = "sha256-1hR2SaJTkqBzU3D955MvLNVzkQHkx0Z/QzOXZfzk2Zw=";
})
(fetchNuGet {
pname = "fsharp-analyzers";
version = "0.27.0";
hash = "sha256-QhLi2veTY1wZlQKJLTyVPgx/ImkaZugQNjSN5VJCNEA=";
})
(fetchNuGet {
pname = "FSharp.Core";
version = "4.3.4";
hash = "sha256-styyo+6mJy+yxE0NZG/b1hxkAjPOnJfMgd9zWzCJ5uk=";
})
(fetchNuGet {
pname = "FSharp.Core";
version = "6.0.1";
hash = "sha256-Ehsgt3nCJijpaVuJguC1TPVEKSkJd6PSc07D2ZQSemI=";
})
(fetchNuGet {
pname = "FSharp.Core";
version = "8.0.400";
hash = "sha256-wlrcAjjvI5YtnHR7kFH8uRUA4GomJYmqr41K5LYjCGs=";
})
(fetchNuGet {
pname = "FsUnit";
version = "6.0.1";
hash = "sha256-vka/aAgWhDCl5tu+kgO7GtSaHOOvlSaWxG+tExwGXpI=";
})
(fetchNuGet {
pname = "Microsoft.AspNetCore.App.Ref";
version = "6.0.33";
hash = "sha256-GcPiO+iI0JsHYlqURAmzWjOnDX2jDCUY4jYaIwr8ojs=";
})
(fetchNuGet {
pname = "Microsoft.AspNetCore.App.Runtime.linux-arm64";
version = "6.0.33";
hash = "sha256-g5zbB1DnCSKuCOWtF09GEqGn1uJLdlTN6kqdnSCzRjQ=";
})
(fetchNuGet {
pname = "Microsoft.AspNetCore.App.Runtime.linux-x64";
version = "6.0.33";
hash = "sha256-ToaiqVy5qonomAVBg5PO1GgrPKL4Cc1BZTJ0z/2LquA=";
})
(fetchNuGet {
pname = "Microsoft.AspNetCore.App.Runtime.osx-arm64";
version = "6.0.33";
hash = "sha256-OY/vdqAzZ99I4lEZbOOQw12TE0AIb5pXxKTvDxO2M2Q=";
})
(fetchNuGet {
pname = "Microsoft.AspNetCore.App.Runtime.osx-x64";
version = "6.0.33";
hash = "sha256-53MAV3RO1kXzy5IpdZDZIOhoUzFqWHn7+A3aWwdTONQ=";
})
(fetchNuGet {
pname = "Microsoft.CodeCoverage";
version = "17.11.1";
hash = "sha256-1dLlK3NGh88PuFYZiYpT+izA96etxhU3BSgixDgdtGA=";
})
(fetchNuGet {
pname = "Microsoft.NET.Test.Sdk";
version = "17.11.1";
hash = "sha256-0JUEucQ2lzaPgkrjm/NFLBTbqU1dfhvhN3Tl3moE6mI=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Host.linux-arm64";
version = "6.0.33";
hash = "sha256-rwWOpf2Pdg84c8bKIUcMYuDTI0kXUELL/nl9psSmX+E=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Host.linux-x64";
version = "6.0.33";
hash = "sha256-5iYNZATXOePDsLA9lI80o1Gjxw4E+B4bJbwdYJJHcZY=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Host.osx-arm64";
version = "6.0.33";
hash = "sha256-k3LenomOlacyzq4FlBY/TwV7+ClbK4U0A/O9r0pZHT4=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Host.osx-x64";
version = "6.0.33";
hash = "sha256-tu72AwDH1+oAIXjOJcNbeyKm1s4pncYp0avbMSBrcJQ=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Ref";
version = "6.0.33";
hash = "sha256-BiGUcXo1FQTlZdR6ndhUQ8lrYG3KaGXNXRVF+Fc3L28=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Runtime.linux-arm64";
version = "6.0.33";
hash = "sha256-obRKiJEVpZ5E3TE7q2oHaYwFYhI23rMiHwp+8ORkwXY=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Runtime.linux-x64";
version = "6.0.33";
hash = "sha256-2xdhvnKsFc8utDWN09zeXzZ5op+WUqkoWLuzdtQAkrA=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Runtime.osx-arm64";
version = "6.0.33";
hash = "sha256-9KHubWicibZOcixiByzuBKPnJM2u5DSQC9jR3MAR1bI=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Runtime.osx-x64";
version = "6.0.33";
hash = "sha256-smh6SiTtCAuFglqWrXiGGsoIDP9dhGuIKdYjmw+xCyY=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "1.1.0";
hash = "sha256-FeM40ktcObQJk4nMYShB61H/E8B7tIKfl9ObJ0IOcCM=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "1.1.1";
hash = "sha256-8hLiUKvy/YirCWlFwzdejD2Db3DaXhHxT7GSZx/znJg=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "2.0.0";
hash = "sha256-IEvBk6wUXSdyCnkj6tHahOJv290tVVT8tyemYcR0Yro=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Targets";
version = "1.1.3";
hash = "sha256-WLsf1NuUfRWyr7C7Rl9jiua9jximnVvzy6nk2D2bVRc=";
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.ObjectModel";
version = "17.11.1";
hash = "sha256-5vX+vCzFY3S7xfMVIv8OlMMFtdedW9UIJzc0WEc+vm4=";
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.TestHost";
version = "17.11.1";
hash = "sha256-wSkY0H1fQAq0H3LcKT4u7Y5RzhAAPa6yueVN84g8HxU=";
})
(fetchNuGet {
pname = "Myriad.Core";
version = "0.8.3";
hash = "sha256-vBOxfq8QriX/yUtaXN69rEQaY/psRNJWxqATLidrt2g=";
})
(fetchNuGet {
pname = "Myriad.Sdk";
version = "0.8.3";
hash = "sha256-7O397WKhskKOvE3MkJT37BvxorDWngDR6gTUogtDZ2M=";
})
(fetchNuGet {
pname = "Nerdbank.GitVersioning";
version = "3.6.143";
hash = "sha256-OhOtMzP+2obDIR+npR7SsoXo0KrmcsL+VCE8Z3t5gzQ=";
})
(fetchNuGet {
pname = "NETStandard.Library";
version = "2.0.3";
hash = "sha256-Prh2RPebz/s8AzHb2sPHg3Jl8s31inv9k+Qxd293ybo=";
})
(fetchNuGet {
pname = "Newtonsoft.Json";
version = "13.0.1";
hash = "sha256-K2tSVW4n4beRPzPu3rlVaBEMdGvWSv/3Q1fxaDh4Mjo=";
})
(fetchNuGet {
pname = "Newtonsoft.Json";
version = "13.0.3";
hash = "sha256-hy/BieY4qxBWVVsDqqOPaLy1QobiIapkbrESm6v2PHc=";
})
(fetchNuGet {
pname = "NuGet.Common";
version = "6.11.0";
hash = "sha256-eb7G07RyZv4AQT6ItRqdBuUf9e9BXcQygsy5RNEXfNE=";
})
(fetchNuGet {
pname = "NuGet.Configuration";
version = "6.11.0";
hash = "sha256-2SNZkX64SB15glzQx3k+vI7btr8Yqg4CayaaaK1B0AQ=";
})
(fetchNuGet {
pname = "NuGet.Frameworks";
version = "6.11.0";
hash = "sha256-8DC7V2IlCjiMDQ9yWbl7QQHia6OpBrbWh5rL0qa0Opw=";
})
(fetchNuGet {
pname = "NuGet.Packaging";
version = "6.11.0";
hash = "sha256-LVLvxcB6SMdayxAsrc5bCuLLt25fqPr6KfYcYoWWIQk=";
})
(fetchNuGet {
pname = "NuGet.Protocol";
version = "6.11.0";
hash = "sha256-3vdB/8IiJ2LMHhFXLWOzf0H59Ow/zcoq6W4uCHbihCQ=";
})
(fetchNuGet {
pname = "NuGet.Versioning";
version = "6.11.0";
hash = "sha256-03edgWvbqUtbzpBBTIxTwsSRoj1T2muGVL+vTuIHXag=";
})
(fetchNuGet {
pname = "NUnit";
version = "4.2.2";
hash = "sha256-+0OS67ITalmG9arYCgQF/+YbmPRnB3pIIykew0kvoCc=";
})
(fetchNuGet {
pname = "NUnit3TestAdapter";
version = "4.6.0";
hash = "sha256-9Yav2fYhC4w0OgsyUwU4/5rDy4FVDTpKnWHuwl/uKJQ=";
})
(fetchNuGet {
pname = "RestEase";
version = "1.6.4";
hash = "sha256-FFmqFwlHhIln46k56Z8KM1G+xuPEh/bceKCQnJcdcdc=";
})
(fetchNuGet {
pname = "runtime.any.System.Runtime";
version = "4.3.0";
hash = "sha256-qwhNXBaJ1DtDkuRacgHwnZmOZ1u9q7N8j0cWOLYOELM=";
})
(fetchNuGet {
pname = "runtime.native.System";
version = "4.3.0";
hash = "sha256-ZBZaodnjvLXATWpXXakFgcy6P+gjhshFXmglrL5xD5Y=";
})
(fetchNuGet {
pname = "runtime.unix.System.Private.Uri";
version = "4.3.0";
hash = "sha256-c5tXWhE/fYbJVl9rXs0uHh3pTsg44YD1dJvyOA0WoMs=";
})
(fetchNuGet {
pname = "System.Diagnostics.DiagnosticSource";
version = "7.0.0";
hash = "sha256-9Wk8cHSkjKtqkN6xW7KnXoQVtF/VNbKeBq79WqDesMs=";
})
(fetchNuGet {
pname = "System.Formats.Asn1";
version = "6.0.0";
hash = "sha256-KaMHgIRBF7Nf3VwOo+gJS1DcD+41cJDPWFh+TDQ8ee8=";
})
(fetchNuGet {
pname = "System.IO.Abstractions";
version = "4.2.13";
hash = "sha256-nkC/PiqE6+c1HJ2yTwg3x+qdBh844Z8n3ERWDW8k6Gg=";
})
(fetchNuGet {
pname = "System.IO.FileSystem.AccessControl";
version = "4.5.0";
hash = "sha256-ck44YBQ0M+2Im5dw0VjBgFD1s0XuY54cujrodjjSBL8=";
})
(fetchNuGet {
pname = "System.Memory";
version = "4.5.5";
hash = "sha256-EPQ9o1Kin7KzGI5O3U3PUQAZTItSbk9h/i4rViN3WiI=";
})
(fetchNuGet {
pname = "System.Private.Uri";
version = "4.3.0";
hash = "sha256-fVfgcoP4AVN1E5wHZbKBIOPYZ/xBeSIdsNF+bdukIRM=";
})
(fetchNuGet {
pname = "System.Reflection.Metadata";
version = "1.6.0";
hash = "sha256-JJfgaPav7UfEh4yRAQdGhLZF1brr0tUWPl6qmfNWq/E=";
})
(fetchNuGet {
pname = "System.Runtime";
version = "4.3.1";
hash = "sha256-R9T68AzS1PJJ7v6ARz9vo88pKL1dWqLOANg4pkQjkA0=";
})
(fetchNuGet {
pname = "System.Runtime.CompilerServices.Unsafe";
version = "6.0.0";
hash = "sha256-bEG1PnDp7uKYz/OgLOWs3RWwQSVYm+AnPwVmAmcgp2I=";
})
(fetchNuGet {
pname = "System.Security.AccessControl";
version = "4.5.0";
hash = "sha256-AFsKPb/nTk2/mqH/PYpaoI8PLsiKKimaXf+7Mb5VfPM=";
})
(fetchNuGet {
pname = "System.Security.Cryptography.Pkcs";
version = "6.0.4";
hash = "sha256-2e0aRybote+OR66bHaNiYpF//4fCiaO3zbR2e9GABUI=";
})
(fetchNuGet {
pname = "System.Security.Cryptography.ProtectedData";
version = "4.4.0";
hash = "sha256-Ri53QmFX8I8UH0x4PikQ1ZA07ZSnBUXStd5rBfGWFOE=";
})
(fetchNuGet {
pname = "System.Security.Principal.Windows";
version = "4.5.0";
hash = "sha256-BkUYNguz0e4NJp1kkW7aJBn3dyH9STwB5N8XqnlCsmY=";
})
(fetchNuGet {
pname = "System.Text.Encodings.Web";
version = "7.0.0";
hash = "sha256-tF8qt9GZh/nPy0mEnj6nKLG4Lldpoi/D8xM5lv2CoYQ=";
})
(fetchNuGet {
pname = "System.Text.Json";
version = "7.0.3";
hash = "sha256-aSJZ17MjqaZNQkprfxm/09LaCoFtpdWmqU9BTROzWX4=";
})
(fetchNuGet {
pname = "TypeEquality";
version = "0.3.0";
hash = "sha256-V50xAOzzyUJrY+MYPRxtnqW5MVeATXCes89wPprv1r4=";
})
(fetchNuGet {
pname = "WoofWare.Whippet.Fantomas";
version = "0.2.1";
hash = "sha256-38LPop5tQ14oqzi0dSzBp2m53fugIMyWed67xnZmJqk=";
})
]