Compare commits

...

5 Commits

Author SHA1 Message Date
Patrick Stevens
913959a740 Make arg parser more AOT-friendly (#253) 2024-09-10 22:16:43 +01:00
dependabot[bot]
93ffc065cd Bump Microsoft.NET.Test.Sdk from 17.11.0 to 17.11.1 (#248)
* Bump Microsoft.NET.Test.Sdk from 17.11.0 to 17.11.1

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.11.0 to 17.11.1.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](https://github.com/microsoft/vstest/compare/v17.11.0...v17.11.1)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump fantomas from 6.3.11 to 6.3.12

Bumps [fantomas](https://github.com/fsprojects/fantomas) from 6.3.11 to 6.3.12.
- [Release notes](https://github.com/fsprojects/fantomas/releases)
- [Changelog](https://github.com/fsprojects/fantomas/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsprojects/fantomas/compare/v6.3.11...v6.3.12)

---
updated-dependencies:
- dependency-name: fantomas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Deps

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com>
2024-09-09 19:33:39 +00:00
dependabot[bot]
d14efba7e7 Bump actions/attest-build-provenance from 1.4.2 to 1.4.3 (#247) 2024-09-09 12:42:12 +01:00
patrick-conscriptus[bot]
f5cf0b79dd Automated commit (#246)
Co-authored-by: patrick-conscriptus[bot] <175414948+patrick-conscriptus[bot]@users.noreply.github.com>
2024-09-08 01:20:34 +00:00
Patrick Stevens
029e3746bb Fix record/union impl accessibility (#245) 2024-09-07 08:49:28 +00:00
13 changed files with 340 additions and 217 deletions

View File

@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas": {
"version": "6.3.11",
"version": "6.3.12",
"commands": [
"fantomas"
]

View File

@@ -241,7 +241,7 @@ jobs:
name: nuget-package-attribute
path: packed
- name: Attest Build Provenance
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-path: "packed/*.nupkg"
@@ -260,7 +260,7 @@ jobs:
name: nuget-package-plugin
path: packed
- name: Attest Build Provenance
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c # v1.4.3
with:
subject-path: "packed/*.nupkg"

View File

@@ -190,3 +190,8 @@ type ManyLongForms =
[<ArgumentLongForm "dont-turn-it-off">]
SomeFlag : bool
}
[<RequireQualifiedAccess>]
type private IrrelevantDu =
| Foo
| Bar

View File

@@ -51,7 +51,11 @@ module BasicNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "baz", System.StringComparison.OrdinalIgnoreCase) then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "baz") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "baz")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -64,7 +68,11 @@ module BasicNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "bar", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "bar") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bar")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -77,7 +85,11 @@ module BasicNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "foo", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "foo") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "foo")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -253,7 +265,11 @@ module Basic =
if System.String.Equals (key, sprintf "--%s" "baz", System.StringComparison.OrdinalIgnoreCase) then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "baz") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "baz")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -266,7 +282,11 @@ module Basic =
else if System.String.Equals (key, sprintf "--%s" "bar", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "bar") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bar")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -279,7 +299,11 @@ module Basic =
else if System.String.Equals (key, sprintf "--%s" "foo", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "foo") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "foo")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -442,7 +466,11 @@ module BasicWithIntPositionals =
if System.String.Equals (key, sprintf "--%s" "baz", System.StringComparison.OrdinalIgnoreCase) then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "baz") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "baz")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -455,7 +483,11 @@ module BasicWithIntPositionals =
else if System.String.Equals (key, sprintf "--%s" "bar", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "bar") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bar")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -468,7 +500,11 @@ module BasicWithIntPositionals =
else if System.String.Equals (key, sprintf "--%s" "foo", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "foo") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "foo")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -623,13 +659,17 @@ module LoadsOfTypes =
(sprintf
"%s bool%s%s"
(sprintf "--%s" "optional-thing")
(LoadsOfTypes.DefaultOptionalThing () |> sprintf " (default value: %O)")
(LoadsOfTypes.DefaultOptionalThing ()
|> (fun x -> x.ToString ())
|> sprintf " (default value: %s)")
"")
(sprintf
"%s int32%s%s"
(sprintf "--%s" "another-optional-thing")
(LoadsOfTypes.DefaultAnotherOptionalThing () |> sprintf " (default value: %O)")
(LoadsOfTypes.DefaultAnotherOptionalThing ()
|> (fun x -> x.ToString ())
|> sprintf " (default value: %s)")
"")
(sprintf
@@ -667,10 +707,10 @@ module LoadsOfTypes =
match arg_10 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "yet-another-optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -690,10 +730,10 @@ module LoadsOfTypes =
match arg_9 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "another-optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -709,10 +749,10 @@ module LoadsOfTypes =
match arg_8 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -732,10 +772,10 @@ module LoadsOfTypes =
match arg_6 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "optional-thing-with-no-default")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -756,10 +796,10 @@ module LoadsOfTypes =
match arg_4 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "some-directory")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -774,7 +814,11 @@ module LoadsOfTypes =
then
match arg_3 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "some-file") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "some-file")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -787,7 +831,11 @@ module LoadsOfTypes =
else if System.String.Equals (key, sprintf "--%s" "baz", System.StringComparison.OrdinalIgnoreCase) then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "baz") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "baz")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -800,7 +848,11 @@ module LoadsOfTypes =
else if System.String.Equals (key, sprintf "--%s" "bar", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "bar") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bar")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -813,7 +865,11 @@ module LoadsOfTypes =
else if System.String.Equals (key, sprintf "--%s" "foo", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "foo") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "foo")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1037,14 +1093,16 @@ module LoadsOfTypesNoPositionals =
"%s bool%s%s"
(sprintf "--%s" "optional-thing")
(LoadsOfTypesNoPositionals.DefaultOptionalThing ()
|> sprintf " (default value: %O)")
|> (fun x -> x.ToString ())
|> sprintf " (default value: %s)")
"")
(sprintf
"%s int32%s%s"
(sprintf "--%s" "another-optional-thing")
(LoadsOfTypesNoPositionals.DefaultAnotherOptionalThing ()
|> sprintf " (default value: %O)")
|> (fun x -> x.ToString ())
|> sprintf " (default value: %s)")
"")
(sprintf
"%s string%s%s"
@@ -1080,10 +1138,10 @@ module LoadsOfTypesNoPositionals =
match arg_9 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "yet-another-optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1103,10 +1161,10 @@ module LoadsOfTypesNoPositionals =
match arg_8 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "another-optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1122,10 +1180,10 @@ module LoadsOfTypesNoPositionals =
match arg_7 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "optional-thing")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1145,10 +1203,10 @@ module LoadsOfTypesNoPositionals =
match arg_6 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "optional-thing-with-no-default")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1169,10 +1227,10 @@ module LoadsOfTypesNoPositionals =
match arg_4 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "some-directory")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1187,7 +1245,11 @@ module LoadsOfTypesNoPositionals =
then
match arg_3 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "some-file") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "some-file")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1200,7 +1262,11 @@ module LoadsOfTypesNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "baz", System.StringComparison.OrdinalIgnoreCase) then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "baz") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "baz")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1213,7 +1279,11 @@ module LoadsOfTypesNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "bar", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "bar") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bar")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1226,7 +1296,11 @@ module LoadsOfTypesNoPositionals =
else if System.String.Equals (key, sprintf "--%s" "foo", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "foo") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "foo")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1481,10 +1555,10 @@ module DatesAndTimesArgParse =
match arg_3 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "invariant-exact")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1509,7 +1583,11 @@ module DatesAndTimesArgParse =
then
match arg_2 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "exact") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "exact")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1535,10 +1613,10 @@ module DatesAndTimesArgParse =
match arg_1 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "invariant")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1559,7 +1637,11 @@ module DatesAndTimesArgParse =
then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "plain") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "plain")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1734,10 +1816,10 @@ module ParentRecordArgParse =
match arg_2 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "and-another")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1752,7 +1834,11 @@ module ParentRecordArgParse =
then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "thing2") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "thing2")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1767,7 +1853,11 @@ module ParentRecordArgParse =
then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "thing1") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "thing1")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1945,7 +2035,11 @@ module ParentRecordChildPosArgParse =
if System.String.Equals (key, sprintf "--%s" "thing1", System.StringComparison.OrdinalIgnoreCase) then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "thing1") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "thing1")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -1961,10 +2055,10 @@ module ParentRecordChildPosArgParse =
match arg_2 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "and-another")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2128,7 +2222,11 @@ module ParentRecordSelfPosArgParse =
if System.String.Equals (key, sprintf "--%s" "thing2", System.StringComparison.OrdinalIgnoreCase) then
match arg_1 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "thing2") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "thing2")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2143,7 +2241,11 @@ module ParentRecordSelfPosArgParse =
then
match arg_0 with
| Some x ->
sprintf "Argument '%s' was supplied multiple times: %O and %O" (sprintf "--%s" "thing1") x value
sprintf
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "thing1")
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2403,10 +2505,10 @@ module ContainsBoolEnvVarArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "bool-var")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2568,10 +2670,10 @@ module WithFlagDuArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "dry-run")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2741,10 +2843,10 @@ module ContainsFlagEnvVarArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "dry-run")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -2930,7 +3032,8 @@ module ContainsFlagDefaultValueArgParse =
(match ContainsFlagDefaultValue.DefaultDryRun () with
| DryRunMode.Wet -> if Consts.FALSE = true then "true" else "false"
| DryRunMode.Dry -> if true = true then "true" else "false"
|> sprintf " (default value: %O)")
|> (fun x -> x.ToString ())
|> sprintf " (default value: %s)")
"")
]
|> String.concat "\n"
@@ -2946,10 +3049,10 @@ module ContainsFlagDefaultValueArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s" "dry-run")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -3119,10 +3222,10 @@ module ManyLongFormsArgParse =
match arg_1 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s / --%s" "turn-it-on" "dont-turn-it-off")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -3138,10 +3241,10 @@ module ManyLongFormsArgParse =
match arg_1 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s / --%s" "turn-it-on" "dont-turn-it-off")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -3157,10 +3260,10 @@ module ManyLongFormsArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s / --%s" "do-something-else" "anotherarg")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()
@@ -3180,10 +3283,10 @@ module ManyLongFormsArgParse =
match arg_0 with
| Some x ->
sprintf
"Argument '%s' was supplied multiple times: %O and %O"
"Argument '%s' was supplied multiple times: %s and %s"
(sprintf "--%s / --%s" "do-something-else" "anotherarg")
x
value
(x.ToString ())
(value.ToString ())
|> ArgParser_errors.Add
Ok ()

View File

@@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="ApiSurface" Version="4.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="NUnit" Version="4.2.2"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
</ItemGroup>

View File

@@ -42,7 +42,7 @@
<PackageReference Include="ApiSurface" Version="4.1.5"/>
<PackageReference Include="FsCheck" Version="2.16.6"/>
<PackageReference Include="FsUnit" Version="6.0.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageReference Include="NUnit" Version="4.2.2"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
</ItemGroup>

View File

@@ -723,7 +723,10 @@ module internal ArgParserGenerator =
]
|> SynExpr.createMatch (SynExpr.callMethod var.idText (SynExpr.createIdent' typeName))
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction (SynExpr.createIdent "sprintf") (SynExpr.CreateConst " (default value: %O)")
SynExpr.createLambda "x" (SynExpr.callMethod "ToString" (SynExpr.createIdent "x"))
)
|> SynExpr.pipeThroughFunction (
SynExpr.applyFunction (SynExpr.createIdent "sprintf") (SynExpr.CreateConst " (default value: %s)")
)
|> SynExpr.paren
| Accumulation.List _ -> SynExpr.CreateConst " (can be repeated)"
@@ -786,10 +789,12 @@ module internal ArgParserGenerator =
| Accumulation.Optional ->
let multipleErrorMessage =
SynExpr.createIdent "sprintf"
|> SynExpr.applyTo (SynExpr.CreateConst "Argument '%s' was supplied multiple times: %O and %O")
|> SynExpr.applyTo (SynExpr.CreateConst "Argument '%s' was supplied multiple times: %s and %s")
|> SynExpr.applyTo arg.HumanReadableArgForm
|> SynExpr.applyTo (SynExpr.createIdent "x")
|> SynExpr.applyTo (SynExpr.createIdent "value")
|> SynExpr.applyTo (SynExpr.createIdent "x" |> SynExpr.callMethod "ToString" |> SynExpr.paren)
|> SynExpr.applyTo (
SynExpr.createIdent "value" |> SynExpr.callMethod "ToString" |> SynExpr.paren
)
let performAssignment =
[
@@ -1521,53 +1526,54 @@ module internal ArgParserGenerator =
|> List.choose (fun ty ->
match ty.Cases with
| [ c1 ; c2 ] ->
let c1Attr =
c1.Attributes
|> List.tryPick (fun attr ->
match attr.TypeName with
| SynLongIdent.SynLongIdent (id, _, _) ->
match id |> List.last |> _.idText with
| "ArgumentFlagAttribute"
| "ArgumentFlag" -> Some (SynExpr.stripOptionalParen attr.ArgExpr)
| _ -> None
)
let c2Attr =
c2.Attributes
|> List.tryPick (fun attr ->
match attr.TypeName with
| SynLongIdent.SynLongIdent (id, _, _) ->
match id |> List.last |> _.idText with
| "ArgumentFlagAttribute"
| "ArgumentFlag" -> Some (SynExpr.stripOptionalParen attr.ArgExpr)
| _ -> None
)
match c1Attr, c2Attr with
| Some _, None
| None, Some _ ->
failwith
"[<ArgumentFlag>] must be placed on both cases of a two-case discriminated union, with opposite argument values on each case."
| None, None -> None
| Some c1Attr, Some c2Attr ->
// Sanity check where possible
match c1Attr, c2Attr with
| SynExpr.Const (SynConst.Bool b1, _), SynExpr.Const (SynConst.Bool b2, _) ->
if b1 = b2 then
failwith
"[<ArgumentFlag>] must have opposite argument values on each case in a two-case discriminated union."
| _, _ -> ()
match c1.Fields, c2.Fields with
| [], [] ->
let c1Attr =
c1.Attributes
|> List.tryPick (fun attr ->
match attr.TypeName with
| SynLongIdent.SynLongIdent (id, _, _) ->
match id |> List.last |> _.idText with
| "ArgumentFlagAttribute"
| "ArgumentFlag" -> Some (SynExpr.stripOptionalParen attr.ArgExpr)
| _ -> None
)
let c2Attr =
c2.Attributes
|> List.tryPick (fun attr ->
match attr.TypeName with
| SynLongIdent.SynLongIdent (id, _, _) ->
match id |> List.last |> _.idText with
| "ArgumentFlagAttribute"
| "ArgumentFlag" -> Some (SynExpr.stripOptionalParen attr.ArgExpr)
| _ -> None
)
match c1Attr, c2Attr with
| Some c1Attr, Some c2Attr ->
// Sanity check where possible
match c1Attr, c2Attr with
| SynExpr.Const (SynConst.Bool b1, _), SynExpr.Const (SynConst.Bool b2, _) ->
if b1 = b2 then
failwith
"[<ArgumentFlag>] must have opposite argument values on each case in a two-case discriminated union."
| _, _ -> ()
{
Name = ty.Name
Case1Name = c1.Name
Case1Arg = c1Attr
Case2Name = c2.Name
Case2Arg = c2Attr
}
|> Some
| Some _, None
| None, Some _ ->
failwith
"[<ArgumentFlag>] must be placed on both cases of a two-case discriminated union, with opposite argument values on each case."
| _, _ -> None
{
Name = ty.Name
Case1Name = c1.Name
Case1Arg = c1Attr
Case2Name = c2.Name
Case2Arg = c2Attr
}
|> Some
| _, _ ->
failwith "[<ArgumentFlag>] may only be placed on discriminated union members with no data."
| _ -> None

View File

@@ -67,7 +67,8 @@ type internal RecordType =
Members : SynMemberDefns option
XmlDoc : PreXmlDoc option
Generics : SynTyparDecls option
Accessibility : SynAccess option
TypeAccessibility : SynAccess option
ImplAccessibility : SynAccess option
Attributes : SynAttribute list
}
@@ -80,17 +81,15 @@ type internal RecordType =
: RecordType
=
match sci with
| SynComponentInfo.SynComponentInfo (attrs, typars, _, longId, doc, _, access2, _) ->
if access <> access2 then
failwith $"TODO what's happened, two different accessibility modifiers: %O{access} and %O{access2}"
| SynComponentInfo.SynComponentInfo (attrs, typars, _, longId, doc, _, implAccess, _) ->
{
Name = List.last longId
Fields = recordFields
Members = if smd.IsEmpty then None else Some smd
XmlDoc = if doc.IsEmpty then None else Some doc
Generics = typars
Accessibility = access
ImplAccessibility = implAccess
TypeAccessibility = access
Attributes = attrs |> List.collect (fun l -> l.Attributes)
}
@@ -144,7 +143,9 @@ type internal UnionType =
/// Attributes of the DU (not its cases): `[<Attr>] type Foo = | ...`
Attributes : SynAttribute list
/// Accessibility modifier of the DU: `type private Foo = ...`
Accessibility : SynAccess option
TypeAccessibility : SynAccess option
/// Accessibility modifier of the DU's implementation: `type Foo = private | ...`
ImplAccessibility : SynAccess option
/// The actual DU cases themselves.
Cases : UnionCase<Ident option> list
}
@@ -157,17 +158,15 @@ type internal UnionType =
: UnionType
=
match sci with
| SynComponentInfo.SynComponentInfo (attrs, typars, _, longId, doc, _, access2, _) ->
if access <> access2 then
failwith $"TODO what's happened, two different accessibility modifiers: %O{access} and %O{access2}"
| SynComponentInfo.SynComponentInfo (attrs, typars, _, longId, doc, _, implAccess, _) ->
{
Name = List.last longId
Members = if smd.IsEmpty then None else Some smd
XmlDoc = if doc.IsEmpty then None else Some doc
Generics = typars
Attributes = attrs |> List.collect (fun l -> l.Attributes)
Accessibility = access
TypeAccessibility = access
ImplAccessibility = implAccess
Cases = cases |> List.map UnionCase.ofSynUnionCase
}
@@ -213,13 +212,13 @@ module internal AstHelper =
let defineRecordType (record : RecordType) : SynTypeDefn =
let name =
SynComponentInfo.create record.Name
|> SynComponentInfo.setAccessibility record.Accessibility
|> SynComponentInfo.setAccessibility record.TypeAccessibility
|> match record.XmlDoc with
| None -> id
| Some doc -> SynComponentInfo.withDocString doc
|> SynComponentInfo.setGenerics record.Generics
SynTypeDefnRepr.record (Seq.toList record.Fields)
SynTypeDefnRepr.recordWithAccess record.ImplAccessibility (Seq.toList record.Fields)
|> SynTypeDefn.create name
|> SynTypeDefn.withMemberDefns (defaultArg record.Members SynMemberDefns.Empty)

View File

@@ -212,7 +212,8 @@ module internal InterfaceMockGenerator =
Members = Some ([ constructor ; interfaceMembers ] @ extraInterfaces)
XmlDoc = Some xmlDoc
Generics = interfaceType.Generics
Accessibility = Some access
TypeAccessibility = Some access
ImplAccessibility = None
Attributes = []
}

View File

@@ -36,7 +36,6 @@ module internal RemoveOptionsGenerator =
trivia
)
// TODO: this option seems a bit odd
let createType
(xmlDoc : PreXmlDoc option)
(accessibility : SynAccess option)
@@ -54,7 +53,8 @@ module internal RemoveOptionsGenerator =
Members = None
XmlDoc = xmlDoc
Generics = generics
Accessibility = accessibility
TypeAccessibility = accessibility
ImplAccessibility = None
Attributes = []
}
@@ -62,7 +62,7 @@ module internal RemoveOptionsGenerator =
SynModuleDecl.Types ([ typeDecl ], range0)
let createMaker (withOptionsType : LongIdent) (withoutOptionsType : LongIdent) (fields : SynFieldData<Ident> list) =
let createMaker (withOptionsType : LongIdent) (withoutOptionsType : Ident) (fields : SynFieldData<Ident> list) =
let xmlDoc = PreXmlDoc.create "Remove the optional members of the input."
let inputArg = Ident.create "input"
@@ -87,7 +87,7 @@ module internal RemoveOptionsGenerator =
SynExpr.applyFunction
(SynExpr.createLongIdent [ "Option" ; "defaultWith" ])
(SynExpr.createLongIdent' (
withoutOptionsType
[ withoutOptionsType ]
@ [ Ident.create (sprintf "Default%s" fieldData.Ident.idText) ]
))
)
@@ -101,47 +101,35 @@ module internal RemoveOptionsGenerator =
[ functionName ]
[
SynPat.named inputArg.idText
|> SynPat.annotateType (SynType.LongIdent (SynLongIdent.create withoutOptionsType))
|> SynPat.annotateType (SynType.LongIdent (SynLongIdent.createI withoutOptionsType))
]
body
|> SynBinding.withXmlDoc xmlDoc
|> SynBinding.withReturnAnnotation (SynType.LongIdent (SynLongIdent.create withOptionsType))
|> SynModuleDecl.createLet
let createRecordModule (namespaceId : LongIdent) (typeDefn : SynTypeDefn) =
let (SynTypeDefn (synComponentInfo, synTypeDefnRepr, _members, _implicitCtor, _, _)) =
typeDefn
let createRecordModule (namespaceId : LongIdent) (typeDefn : RecordType) =
let fieldData = typeDefn.Fields |> List.map SynField.extractWithIdent
let (SynComponentInfo (_attributes, typeParams, _constraints, recordId, doc, _preferPostfix, _access, _)) =
synComponentInfo
let decls =
[
createType typeDefn.XmlDoc typeDefn.TypeAccessibility typeDefn.Generics typeDefn.Fields
createMaker [ Ident.create "Short" ] typeDefn.Name fieldData
]
match synTypeDefnRepr with
| SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Record (accessibility, fields, _range), _) ->
let fieldData = fields |> List.map SynField.extractWithIdent
let xmlDoc =
sprintf "Module containing an option-truncated version of the %s type" typeDefn.Name.idText
|> PreXmlDoc.create
let decls =
[
createType (Some doc) accessibility typeParams fields
createMaker [ Ident.create "Short" ] recordId fieldData
]
let info =
SynComponentInfo.create typeDefn.Name
|> SynComponentInfo.withDocString xmlDoc
|> SynComponentInfo.addAttributes [ SynAttribute.compilationRepresentation ]
|> SynComponentInfo.addAttributes [ SynAttribute.requireQualifiedAccess ]
let xmlDoc =
recordId
|> Seq.map (fun i -> i.idText)
|> String.concat "."
|> sprintf "Module containing an option-truncated version of the %s type"
|> PreXmlDoc.create
let info =
SynComponentInfo.createLong recordId
|> SynComponentInfo.withDocString xmlDoc
|> SynComponentInfo.addAttributes [ SynAttribute.compilationRepresentation ]
|> SynComponentInfo.addAttributes [ SynAttribute.requireQualifiedAccess ]
SynModuleDecl.nestedModule info decls
|> List.singleton
|> SynModuleOrNamespace.createNamespace namespaceId
| _ -> failwithf "Not a record type"
SynModuleDecl.nestedModule info decls
|> List.singleton
|> SynModuleOrNamespace.createNamespace namespaceId
open Myriad.Core
@@ -164,7 +152,24 @@ type RemoveOptionsGenerator () =
|> List.choose (fun (ns, types) ->
match types |> List.filter Ast.hasAttribute<RemoveOptionsAttribute> with
| [] -> None
| types -> Some (ns, types)
| types ->
let types =
types
|> List.map (fun ty ->
match ty with
| SynTypeDefn.SynTypeDefn (sci,
SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Record (access,
fields,
_),
_),
smd,
smdo,
_,
_) -> RecordType.OfRecord sci smd access fields
| _ -> failwith "unexpectedly not a record"
)
Some (ns, types)
)
let modules =

View File

@@ -13,8 +13,12 @@ module internal SynTypeDefnRepr =
let inline augmentation () : SynTypeDefnRepr =
SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.Augmentation range0, [], range0)
let inline union (cases : SynUnionCase list) : SynTypeDefnRepr =
SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Union (None, cases, range0), range0)
let inline unionWithAccess (implAccess : SynAccess option) (cases : SynUnionCase list) : SynTypeDefnRepr =
SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Union (implAccess, cases, range0), range0)
let inline record (fields : SynField list) : SynTypeDefnRepr =
SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Record (None, fields, range0), range0)
let inline union (cases : SynUnionCase list) : SynTypeDefnRepr = unionWithAccess None cases
let inline recordWithAccess (implAccess : SynAccess option) (fields : SynField list) : SynTypeDefnRepr =
SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.Record (implAccess, fields, range0), range0)
let inline record (fields : SynField list) : SynTypeDefnRepr = recordWithAccess None fields

6
flake.lock generated
View File

@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1725099143,
"narHash": "sha256-CHgumPZaC7z+WYx72WgaLt2XF0yUVzJS60rO4GZ7ytY=",
"lastModified": 1725534445,
"narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5629520edecb69630a3f4d17d3d33fc96c13f6fe",
"rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39",
"type": "github"
},
"original": {

View File

@@ -8,8 +8,8 @@
})
(fetchNuGet {
pname = "fantomas";
version = "6.3.11";
hash = "sha256-11bHGEAZTNtdp2pTg5zqLrQiyI/j/AT7GGL/2CR4+dw=";
version = "6.3.12";
hash = "sha256-LFZn2cO72FlsmLI0vTLz52Bn4XBeGILTOr8rz/EuXeg=";
})
(fetchNuGet {
pname = "Fantomas.Core";
@@ -78,13 +78,13 @@
})
(fetchNuGet {
pname = "Microsoft.CodeCoverage";
version = "17.11.0";
hash = "sha256-XglInnx5GePUYHG7n2NLX+WfK7kJnornsWOW/5FnOXE=";
version = "17.11.1";
hash = "sha256-1dLlK3NGh88PuFYZiYpT+izA96etxhU3BSgixDgdtGA=";
})
(fetchNuGet {
pname = "Microsoft.NET.Test.Sdk";
version = "17.11.0";
hash = "sha256-WjyA78+PG9ZloWTt9Hf1ek3VVj2FfJ9fAjqklnN+fWw=";
version = "17.11.1";
hash = "sha256-0JUEucQ2lzaPgkrjm/NFLBTbqU1dfhvhN3Tl3moE6mI=";
})
(fetchNuGet {
pname = "Microsoft.NETCore.App.Host.linux-arm64";
@@ -153,13 +153,13 @@
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.ObjectModel";
version = "17.11.0";
hash = "sha256-mCI3MCV6nyrGLrBat5VvK5LrXTEKlsdp9NkpZyJYwVg=";
version = "17.11.1";
hash = "sha256-5vX+vCzFY3S7xfMVIv8OlMMFtdedW9UIJzc0WEc+vm4=";
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.TestHost";
version = "17.11.0";
hash = "sha256-gViDLobza22kuLvB4JdlGtbANqwBHRwf1wLmIHMw9Eo=";
version = "17.11.1";
hash = "sha256-wSkY0H1fQAq0H3LcKT4u7Y5RzhAAPa6yueVN84g8HxU=";
})
(fetchNuGet {
pname = "Myriad.Core";