mirror of
				https://github.com/Smaug123/WoofWare.Myriad
				synced 2025-10-29 07:39:00 +00:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
			WoofWare.M
			...
			c1dc12122a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | c1dc12122a | ||
|  | 881c83591a | ||
|  | 41eed6653d | ||
|  | 52ac8db542 | ||
|  | 6f69c67d7e | ||
|  | 1985fcbe5b | ||
|  | 51518614bc | ||
|  | eddf7bac18 | ||
|  | be6b3e20b6 | ||
|  | 6a3d5e6019 | 
| @@ -3,7 +3,7 @@ | |||||||
|   "isRoot": true, |   "isRoot": true, | ||||||
|   "tools": { |   "tools": { | ||||||
|     "fantomas": { |     "fantomas": { | ||||||
|       "version": "6.3.3", |       "version": "6.3.0-alpha-008", | ||||||
|       "commands": [ |       "commands": [ | ||||||
|         "fantomas" |         "fantomas" | ||||||
|       ] |       ] | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								.github/workflows/dotnet.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/dotnet.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -28,7 +28,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@v26 |       uses: cachix/install-nix-action@v25 | ||||||
|       with: |       with: | ||||||
|         extra_nix_config: | |         extra_nix_config: | | ||||||
|           access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |           access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -49,7 +49,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@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -66,7 +66,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@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -79,7 +79,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@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -92,7 +92,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@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -105,7 +105,7 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@master |       - uses: actions/checkout@master | ||||||
|       - name: Install Nix |       - name: Install Nix | ||||||
|         uses: cachix/install-nix-action@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -118,7 +118,7 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@master |       - uses: actions/checkout@master | ||||||
|       - name: Install Nix |       - name: Install Nix | ||||||
|         uses: cachix/install-nix-action@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -132,7 +132,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@v26 |       uses: cachix/install-nix-action@v25 | ||||||
|       with: |       with: | ||||||
|         extra_nix_config: | |         extra_nix_config: | | ||||||
|           access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |           access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
| @@ -188,7 +188,7 @@ jobs: | |||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|       - name: Install Nix |       - name: Install Nix | ||||||
|         uses: cachix/install-nix-action@v26 |         uses: cachix/install-nix-action@v25 | ||||||
|         with: |         with: | ||||||
|           extra_nix_config: | |           extra_nix_config: | | ||||||
|             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} |             access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | ||||||
|   | |||||||
| @@ -5,7 +5,6 @@ | |||||||
|  |  | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -26,11 +25,10 @@ type internal PublicTypeMock = | |||||||
|  |  | ||||||
|     interface IPublicType with |     interface IPublicType with | ||||||
|         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) |         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) | ||||||
|         member this.Mem2 arg_0_0 = this.Mem2 (arg_0_0) |         member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) | ||||||
|         member this.Mem3 (arg_0_0, arg_0_1) = this.Mem3 (arg_0_0, arg_0_1) |         member this.Mem3 (arg_0_0, arg_0_1) = this.Mem3 (arg_0_0, arg_0_1) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -51,11 +49,10 @@ type public PublicTypeInternalFalseMock = | |||||||
|  |  | ||||||
|     interface IPublicTypeInternalFalse with |     interface IPublicTypeInternalFalse with | ||||||
|         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) |         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) | ||||||
|         member this.Mem2 arg_0_0 = this.Mem2 (arg_0_0) |         member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) | ||||||
|         member this.Mem3 (arg_0_0, arg_0_1) = this.Mem3 (arg_0_0, arg_0_1) |         member this.Mem3 (arg_0_0, arg_0_1) = this.Mem3 (arg_0_0, arg_0_1) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -74,10 +71,9 @@ type internal InternalTypeMock = | |||||||
|  |  | ||||||
|     interface InternalType with |     interface InternalType with | ||||||
|         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) |         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) | ||||||
|         member this.Mem2 arg_0_0 = this.Mem2 (arg_0_0) |         member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -96,10 +92,9 @@ type private PrivateTypeMock = | |||||||
|  |  | ||||||
|     interface PrivateType with |     interface PrivateType with | ||||||
|         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) |         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) | ||||||
|         member this.Mem2 arg_0_0 = this.Mem2 (arg_0_0) |         member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -118,10 +113,9 @@ type private PrivateTypeInternalFalseMock = | |||||||
|  |  | ||||||
|     interface PrivateTypeInternalFalse with |     interface PrivateTypeInternalFalse with | ||||||
|         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) |         member this.Mem1 (arg_0_0, arg_0_1) = this.Mem1 (arg_0_0, arg_0_1) | ||||||
|         member this.Mem2 arg_0_0 = this.Mem2 (arg_0_0) |         member this.Mem2 (arg_0_0) = this.Mem2 (arg_0_0) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -137,10 +131,9 @@ type internal VeryPublicTypeMock<'a, 'b> = | |||||||
|         } |         } | ||||||
|  |  | ||||||
|     interface VeryPublicType<'a, 'b> with |     interface VeryPublicType<'a, 'b> with | ||||||
|         member this.Mem1 arg_0_0 = this.Mem1 (arg_0_0) |         member this.Mem1 (arg_0_0) = this.Mem1 (arg_0_0) | ||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| /// Mock record type for an interface | /// Mock record type for an interface | ||||||
| @@ -166,9 +159,9 @@ type internal CurriedMock<'a> = | |||||||
|         } |         } | ||||||
|  |  | ||||||
|     interface Curried<'a> with |     interface Curried<'a> with | ||||||
|         member this.Mem1 arg_0_0 arg_1_0 = this.Mem1 (arg_0_0) (arg_1_0) |         member this.Mem1 (arg_0_0) (arg_1_0) = this.Mem1 (arg_0_0) (arg_1_0) | ||||||
|         member this.Mem2 (arg_0_0, arg_0_1) arg_1_0 = this.Mem2 (arg_0_0, arg_0_1) (arg_1_0) |         member this.Mem2 (arg_0_0, arg_0_1) (arg_1_0) = this.Mem2 (arg_0_0, arg_0_1) (arg_1_0) | ||||||
|         member this.Mem3 ((arg_0_0, arg_0_1)) arg_1_0 = this.Mem3 (arg_0_0, arg_0_1) (arg_1_0) |         member this.Mem3 ((arg_0_0, arg_0_1)) (arg_1_0) = this.Mem3 (arg_0_0, arg_0_1) (arg_1_0) | ||||||
|  |  | ||||||
|         member this.Mem4 ((arg_0_0, arg_0_1)) ((arg_1_0, arg_1_1)) = |         member this.Mem4 ((arg_0_0, arg_0_1)) ((arg_1_0, arg_1_1)) = | ||||||
|             this.Mem4 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) |             this.Mem4 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) | ||||||
| @@ -178,31 +171,3 @@ type internal CurriedMock<'a> = | |||||||
|  |  | ||||||
|         member this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) = |         member this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) = | ||||||
|             this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) |             this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) | ||||||
| namespace SomeNamespace |  | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins |  | ||||||
|  |  | ||||||
| /// Mock record type for an interface |  | ||||||
| type internal TypeWithInterfaceMock = |  | ||||||
|     { |  | ||||||
|         /// Implementation of IDisposable.Dispose |  | ||||||
|         Dispose : unit -> unit |  | ||||||
|         Mem1 : string option -> string[] Async |  | ||||||
|         Mem2 : unit -> string[] Async |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /// An implementation where every method throws. |  | ||||||
|     static member Empty : TypeWithInterfaceMock = |  | ||||||
|         { |  | ||||||
|             Dispose = (fun _ -> ()) |  | ||||||
|             Mem1 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) |  | ||||||
|             Mem2 = (fun x -> raise (System.NotImplementedException "Unimplemented mock function")) |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|     interface TypeWithInterface with |  | ||||||
|         member this.Mem1 arg_0_0 = this.Mem1 (arg_0_0) |  | ||||||
|         member this.Mem2 () = this.Mem2 (()) |  | ||||||
|  |  | ||||||
|     interface System.IDisposable with |  | ||||||
|         member this.Dispose () : unit = this.Dispose () |  | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| namespace SomeNamespace | namespace SomeNamespace | ||||||
|  |  | ||||||
| open System |  | ||||||
| open WoofWare.Myriad.Plugins | open WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| [<GenerateMock>] | [<GenerateMock>] | ||||||
| @@ -42,9 +41,3 @@ type Curried<'a> = | |||||||
|     abstract Mem4 : (int * string) -> ('a * int) -> string |     abstract Mem4 : (int * string) -> ('a * int) -> string | ||||||
|     abstract Mem5 : x : int * string -> ('a * int) -> string |     abstract Mem5 : x : int * string -> ('a * int) -> string | ||||||
|     abstract Mem6 : int * string -> y : 'a * int -> string |     abstract Mem6 : int * string -> y : 'a * int -> string | ||||||
|  |  | ||||||
| [<GenerateMock>] |  | ||||||
| type TypeWithInterface = |  | ||||||
|     inherit IDisposable |  | ||||||
|     abstract Mem1 : string option -> string[] Async |  | ||||||
|     abstract Mem2 : unit -> string[] Async |  | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| namespace WoofWare.Myriad.Plugins | namespace WoofWare.Myriad.Plugins | ||||||
|  |  | ||||||
| open System.IO |  | ||||||
| open Fantomas.FCS.Syntax | open Fantomas.FCS.Syntax | ||||||
| open Fantomas.FCS.SyntaxTrivia | open Fantomas.FCS.SyntaxTrivia | ||||||
| open Fantomas.FCS.Text.Range | open Fantomas.FCS.Text.Range | ||||||
| @@ -55,7 +54,6 @@ type internal InterfaceType = | |||||||
|     { |     { | ||||||
|         Attributes : SynAttribute list |         Attributes : SynAttribute list | ||||||
|         Name : LongIdent |         Name : LongIdent | ||||||
|         Inherits : SynType list |  | ||||||
|         Members : MemberInfo list |         Members : MemberInfo list | ||||||
|         Properties : PropertyInfo list |         Properties : PropertyInfo list | ||||||
|         Generics : SynTyparDecls option |         Generics : SynTyparDecls option | ||||||
| @@ -133,11 +131,6 @@ module internal AstHelper = | |||||||
|         // TODO: consider Microsoft.FSharp.Option or whatever it is |         // TODO: consider Microsoft.FSharp.Option or whatever it is | ||||||
|         | _ -> false |         | _ -> false | ||||||
|  |  | ||||||
|     let isUnitIdent (ident : SynLongIdent) : bool = |  | ||||||
|         match ident.LongIdent with |  | ||||||
|         | [ i ] when System.String.Equals (i.idText, "unit", System.StringComparison.OrdinalIgnoreCase) -> true |  | ||||||
|         | _ -> false |  | ||||||
|  |  | ||||||
|     let isListIdent (ident : SynLongIdent) : bool = |     let isListIdent (ident : SynLongIdent) : bool = | ||||||
|         match ident.LongIdent with |         match ident.LongIdent with | ||||||
|         | [ i ] when System.String.Equals (i.idText, "list", System.StringComparison.OrdinalIgnoreCase) -> true |         | [ i ] when System.String.Equals (i.idText, "list", System.StringComparison.OrdinalIgnoreCase) -> true | ||||||
| @@ -349,18 +342,7 @@ module internal AstHelper = | |||||||
|                                 } |                                 } | ||||||
|                                 |> List.singleton |                                 |> List.singleton | ||||||
|                         } |                         } | ||||||
|                     | arg -> |                     | _ -> failwith $"Unrecognised args in interface method declaration: %+A{args}" | ||||||
|                         { |  | ||||||
|                             HasParen = false |  | ||||||
|                             Args = |  | ||||||
|                                 { |  | ||||||
|                                     Attributes = [] |  | ||||||
|                                     IsOptional = false |  | ||||||
|                                     Id = None |  | ||||||
|                                     Type = arg |  | ||||||
|                                 } |  | ||||||
|                                 |> List.singleton |  | ||||||
|                         } |  | ||||||
|                     |> fun ty -> |                     |> fun ty -> | ||||||
|                         { ty with |                         { ty with | ||||||
|                             HasParen = ty.HasParen || hasParen |                             HasParen = ty.HasParen || hasParen | ||||||
| @@ -404,26 +386,22 @@ module internal AstHelper = | |||||||
|  |  | ||||||
|         let attrs = attrs |> List.collect (fun s -> s.Attributes) |         let attrs = attrs |> List.collect (fun s -> s.Attributes) | ||||||
|  |  | ||||||
|         let members, inherits = |         let members, properties = | ||||||
|             match synTypeDefnRepr with |             match synTypeDefnRepr with | ||||||
|             | SynTypeDefnRepr.ObjectModel (_kind, members, _) -> |             | SynTypeDefnRepr.ObjectModel (_kind, members, _) -> | ||||||
|                 members |                 members | ||||||
|                 |> List.map (fun defn -> |                 |> List.map (fun defn -> | ||||||
|                     match defn with |                     match defn with | ||||||
|                     | SynMemberDefn.AbstractSlot (slotSig, flags, _, _) -> Choice1Of2 (parseMember slotSig flags) |                     | SynMemberDefn.AbstractSlot (slotSig, flags, _, _) -> parseMember slotSig flags | ||||||
|                     | SynMemberDefn.Inherit (baseType, _asIdent, _) -> Choice2Of2 baseType |  | ||||||
|                     | _ -> failwith $"Unrecognised member definition: %+A{defn}" |                     | _ -> failwith $"Unrecognised member definition: %+A{defn}" | ||||||
|                 ) |                 ) | ||||||
|             | _ -> failwith $"Unrecognised SynTypeDefnRepr for an interface type: %+A{synTypeDefnRepr}" |             | _ -> failwith $"Unrecognised SynTypeDefnRepr for an interface type: %+A{synTypeDefnRepr}" | ||||||
|             |> List.partitionChoice |             |> List.partitionChoice | ||||||
|  |  | ||||||
|         let members, properties = members |> List.partitionChoice |  | ||||||
|  |  | ||||||
|         { |         { | ||||||
|             Members = members |             Members = members | ||||||
|             Properties = properties |             Properties = properties | ||||||
|             Name = interfaceName |             Name = interfaceName | ||||||
|             Inherits = inherits |  | ||||||
|             Attributes = attrs |             Attributes = attrs | ||||||
|             Generics = typars |             Generics = typars | ||||||
|             Accessibility = accessibility |             Accessibility = accessibility | ||||||
| @@ -508,11 +486,6 @@ module internal SynTypePatterns = | |||||||
|             Some innerType |             Some innerType | ||||||
|         | _ -> None |         | _ -> None | ||||||
|  |  | ||||||
|     let (|UnitType|_|) (fieldType : SynType) : unit option = |  | ||||||
|         match fieldType with |  | ||||||
|         | SynType.LongIdent ident when AstHelper.isUnitIdent ident -> Some () |  | ||||||
|         | _ -> None |  | ||||||
|  |  | ||||||
|     let (|ListType|_|) (fieldType : SynType) = |     let (|ListType|_|) (fieldType : SynType) = | ||||||
|         match fieldType with |         match fieldType with | ||||||
|         | SynType.App (SynType.LongIdent ident, _, [ innerType ], _, _, _, _) when AstHelper.isListIdent ident -> |         | SynType.App (SynType.LongIdent ident, _, [ innerType ], _, _, _, _) when AstHelper.isListIdent ident -> | ||||||
|   | |||||||
| @@ -764,10 +764,6 @@ module internal HttpClientGenerator = | |||||||
|         = |         = | ||||||
|         let interfaceType = AstHelper.parseInterface interfaceType |         let interfaceType = AstHelper.parseInterface interfaceType | ||||||
|  |  | ||||||
|         if not (List.isEmpty interfaceType.Inherits) then |  | ||||||
|             failwith |  | ||||||
|                 "HttpClientGenerator does not support inheritance. Remove the `inherit` keyword if you want to use this generator." |  | ||||||
|  |  | ||||||
|         let constantHeaders = |         let constantHeaders = | ||||||
|             interfaceType.Attributes |             interfaceType.Attributes | ||||||
|             |> extractHeaderInformation |             |> extractHeaderInformation | ||||||
|   | |||||||
| @@ -21,9 +21,6 @@ module internal InterfaceMockGenerator = | |||||||
|         | None -> failwith "Expected record field to have a name, but it was somehow anonymous" |         | None -> failwith "Expected record field to have a name, but it was somehow anonymous" | ||||||
|         | Some id -> id |         | Some id -> id | ||||||
|  |  | ||||||
|     [<RequireQualifiedAccess>] |  | ||||||
|     type private KnownInheritance = | IDisposable |  | ||||||
|  |  | ||||||
|     let createType |     let createType | ||||||
|         (spec : GenerateMockOutputSpec) |         (spec : GenerateMockOutputSpec) | ||||||
|         (name : string) |         (name : string) | ||||||
| @@ -32,20 +29,6 @@ module internal InterfaceMockGenerator = | |||||||
|         (fields : SynField list) |         (fields : SynField list) | ||||||
|         : SynModuleDecl |         : SynModuleDecl | ||||||
|         = |         = | ||||||
|         let inherits = |  | ||||||
|             interfaceType.Inherits |  | ||||||
|             |> Seq.map (fun ty -> |  | ||||||
|                 match ty with |  | ||||||
|                 | SynType.LongIdent (SynLongIdent.SynLongIdent (name, _, _)) -> |  | ||||||
|                     match name |> List.map _.idText with |  | ||||||
|                     | [] -> failwith "Unexpected empty identifier in inheritance declaration" |  | ||||||
|                     | [ "IDisposable" ] |  | ||||||
|                     | [ "System" ; "IDisposable" ] -> KnownInheritance.IDisposable |  | ||||||
|                     | _ -> failwithf "Unrecognised inheritance identifier: %+A" name |  | ||||||
|                 | x -> failwithf "Unrecognised type in inheritance: %+A" x |  | ||||||
|             ) |  | ||||||
|             |> Set.ofSeq |  | ||||||
|  |  | ||||||
|         let synValData = |         let synValData = | ||||||
|             { |             { | ||||||
|                 SynMemberFlags.IsInstance = false |                 SynMemberFlags.IsInstance = false | ||||||
| @@ -107,23 +90,6 @@ module internal InterfaceMockGenerator = | |||||||
|                 ) |                 ) | ||||||
|             |> SynBindingReturnInfo.Create |             |> SynBindingReturnInfo.Create | ||||||
|  |  | ||||||
|         let constructorFields = |  | ||||||
|             let extras = |  | ||||||
|                 if inherits.Contains KnownInheritance.IDisposable then |  | ||||||
|                     let unitFun = SynExpr.createLambda "_" SynExpr.CreateUnit |  | ||||||
|  |  | ||||||
|                     [ |  | ||||||
|                         (SynLongIdent.CreateFromLongIdent [ Ident.Create "Dispose" ], true), Some unitFun |  | ||||||
|                     ] |  | ||||||
|                 else |  | ||||||
|                     [] |  | ||||||
|  |  | ||||||
|             let nonExtras = |  | ||||||
|                 fields |  | ||||||
|                 |> List.map (fun field -> (SynLongIdent.CreateFromLongIdent [ getName field ], true), Some failwithFun) |  | ||||||
|  |  | ||||||
|             extras @ nonExtras |  | ||||||
|  |  | ||||||
|         let constructor = |         let constructor = | ||||||
|             SynMemberDefn.Member ( |             SynMemberDefn.Member ( | ||||||
|                 SynBinding.SynBinding ( |                 SynBinding.SynBinding ( | ||||||
| @@ -136,7 +102,12 @@ module internal InterfaceMockGenerator = | |||||||
|                     SynValData.SynValData (Some synValData, SynValInfo.Empty, None), |                     SynValData.SynValData (Some synValData, SynValInfo.Empty, None), | ||||||
|                     constructorIdent, |                     constructorIdent, | ||||||
|                     Some constructorReturnType, |                     Some constructorReturnType, | ||||||
|                     AstHelper.instantiateRecord constructorFields, |                     AstHelper.instantiateRecord ( | ||||||
|  |                         fields | ||||||
|  |                         |> List.map (fun field -> | ||||||
|  |                             ((SynLongIdent.CreateFromLongIdent [ getName field ], true), Some failwithFun) | ||||||
|  |                         ) | ||||||
|  |                     ), | ||||||
|                     range0, |                     range0, | ||||||
|                     DebugPointAtBinding.Yes range0, |                     DebugPointAtBinding.Yes range0, | ||||||
|                     { SynExpr.synBindingTriviaZero true with |                     { SynExpr.synBindingTriviaZero true with | ||||||
| @@ -146,21 +117,6 @@ module internal InterfaceMockGenerator = | |||||||
|                 range0 |                 range0 | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|         let fields = |  | ||||||
|             let extras = |  | ||||||
|                 if inherits.Contains KnownInheritance.IDisposable then |  | ||||||
|                     [ |  | ||||||
|                         SynField.Create ( |  | ||||||
|                             SynType.CreateFun (SynType.CreateUnit, SynType.CreateUnit), |  | ||||||
|                             Ident.Create "Dispose", |  | ||||||
|                             xmldoc = PreXmlDoc.Create " Implementation of IDisposable.Dispose" |  | ||||||
|                         ) |  | ||||||
|                     ] |  | ||||||
|                 else |  | ||||||
|                     [] |  | ||||||
|  |  | ||||||
|             extras @ fields |  | ||||||
|  |  | ||||||
|         let interfaceMembers = |         let interfaceMembers = | ||||||
|             let members = |             let members = | ||||||
|                 interfaceType.Members |                 interfaceType.Members | ||||||
| @@ -194,9 +150,7 @@ module internal InterfaceMockGenerator = | |||||||
|                                                 |> List.mapi (fun i arg -> |                                                 |> List.mapi (fun i arg -> | ||||||
|                                                     arg.Args |                                                     arg.Args | ||||||
|                                                     |> List.mapi (fun j arg -> |                                                     |> List.mapi (fun j arg -> | ||||||
|                                                         match arg.Type with |                                                         SynArgInfo.CreateIdString $"arg_%i{i}_%i{j}" | ||||||
|                                                         | UnitType -> SynArgInfo.SynArgInfo ([], false, None) |  | ||||||
|                                                         | _ -> SynArgInfo.CreateIdString $"arg_%i{i}_%i{j}" |  | ||||||
|                                                     ) |                                                     ) | ||||||
|                                                 ) |                                                 ) | ||||||
|                                         ], |                                         ], | ||||||
| @@ -211,18 +165,10 @@ module internal InterfaceMockGenerator = | |||||||
|                         |> List.mapi (fun i tupledArgs -> |                         |> List.mapi (fun i tupledArgs -> | ||||||
|                             let args = |                             let args = | ||||||
|                                 tupledArgs.Args |                                 tupledArgs.Args | ||||||
|                                 |> List.mapi (fun j ty -> |                                 |> List.mapi (fun j _ -> SynPat.CreateNamed (Ident.Create $"arg_%i{i}_%i{j}")) | ||||||
|                                     match ty.Type with |  | ||||||
|                                     | UnitType -> SynPat.Const (SynConst.Unit, range0) |  | ||||||
|                                     | _ -> SynPat.CreateNamed (Ident.Create $"arg_%i{i}_%i{j}") |  | ||||||
|                                 ) |  | ||||||
|  |  | ||||||
|                             match args with |                             SynPat.Tuple (false, args, List.replicate (args.Length - 1) range0, range0) | ||||||
|                             | [] -> failwith "somehow got no args at all" |                             |> SynPat.CreateParen | ||||||
|                             | [ arg ] -> arg |  | ||||||
|                             | args -> |  | ||||||
|                                 SynPat.Tuple (false, args, List.replicate (args.Length - 1) range0, range0) |  | ||||||
|                                 |> SynPat.CreateParen |  | ||||||
|                             |> fun i -> if tupledArgs.HasParen then SynPat.Paren (i, range0) else i |                             |> fun i -> if tupledArgs.HasParen then SynPat.Paren (i, range0) else i | ||||||
|                         ) |                         ) | ||||||
|  |  | ||||||
| @@ -241,11 +187,7 @@ module internal InterfaceMockGenerator = | |||||||
|                             memberInfo.Args |                             memberInfo.Args | ||||||
|                             |> List.mapi (fun i args -> |                             |> List.mapi (fun i args -> | ||||||
|                                 args.Args |                                 args.Args | ||||||
|                                 |> List.mapi (fun j arg -> |                                 |> List.mapi (fun j args -> SynExpr.CreateIdentString $"arg_%i{i}_%i{j}") | ||||||
|                                     match arg.Type with |  | ||||||
|                                     | UnitType -> SynExpr.CreateConst SynConst.Unit |  | ||||||
|                                     | _ -> SynExpr.CreateIdentString $"arg_%i{i}_%i{j}" |  | ||||||
|                                 ) |  | ||||||
|                                 |> SynExpr.CreateParenedTuple |                                 |> SynExpr.CreateParenedTuple | ||||||
|                             ) |                             ) | ||||||
|  |  | ||||||
| @@ -322,100 +264,11 @@ module internal InterfaceMockGenerator = | |||||||
|             | Some (SynAccess.Internal _), _ -> SynAccess.Internal range0 |             | Some (SynAccess.Internal _), _ -> SynAccess.Internal range0 | ||||||
|             | Some (SynAccess.Private _), _ -> SynAccess.Private range0 |             | Some (SynAccess.Private _), _ -> SynAccess.Private range0 | ||||||
|  |  | ||||||
|         let extraInterfaces = |  | ||||||
|             inherits |  | ||||||
|             |> Seq.map (fun inheritance -> |  | ||||||
|                 match inheritance with |  | ||||||
|                 | KnownInheritance.IDisposable -> |  | ||||||
|                     let valData = |  | ||||||
|                         SynValData.SynValData ( |  | ||||||
|                             Some |  | ||||||
|                                 { |  | ||||||
|                                     IsInstance = true |  | ||||||
|                                     IsDispatchSlot = false |  | ||||||
|                                     IsOverrideOrExplicitImpl = true |  | ||||||
|                                     IsFinal = false |  | ||||||
|                                     GetterOrSetterIsCompilerGenerated = false |  | ||||||
|                                     MemberKind = SynMemberKind.Member |  | ||||||
|                                 }, |  | ||||||
|                             valInfo = |  | ||||||
|                                 SynValInfo.SynValInfo ( |  | ||||||
|                                     curriedArgInfos = |  | ||||||
|                                         [ |  | ||||||
|                                             yield |  | ||||||
|                                                 [ |  | ||||||
|                                                     SynArgInfo.SynArgInfo ( |  | ||||||
|                                                         attributes = [], |  | ||||||
|                                                         optional = false, |  | ||||||
|                                                         ident = None |  | ||||||
|                                                     ) |  | ||||||
|                                                 ] |  | ||||||
|                                         ], |  | ||||||
|                                     returnInfo = |  | ||||||
|                                         SynArgInfo.SynArgInfo (attributes = [], optional = false, ident = None) |  | ||||||
|                                 ), |  | ||||||
|                             thisIdOpt = None |  | ||||||
|                         ) |  | ||||||
|  |  | ||||||
|                     let headArgs = [ SynPat.Const (SynConst.Unit, range0) ] |  | ||||||
|  |  | ||||||
|                     let headPat = |  | ||||||
|                         SynPat.LongIdent ( |  | ||||||
|                             SynLongIdent.CreateFromLongIdent [ Ident.Create "this" ; Ident.Create "Dispose" ], |  | ||||||
|                             None, |  | ||||||
|                             None, |  | ||||||
|                             SynArgPats.Pats headArgs, |  | ||||||
|                             None, |  | ||||||
|                             range0 |  | ||||||
|                         ) |  | ||||||
|  |  | ||||||
|                     let binding = |  | ||||||
|                         SynBinding.SynBinding ( |  | ||||||
|                             None, |  | ||||||
|                             SynBindingKind.Normal, |  | ||||||
|                             false, |  | ||||||
|                             false, |  | ||||||
|                             [], |  | ||||||
|                             PreXmlDoc.Empty, |  | ||||||
|                             valData, |  | ||||||
|                             headPat, |  | ||||||
|                             Some ( |  | ||||||
|                                 SynBindingReturnInfo.SynBindingReturnInfo ( |  | ||||||
|                                     SynType.Unit (), |  | ||||||
|                                     range0, |  | ||||||
|                                     [], |  | ||||||
|                                     SynBindingReturnInfoTrivia.Zero |  | ||||||
|                                 ) |  | ||||||
|                             ), |  | ||||||
|                             SynExpr.CreateApp ( |  | ||||||
|                                 SynExpr.CreateLongIdent (SynLongIdent.Create [ "this" ; "Dispose" ]), |  | ||||||
|                                 SynExpr.CreateUnit |  | ||||||
|                             ), |  | ||||||
|                             range0, |  | ||||||
|                             DebugPointAtBinding.Yes range0, |  | ||||||
|                             { |  | ||||||
|                                 LeadingKeyword = SynLeadingKeyword.Member range0 |  | ||||||
|                                 InlineKeyword = None |  | ||||||
|                                 EqualsRange = Some range0 |  | ||||||
|                             } |  | ||||||
|                         ) |  | ||||||
|  |  | ||||||
|                     let mem = SynMemberDefn.Member (binding, range0) |  | ||||||
|  |  | ||||||
|                     SynMemberDefn.Interface ( |  | ||||||
|                         SynType.CreateLongIdent (SynLongIdent.Create [ "System" ; "IDisposable" ]), |  | ||||||
|                         Some range0, |  | ||||||
|                         Some [ mem ], |  | ||||||
|                         range0 |  | ||||||
|                     ) |  | ||||||
|             ) |  | ||||||
|             |> Seq.toList |  | ||||||
|  |  | ||||||
|         let record = |         let record = | ||||||
|             { |             { | ||||||
|                 Name = Ident.Create name |                 Name = Ident.Create name | ||||||
|                 Fields = fields |                 Fields = fields | ||||||
|                 Members = Some ([ constructor ; interfaceMembers ] @ extraInterfaces) |                 Members = Some [ constructor ; interfaceMembers ] | ||||||
|                 XmlDoc = Some xmlDoc |                 XmlDoc = Some xmlDoc | ||||||
|                 Generics = interfaceType.Generics |                 Generics = interfaceType.Generics | ||||||
|                 Accessibility = Some access |                 Accessibility = Some access | ||||||
| @@ -480,6 +333,7 @@ module internal InterfaceMockGenerator = | |||||||
|  |  | ||||||
|         let typeDecl = createType spec name interfaceType docString fields |         let typeDecl = createType spec name interfaceType docString fields | ||||||
|  |  | ||||||
|  |  | ||||||
|         SynModuleOrNamespace.CreateNamespace ( |         SynModuleOrNamespace.CreateNamespace ( | ||||||
|             namespaceId, |             namespaceId, | ||||||
|             decls = (opens |> List.map SynModuleDecl.CreateOpen) @ [ typeDecl ] |             decls = (opens |> List.map SynModuleDecl.CreateOpen) @ [ typeDecl ] | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ | |||||||
|   }) |   }) | ||||||
|   (fetchNuGet { |   (fetchNuGet { | ||||||
|     pname = "fantomas"; |     pname = "fantomas"; | ||||||
|     version = "6.3.3"; |     version = "6.3.0-alpha-008"; | ||||||
|     sha256 = "sha256-02uTwRPJkRZtjJ7fOJdHSvc17DszkXjT5X9jGuRZlA4="; |     sha256 = "sha256-rI/4upuj8JBy2C9gl2lwI/JXmBD7UHKxCoSpd+bstRw="; | ||||||
|   }) |   }) | ||||||
|   (fetchNuGet { |   (fetchNuGet { | ||||||
|     pname = "ApiSurface"; |     pname = "ApiSurface"; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user