mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-10-08 13:38:39 +00:00
Compare commits
9 Commits
WoofWare.M
...
WoofWare.M
Author | SHA1 | Date | |
---|---|---|---|
|
277a186fda | ||
|
129687ec1c | ||
|
c7fea55e28 | ||
|
ded7b32771 | ||
|
b272f8b645 | ||
|
b8d60aec90 | ||
|
0e3510e1e5 | ||
|
8a1edd90d5 | ||
|
74fdd7c0a9 |
@@ -3,7 +3,7 @@
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"fantomas": {
|
||||
"version": "6.3.16",
|
||||
"version": "7.0.0",
|
||||
"commands": [
|
||||
"fantomas"
|
||||
]
|
||||
|
4
.github/workflows/dotnet.yaml
vendored
4
.github/workflows/dotnet.yaml
vendored
@@ -254,7 +254,7 @@ jobs:
|
||||
name: nuget-package-attribute
|
||||
path: packed
|
||||
- name: Attest Build Provenance
|
||||
uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0
|
||||
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
|
||||
with:
|
||||
subject-path: "packed/*.nupkg"
|
||||
|
||||
@@ -273,7 +273,7 @@ jobs:
|
||||
name: nuget-package-plugin
|
||||
path: packed
|
||||
- name: Attest Build Provenance
|
||||
uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0
|
||||
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
|
||||
with:
|
||||
subject-path: "packed/*.nupkg"
|
||||
|
||||
|
@@ -26769,8 +26769,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"admin/cron/{task}"
|
||||
.Replace ("{task}", task.ToString () |> System.Uri.EscapeDataString),
|
||||
"admin/cron/{task}".Replace ("{task}", task.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -26902,8 +26901,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"admin/hooks/{id}"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
"admin/hooks/{id}".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -26945,8 +26943,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"admin/hooks/{id}"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
"admin/hooks/{id}".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -27584,8 +27581,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"amdin/hooks/{id}"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
"amdin/hooks/{id}".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -28008,8 +28004,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"org/{org}/repos"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
"org/{org}/repos".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -28292,8 +28287,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("orgs/{org}/hooks"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
("orgs/{org}/hooks".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "orgs/{org}/hooks".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -28345,8 +28339,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"orgs/{org}/hooks"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
"orgs/{org}/hooks".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -28538,8 +28531,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("orgs/{org}/labels"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
("orgs/{org}/labels".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "orgs/{org}/labels".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -28591,8 +28583,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"orgs/{org}/labels"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
"orgs/{org}/labels".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -28784,8 +28775,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("orgs/{org}/members"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
("orgs/{org}/members".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "orgs/{org}/members".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -29086,8 +29076,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("orgs/{org}/repos"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
("orgs/{org}/repos".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "orgs/{org}/repos".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -29142,8 +29131,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"orgs/{org}/repos"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
"orgs/{org}/repos".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -29197,8 +29185,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("orgs/{org}/teams"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
("orgs/{org}/teams".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "orgs/{org}/teams".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -29250,8 +29237,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"orgs/{org}/teams"
|
||||
.Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
"orgs/{org}/teams".Replace ("{org}", org.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -39381,8 +39367,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"repositories/{id}"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
"repositories/{id}".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
@@ -39745,8 +39730,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("teams/{id}/members"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString)
|
||||
("teams/{id}/members".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "teams/{id}/members".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -39918,8 +39902,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
("teams/{id}/repos"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString)
|
||||
("teams/{id}/repos".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString)
|
||||
+ (if "teams/{id}/repos".IndexOf (char 63) >= 0 then
|
||||
"&"
|
||||
else
|
||||
@@ -40807,8 +40790,7 @@ module Gitea =
|
||||
System.Uri ("/api/v1/", System.UriKind.Relative)
|
||||
),
|
||||
System.Uri (
|
||||
"user/gpg_keys/{id}"
|
||||
.Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
"user/gpg_keys/{id}".Replace ("{id}", id.ToString () |> System.Uri.EscapeDataString),
|
||||
System.UriKind.Relative
|
||||
)
|
||||
)
|
||||
|
@@ -206,3 +206,34 @@ type internal TypeWithInterfaceMock =
|
||||
|
||||
interface System.IDisposable with
|
||||
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 ()
|
||||
|
@@ -160,8 +160,7 @@ module PureGymApi =
|
||||
| null -> System.Uri "https://whatnot.com/"
|
||||
| v -> v),
|
||||
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
|
||||
)
|
||||
)
|
||||
|
@@ -48,3 +48,10 @@ type TypeWithInterface =
|
||||
inherit IDisposable
|
||||
abstract Mem1 : string option -> 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
|
||||
|
@@ -34,3 +34,16 @@ module TestMockGenerator =
|
||||
mock.Mem1 3 'a' |> shouldEqual "aaa"
|
||||
mock.Mem2 (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
|
||||
|
@@ -42,7 +42,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ApiSurface" Version="4.1.16"/>
|
||||
<PackageReference Include="FsCheck" Version="3.0.0"/>
|
||||
<PackageReference Include="FsCheck" Version="3.1.0"/>
|
||||
<PackageReference Include="FsUnit" Version="6.0.1"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
|
||||
<PackageReference Include="NUnit" Version="4.3.2"/>
|
||||
|
@@ -159,6 +159,15 @@ module internal InterfaceMockGenerator =
|
||||
|> 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 baseName = SynType.createLongIdent interfaceType.Name
|
||||
|
||||
@@ -174,7 +183,7 @@ module internal InterfaceMockGenerator =
|
||||
|
||||
SynType.app' baseName generics
|
||||
|
||||
SynMemberDefn.Interface (interfaceName, Some range0, Some members, range0)
|
||||
SynMemberDefn.Interface (interfaceName, Some range0, Some (members @ properties), range0)
|
||||
|
||||
let access =
|
||||
match interfaceType.Accessibility, spec.IsInternal with
|
||||
@@ -248,6 +257,15 @@ module internal InterfaceMockGenerator =
|
||||
|> SynField.make
|
||||
|> 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
|
||||
(namespaceId : LongIdent)
|
||||
(opens : SynOpenDeclTarget list)
|
||||
@@ -255,7 +273,12 @@ module internal InterfaceMockGenerator =
|
||||
: SynModuleOrNamespace
|
||||
=
|
||||
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 name =
|
||||
|
@@ -351,10 +351,7 @@ module internal JsonParseGenerator =
|
||||
let getParseOptions (fieldAttrs : SynAttribute list) =
|
||||
(JsonParseOption.None, fieldAttrs)
|
||||
||> 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 =
|
||||
match SynExpr.stripOptionalParen attr.ArgExpr with
|
||||
| SynExpr.LongIdent (_, SynLongIdent (ident, _, _), _, _) when isJsonNumberHandling ident ->
|
||||
@@ -384,15 +381,13 @@ module internal JsonParseGenerator =
|
||||
let propertyNameAttr =
|
||||
fieldData.Attrs
|
||||
|> List.tryFind (fun attr ->
|
||||
(SynLongIdent.toString attr.TypeName)
|
||||
.EndsWith ("JsonPropertyName", StringComparison.Ordinal)
|
||||
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonPropertyName", StringComparison.Ordinal)
|
||||
)
|
||||
|
||||
let extensionDataAttr =
|
||||
fieldData.Attrs
|
||||
|> List.tryFind (fun attr ->
|
||||
(SynLongIdent.toString attr.TypeName)
|
||||
.EndsWith ("JsonExtensionData", StringComparison.Ordinal)
|
||||
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonExtensionData", StringComparison.Ordinal)
|
||||
)
|
||||
|
||||
let propertyName =
|
||||
|
@@ -180,8 +180,7 @@ module internal JsonSerializeGenerator =
|
||||
let propertyNameAttr =
|
||||
attrs
|
||||
|> List.tryFind (fun attr ->
|
||||
(SynLongIdent.toString attr.TypeName)
|
||||
.EndsWith ("JsonPropertyName", StringComparison.Ordinal)
|
||||
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonPropertyName", StringComparison.Ordinal)
|
||||
)
|
||||
|
||||
match propertyNameAttr with
|
||||
@@ -198,8 +197,7 @@ module internal JsonSerializeGenerator =
|
||||
let getIsJsonExtension (attrs : SynAttribute list) : bool =
|
||||
attrs
|
||||
|> List.tryFind (fun attr ->
|
||||
(SynLongIdent.toString attr.TypeName)
|
||||
.EndsWith ("JsonExtensionData", StringComparison.Ordinal)
|
||||
(SynLongIdent.toString attr.TypeName).EndsWith ("JsonExtensionData", StringComparison.Ordinal)
|
||||
)
|
||||
|> Option.isSome
|
||||
|
||||
|
6
flake.lock
generated
6
flake.lock
generated
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1736420959,
|
||||
"narHash": "sha256-dMGNa5UwdtowEqQac+Dr0d2tFO/60ckVgdhZU9q2E2o=",
|
||||
"lastModified": 1739019272,
|
||||
"narHash": "sha256-7Fu7oazPoYCbDzb9k8D/DdbKrC3aU1zlnc39Y8jy/s8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "32af3611f6f05655ca166a0b1f47b57c762b5192",
|
||||
"rev": "fa35a3c8e17a3de613240fea68f876e5b4896aec",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@@ -6,8 +6,8 @@
|
||||
},
|
||||
{
|
||||
"pname": "fantomas",
|
||||
"version": "6.3.16",
|
||||
"hash": "sha256-4tRdYf+/Q1iedx+DDuIKVGlIWQdr6erM51VdKzZkhCs="
|
||||
"version": "7.0.0",
|
||||
"hash": "sha256-v4bXmvjZOYxl5RSIHuqVfDzBQdRz5SrmzZtD6SeEYTY="
|
||||
},
|
||||
{
|
||||
"pname": "Fantomas.Core",
|
||||
@@ -21,8 +21,8 @@
|
||||
},
|
||||
{
|
||||
"pname": "FsCheck",
|
||||
"version": "3.0.0",
|
||||
"hash": "sha256-/5FqiNeTVFairRtInS0cjQ3uGlqVfVJG2FsKIo8mdZ4="
|
||||
"version": "3.1.0",
|
||||
"hash": "sha256-u0Ha94EjClJ8evNSHu8d6+Dx9qYM3kV3sl1PEq9gF8s="
|
||||
},
|
||||
{
|
||||
"pname": "fsharp-analyzers",
|
||||
@@ -51,8 +51,8 @@
|
||||
},
|
||||
{
|
||||
"pname": "FSharp.Core",
|
||||
"version": "9.0.100",
|
||||
"hash": "sha256-V1q3CjbRvWZqxpi6cXD/R0F7pyXGGtH83M5Z/ITDrp8="
|
||||
"version": "9.0.101",
|
||||
"hash": "sha256-bR4PHanvKrzD43qFQxmOmmhhpz+ZmKZMPlgGnlRNcp4="
|
||||
},
|
||||
{
|
||||
"pname": "FsUnit",
|
||||
|
Reference in New Issue
Block a user