diff --git a/FSharp.Interop.Dynamic/Dyn.fs b/FSharp.Interop.Dynamic/Dyn.fs index 99bd6b1..03d8dec 100644 --- a/FSharp.Interop.Dynamic/Dyn.fs +++ b/FSharp.Interop.Dynamic/Dyn.fs @@ -11,14 +11,13 @@ // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and -// limitations under the License. - - +// limitations under the License. + namespace FSharp.Interop.Dynamic open System -type Calling = - | GenericMember of string * Type array +type Calling = + | GenericMember of string * Type array | Member of string | Direct @@ -30,35 +29,31 @@ module Dyn = let staticContext (target:Type) = InvokeContext.CreateStatic.Invoke(target) let staticTarget<'TTarget> = InvokeContext.CreateStatic.Invoke(typeof<'TTarget>) - - let implicitConvertTo (convertType:Type) (target:obj) : 'TResult = - match target with + + let implicitConvertTo (convertType:Type) (target:obj) : 'TResult = + match target with | null -> target - | t -> Dynamic.InvokeConvert(t, convertType, explicit = false) - |> unbox<'TResult> - - + | t -> Dynamic.InvokeConvert(t, convertType, explicit = false) + |> unbox<'TResult> + let implicitConvert(target:obj) : 'TResult = - implicitConvertTo typeof<'TResult> target - - - let explicitConvertTo (convertType:Type) (target:obj) : 'TResult = + implicitConvertTo typeof<'TResult> target + + let explicitConvertTo (convertType:Type) (target:obj) : 'TResult = Dynamic.InvokeConvert(target, convertType, explicit = true) |> unbox<'TResult> - let explicitConvert (target:obj) : 'TResult = + let explicitConvert (target:obj) : 'TResult = explicitConvertTo typeof<'TResult> target let namedArg (name:string) (argValue:obj) = InvokeArg(name, argValue) let memberAddAssign (memberName:string) (value:obj) (target:obj) = - Dynamic.InvokeAddAssignMember(target, memberName, value) - - + Dynamic.InvokeAddAssignMember(target, memberName, value) + let memberSubtractAssign (memberName:string) (value:obj) (target:obj) = - Dynamic.InvokeSubtractAssignMember(target, memberName, value) - - + Dynamic.InvokeSubtractAssignMember(target, memberName, value) + let invocation (target:obj) (memberName:Calling) : 'TResult = let resultType = typeof<'TResult> //Helper to dynamically call call FSharpFuncs @@ -70,12 +65,12 @@ module Dyn = | Member name -> Dynamic.InvokeGet(target', name) | Direct -> target' Dynamic.InvokeMember(invokeContext(start), invokeName, [|arg'|]) - let (|NoConversion| Conversion|) t = + let (|NoConversion| Conversion|) t = if t = typeof then NoConversion else Conversion - let finalConvertResult finalType result :'TResult = + let finalConvertResult finalType result :'TResult = match finalType with | x when FSharpType.IsFunction x -> // if return type is a function - let rec curriedLambda target type' arg' = + let rec curriedLambda target type' arg' = let result' = fsharpInvoke target Direct arg' let _,retType = FSharpType.GetFunctionElements type' if FSharpType.IsFunction retType then @@ -101,11 +96,11 @@ module Dyn = | a when FSharpType.IsTuple(a) -> FSharpValue.GetTupleFields(arg) | a when a = typeof -> [| |] | ____________________________ -> [|arg|] - let invoker k = + let invoker k = let memberName = memberName |> function | GenericMember (name, targs) -> InvokeMemberName(name, targs) - | Member name -> + | Member name -> InvokeMemberName(name, null) | Direct -> null Invocation(k, memberName).Invoke(target, argArray) @@ -136,13 +131,11 @@ module Dyn = FSharpValue.MakeFunction(resultType, lambda) |> unbox<'TResult> let invokeDirect value (target:obj) : 'TResult = - invocation target Direct value - - + invocation target Direct value + let invokeMember (memberName:string) value (target:obj) : 'TResult = - invocation target (Member memberName) value - - + invocation target (Member memberName) value + let invokeGeneric (memberName:string) (typeArgs:Type seq) value (target:obj) : 'TResult = let typeArgs' = typeArgs |> Array.ofSeq let genericMember = GenericMember (memberName, typeArgs') @@ -184,7 +177,7 @@ module Dyn = Dynamic.InvokeSet(target, propertyName, value) |> ignore let setChain (chainOfMembers: string seq) (value:obj) (target:obj) = - let chainOfMembers' = String.concat "." chainOfMembers + let chainOfMembers' = String.concat "." chainOfMembers Dynamic.InvokeSetChain(target, chainOfMembers', value) |> ignore /// dynamically call set index @@ -203,7 +196,7 @@ module Dyn = [] let addAssignMember (target:obj) (memberName:string) (value:obj) = target |> memberAddAssign memberName value - + [] let subtractAssignMember (target:obj) (memberName:string) (value:obj) = target |> memberSubtractAssign memberName value diff --git a/FSharp.Interop.Dynamic/Dyn.fsi b/FSharp.Interop.Dynamic/Dyn.fsi index dc0240e..2c5302d 100644 --- a/FSharp.Interop.Dynamic/Dyn.fsi +++ b/FSharp.Interop.Dynamic/Dyn.fsi @@ -7,7 +7,7 @@ namespace FSharp.Interop.Dynamic | Member of string /// Invoke the target itself, not a named member. | Direct - + /// /// Function surface behind the operators. Use when you want piping, a name as data, or an operation ? does not spell. Target is last on most members so target |> Dyn.get "Name" works; invocation is the exception. /// @@ -118,4 +118,4 @@ namespace FSharp.Interop.Dynamic /// Obsolete. Use invocation with Member or Direct instead of Some name or None. [] val invoke : target:obj -> memberName:string option -> 'TResult - end + end \ No newline at end of file diff --git a/FSharp.Interop.Dynamic/Operators.fs b/FSharp.Interop.Dynamic/Operators.fs index 659a5b8..29c45a2 100644 --- a/FSharp.Interop.Dynamic/Operators.fs +++ b/FSharp.Interop.Dynamic/Operators.fs @@ -3,52 +3,50 @@ namespace FSharp.Interop.Dynamic module Operators= open Dynamitey open System.Linq.Expressions - let (?%?) (left:obj) (right: obj) : 'TResult = + let (?%?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Modulo, right)) :?> 'TResult - - let (?*?) (left:obj) (right: obj) : 'TResult = + + let (?*?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Multiply, right)) :?> 'TResult - let (?+?) (left:obj) (right: obj) : 'TResult = + let (?+?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Add, right)) :?> 'TResult - - let (?-?) (left:obj) (right: obj) : 'TResult = + + let (?-?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Subtract, right)) :?> 'TResult - let (?/?) (left:obj) (right: obj) : 'TResult = + let (?/?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Divide, right)) :?> 'TResult - let (?&&&?) (left:obj) (right: obj) : 'TResult = + let (?&&&?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.And, right)) :?> 'TResult - let (?|||?) (left:obj) (right: obj) : 'TResult = + let (?|||?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.Or, right)) :?> 'TResult - let (?^^^?) (left:obj) (right: obj) : 'TResult = + let (?^^^?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.ExclusiveOr, right)) :?> 'TResult - let (?<< 'TResult - let (?>>>?) (left:obj) (right: obj) : 'TResult = + let (?>>>?) (left:obj) (right: obj) : 'TResult = (Dynamic.InvokeBinaryOperator(left, ExpressionType.RightShift, right)) :?> 'TResult - let (?<=?) (left:obj) (right: obj) : bool = + let (?<=?) (left:obj) (right: obj) : bool = Dynamic.InvokeBinaryOperator(left, ExpressionType.LessThanOrEqual, right) |> Dyn.explicitConvert - let (?<>?) (left:obj) (right: obj) : bool = + let (?<>?) (left:obj) (right: obj) : bool = Dynamic.InvokeBinaryOperator(left, ExpressionType.NotEqual, right) |> Dyn.explicitConvert - let (? Dyn.explicitConvert - let (?=?) (left:obj) (right: obj) : bool = + let (?=?) (left:obj) (right: obj) : bool = Dynamic.InvokeBinaryOperator(left, ExpressionType.Equal, right) |> Dyn.explicitConvert - let (?>?) (left:obj) (right: obj) : bool = + let (?>?) (left:obj) (right: obj) : bool = Dynamic.InvokeBinaryOperator(left, ExpressionType.GreaterThan, right) |> Dyn.explicitConvert - let (?>=?) (left:obj) (right: obj) : bool = - Dynamic.InvokeBinaryOperator(left, ExpressionType.GreaterThanOrEqual, right) |> Dyn.explicitConvert - - \ No newline at end of file + let (?>=?) (left:obj) (right: obj) : bool = + Dynamic.InvokeBinaryOperator(left, ExpressionType.GreaterThanOrEqual, right) |> Dyn.explicitConvert \ No newline at end of file diff --git a/FSharp.Interop.Dynamic/Operators.fsi b/FSharp.Interop.Dynamic/Operators.fsi index af99820..2af9704 100644 --- a/FSharp.Interop.Dynamic/Operators.fsi +++ b/FSharp.Interop.Dynamic/Operators.fsi @@ -35,4 +35,4 @@ namespace FSharp.Interop.Dynamic val ( ?>? ) : left:obj -> right:obj -> bool /// Dynamically compare whether is greater than or equal to . Converts the DLR result to bool. val ( ?>=? ) : left:obj -> right:obj -> bool - end + end \ No newline at end of file diff --git a/FSharp.Interop.Dynamic/SymbolicString.fs b/FSharp.Interop.Dynamic/SymbolicString.fs index b5b0d3d..0f6ef46 100644 --- a/FSharp.Interop.Dynamic/SymbolicString.fs +++ b/FSharp.Interop.Dynamic/SymbolicString.fs @@ -9,9 +9,9 @@ module SymbolicString = /// Typed hole for quotations only. Do not evaluate; calling it throws. let sym<'TTarget> : 'TTarget = failwith "don't call the sym function, meant for quotations only!" - + /// Name, return type, and optional declaring type of a quoted leaf. - type LeafInfo = + type LeafInfo = { /// Return type of the quoted leaf. ReturnType : System.Type /// Member, union-case, or value name of the quoted leaf. @@ -19,7 +19,7 @@ module SymbolicString = /// Declaring type when the leaf is a member, field, union case, or call; None for a named value. DeclaringType: System.Type option } - + /// Extracts name and type information from an F# quotation of a member, union case, or value. type Symbol = @@ -31,9 +31,9 @@ module SymbolicString = static member leafInfoOf([] value:Expr<'T>) : LeafInfo = let rec finalName value' = match value' with - | ValueWithName(_, type', name) -> + | ValueWithName(_, type', name) -> { ReturnType= type'; Name= name; DeclaringType = None } - | NewUnionCase(caseInfo, _) -> + | NewUnionCase(caseInfo, _) -> { ReturnType= caseInfo.DeclaringType Name= caseInfo.Name DeclaringType= Some <| caseInfo.DeclaringType } @@ -53,10 +53,9 @@ module SymbolicString = | Let(_,_, expr) -> finalName expr | ________________________________ -> invalidArg "value" (sprintf "Couldn't figure out how to make '%A' a name" value) finalName value - + /// Member, union-case, or value name of the quoted leaf. static member nameOf([] value:Expr<'T>) : string = (value |> Symbol.leafInfoOf).Name - + /// Return type of the quoted leaf. - static member typeOf([] value:Expr<'T>) : System.Type = (value |> Symbol.leafInfoOf).ReturnType - \ No newline at end of file + static member typeOf([] value:Expr<'T>) : System.Type = (value |> Symbol.leafInfoOf).ReturnType \ No newline at end of file diff --git a/FSharp.Interop.Dynamic/TopLevelOperators.fs b/FSharp.Interop.Dynamic/TopLevelOperators.fs index fcb52fc..a6c7a16 100644 --- a/FSharp.Interop.Dynamic/TopLevelOperators.fs +++ b/FSharp.Interop.Dynamic/TopLevelOperators.fs @@ -13,9 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace FSharp.Interop.Dynamic - - +namespace FSharp.Interop.Dynamic + [] module TopLevelOperators= let (?) (target : obj) (name:string) : 'TResult = @@ -25,4 +24,4 @@ module TopLevelOperators= target |> Dyn.set name value let (!?) (target:obj) : 'TResult = - Dyn.invocation target Direct + Dyn.invocation target Direct \ No newline at end of file diff --git a/FSharp.Interop.Dynamic/TopLevelOperators.fsi b/FSharp.Interop.Dynamic/TopLevelOperators.fsi index bcd4196..4516105 100644 --- a/FSharp.Interop.Dynamic/TopLevelOperators.fsi +++ b/FSharp.Interop.Dynamic/TopLevelOperators.fsi @@ -33,4 +33,4 @@ namespace FSharp.Interop.Dynamic /// . /// val ( !? ) : target:obj -> 'TResult - end + end \ No newline at end of file diff --git a/Tests/Invocation.fs b/Tests/Invocation.fs index d48228a..4f1568f 100644 --- a/Tests/Invocation.fs +++ b/Tests/Invocation.fs @@ -137,4 +137,4 @@ module Invocation = [] let ``a throwing getter is not wrapped after a binder failure`` () = (fun () -> PropThrows() |> Dyn.invokeMember "Bad" () |> ignore) - |> should throw typeof + |> should throw typeof \ No newline at end of file diff --git a/Tests/Library1.fs b/Tests/Library1.fs index 4965a05..16a466c 100644 --- a/Tests/Library1.fs +++ b/Tests/Library1.fs @@ -1,5 +1,4 @@ - -(** +(** # Examples of using Dynamic operator and Functions *) namespace Tests @@ -24,9 +23,8 @@ type TestEvent()= [] member __.Event = event1.Publish member __.OnEvent(obj:Object, args:EventArgs)= - event1.Trigger(obj,args) - - + event1.Trigger(obj,args) + (***hide***) type TestFuncs()= static member Plus3:Func = @@ -49,18 +47,15 @@ type DynamicWeirdFlakyIndexer()= override __.TrySetIndex(_, indexes, value) = stuff.Add((indexes.[0], indexes.[1]),value) true - -module Tests = - - - - + +module Tests = + (** Call a method with dlr (ideally you wouldn't know it was as a string). *) [] let ``Call method off of an object dynamically`` ()= - "HelloWorld"?Substring(0,5) + "HelloWorld"?Substring(0,5) |> should equal "Hello" (** Call a method with a variable (ideally you wouldn't know it was as a string). @@ -68,7 +63,7 @@ Call a method with a variable (ideally you wouldn't know it was as a string). [] let ``Call method off of an object dynamically with variable`` ()= let method = "Substring" - "HelloWorld"?(method)(0,5) + "HelloWorld"?(method)(0,5) |> should equal "Hello" (** Set a property with dlr, Expando only responds to the dlr. @@ -132,7 +127,7 @@ Set a property with dlr, Expando only responds to the dlr. [] let ``Test FSharp Lambda 4 arg`` ()= let dyn = (fun x y z bbq -> x + y - z - bbq) :> obj in - let x = !?dyn 3 2 1 5 + let x = !?dyn 3 2 1 5 x |> should equal -1 (***hide***) @@ -140,7 +135,7 @@ Set a property with dlr, Expando only responds to the dlr. let ``Test FSharp Lambda 5 arg`` ()= let unknownfunc = (fun x y z bbq etc -> x + y - z - bbq + etc) :> obj in let go = !?unknownfunc - let x = go 3 2 1 5 9 + let x = go 3 2 1 5 9 x |> should equal 8 (***hide***) @@ -161,7 +156,7 @@ Set a property with dlr, Expando only responds to the dlr. !refBool |> should equal false (** -`!?` will invoke without a name, dynamic function or the like. +`!?` will invoke without a name, dynamic function or the like. `Dyn.namedArg` allows you to wrap your arguments with names as part of the invocation. *) [] @@ -206,14 +201,13 @@ Use the dlr to call the implicit operator with inferred type from usage let ``Test Implicit Conversion`` ()= let ele = 50 let actual:decimal = ele |> Dyn.implicitConvert - actual |> should equal 50m - - + actual |> should equal 50m + (***hide***) [] let ``Test Implicit Conversion Fail`` ()= let ele = XElement(XName.Get("Test"),"50") - (fun () -> Dyn.implicitConvert(ele) = 50 |> ignore) + (fun () -> Dyn.implicitConvert(ele) = 50 |> ignore) |> should throw typeof (***hide***) @@ -228,7 +222,7 @@ Use the dlr to call the implicit operator with inferred type from usage archive |> Dyn.getIndexer [1; 5] |> should equal "A" archive |> Dyn.getIndexer ["Hello"; "World" ] |> should equal "B" archive |> Dyn.getIndexer [box 1; box "World"] |> should equal "C" - + (***hide***) [] let ``Basic Operator Mock Tests`` ()= @@ -255,31 +249,31 @@ Use operators dynamically (better without knowing the types). 5 ?+? 4 |> should equal 9 5 ?-? 3 |> should equal 2 15 ?/? 5 |> should equal 3 - + 5 ?&&&? 3 |> should equal 1 5 ?|||? 3 |> should equal 7 5 ?^^^? 3 |> should equal 6 23 ?<< should equal 92 (-105) ?>>>? 1 |> should equal (-53) - + 10 ?<=? 5 |> should equal false 5 ?<=? 10 |> should equal true 10 ?<=? 10 |> should equal true - + 10 ?>=? 5 |> should equal true 5 ?>=? 10 |> should equal false 10 ?>=? 10 |> should equal true - + 10 ? should equal false 5 ? should equal true 10 ? should equal false - + 10 ?>? 5 |> should equal true 5 ?>? 10 |> should equal false 10 ?>? 10 |> should equal false - + 10 ?<>? 5 |> should equal true 10 ?<>? 10 |> should equal false - + 10 ?=? 5 |> should equal false - 10 ?=? 10 |> should equal true + 10 ?=? 10 |> should equal true \ No newline at end of file diff --git a/Tests/Obsolete.fs b/Tests/Obsolete.fs index e7bb9b4..669b758 100644 --- a/Tests/Obsolete.fs +++ b/Tests/Obsolete.fs @@ -5,7 +5,7 @@ open Xunit open FsUnit.Xunit open Tests open System - + #nowarn "44" module Obsolete = @@ -41,5 +41,5 @@ module Obsolete = [] let ``Call method off of an object dynamically with variable`` ()= let method = "Substring" - Dyn.invoke "HelloWorld" (Some method) (0,5) - |> should equal "Hello" + Dyn.invoke "HelloWorld" (Some method) (0,5) + |> should equal "Hello" \ No newline at end of file diff --git a/Tests/OperatorValues.fs b/Tests/OperatorValues.fs index 74c84a5..c19350a 100644 --- a/Tests/OperatorValues.fs +++ b/Tests/OperatorValues.fs @@ -32,4 +32,4 @@ module OperatorValues = [] let ``dynamic divide by zero raises the runtime divide-by-zero`` () = (fun () -> 1 ?/? 0 |> ignore) - |> should throw typeof + |> should throw typeof \ No newline at end of file diff --git a/Tests/Properties.fs b/Tests/Properties.fs index 718886b..9c9de0d 100644 --- a/Tests/Properties.fs +++ b/Tests/Properties.fs @@ -48,4 +48,4 @@ module Properties = check (fun (NonNull (probe: string)) -> let o = Clr() let found: string option = o |> Dyn.tryGet probe - if probe = "Name" then found = Some "Ada" else found = None) + if probe = "Name" then found = Some "Ada" else found = None) \ No newline at end of file diff --git a/Tests/Quotations.fs b/Tests/Quotations.fs index ef684c0..eaf6c5d 100644 --- a/Tests/Quotations.fs +++ b/Tests/Quotations.fs @@ -30,4 +30,4 @@ module Quotations = [] let ``typeOf matches nameOf's rejection of an unnamed expression`` () = (fun () -> Symbol.typeOf(1) |> ignore) - |> should throw typeof + |> should throw typeof \ No newline at end of file diff --git a/Tests/Raw.fs b/Tests/Raw.fs index 113a382..a204068 100644 --- a/Tests/Raw.fs +++ b/Tests/Raw.fs @@ -8,46 +8,44 @@ open FsUnit.Xunit open System.Linq open System open System.Collections.Generic -open System.Dynamic - - +open System.Dynamic + type FieldObj (i:int) as this= [] val mutable Field : int - do + do this.Field<- i module Raw = open System.Collections - [] + [] let ``Name of Field`` ()= let fieldName = Symbol.nameOf(sym.Field) fieldName |> should equal "Field" let target = FieldObj(7) - target |> Dyn.get fieldName |> should equal 7 - - - [] + target |> Dyn.get fieldName |> should equal 7 + + [] let ``Name of Call`` ()= Symbol.nameOf(sym.Substring(0,0)) |> should equal "Substring" Symbol.typeOf(sym.Substring(0,0)) |> should equal typeof - + [] let ``Name of unapplied method`` ()= Symbol.nameOf(sym.Substring) |> should equal "Substring" Symbol.typeOf(sym.Substring) |> should equal typeof - + [] let ``Name of get`` ()= Symbol.nameOf(sym.Length) |> should equal "Length" Symbol.typeOf(sym.Length) |> should equal typeof - + [] let ``Name of end of chain`` ()= Symbol.nameOf(sym.Length.CompareTo) |> should equal "CompareTo" Symbol.typeOf(sym.Length.CompareTo) |> should equal typeof - + [] let ``Name of End of chain overload`` ()= Symbol.nameOf(sym.Length.ToString(sym)) |> should equal "ToString" @@ -74,28 +72,28 @@ module Raw = [] let ``Call method off of an object dynamically`` ()= let name = Symbol.nameOf(sym.Substring(0,0)) - let actual = "HelloWorld" |> Dyn.invokeMember name (0,5) + let actual = "HelloWorld" |> Dyn.invokeMember name (0,5) actual |> should equal "Hello" - + [] let ``implicit convert null`` () = let actual:string = (null |> Dyn.implicitConvertTo typeof) actual |> should equal null - + [] let ``implicit convert null option`` () = let actual:string option = (null |> Dyn.implicitConvertTo typeof) - actual |> should equal None + actual |> should equal None [] let ``implicit convert null fail`` () = let actual ():int = null |> Dyn.implicitConvertTo typeof - actual >> ignore |> shouldFail - + actual >> ignore |> shouldFail + [] let ``implicit convert null fail fsharp type`` () = let actual ():Calling = (null |> Dyn.implicitConvertTo typeof) - actual >> ignore |> shouldFail - + actual >> ignore |> shouldFail + [] let ``set dynamic chain`` () = let expected = "1"; @@ -103,13 +101,12 @@ module Raw = let target2 = ExpandoObject(); let target3 = ExpandoObject(); target?Test <- target2; - target2?Test2 <- target3; - - + target2?Test2 <- target3; + target |> Dyn.setChain ["Test"; "Test2"; "Test3"] expected; - + target?Test?Test2?Test3 |> should equal expected - + [] let ``set dynamic get chain`` () = let expected = "1"; @@ -119,11 +116,11 @@ module Raw = target?Test <- target2; target2?Test2 <- target3; target3?Test3 <- expected; - + let actual = target |> Dyn.getChain ["Test"; "Test2"; "Test3"]; - - actual |> should equal expected - + + actual |> should equal expected + [] let ``set dynamic get`` () = let expected = "A"; @@ -131,24 +128,23 @@ module Raw = target?prop <- expected let actual = target |> Dyn.get "prop" actual |> should equal expected - + [] let ``set dynamic set`` () = let expected = "A"; let target = ExpandoObject(); target |> Dyn.set "prop" expected let actual = target?prop - actual |> should equal expected - - [] + actual |> should equal expected + + [] let ``call static generic method`` () = let expected = Enumerable.Empty() let target = Dyn.staticTarget let actual: int seq = target |> Dyn.invokeGeneric "Empty" [typeof] () - actual |> should equal expected - - - [] + actual |> should equal expected + + [] let ``call static generic method typeof`` () = let expected = Enumerable.Empty() let target = Dyn.staticContext (typeof) diff --git a/Tests/ReadmeExamples.fs b/Tests/ReadmeExamples.fs index ef2f178..4ecdd39 100644 --- a/Tests/ReadmeExamples.fs +++ b/Tests/ReadmeExamples.fs @@ -58,4 +58,4 @@ module ReadmeExamples = [] let ``direct invoke of an FSharp function`` () = let add3: int -> int = !?(+) 3 - Assert.Equal(7, add3 4) + Assert.Equal(7, add3 4) \ No newline at end of file diff --git a/Tests/TryGet.fs b/Tests/TryGet.fs index 12ec085..052b4bb 100644 --- a/Tests/TryGet.fs +++ b/Tests/TryGet.fs @@ -78,4 +78,4 @@ module TryGet = let ``tryGet returns None for a missing member even when the result type is a function`` () = let o = ExpandoObject() let missing: (int -> int) option = o |> Dyn.tryGet "nope" - missing |> should equal None + missing |> should equal None \ No newline at end of file diff --git a/Tests/WhyExamples.fs b/Tests/WhyExamples.fs index 9083db8..9a2368d 100644 --- a/Tests/WhyExamples.fs +++ b/Tests/WhyExamples.fs @@ -42,4 +42,4 @@ module WhyExamples = let ``CSharp API handed back a DynamicObject`` () = let client = Client() let _: unit = client?addMessage("hi") - Assert.Equal("addMessage(hi)", client.Last) + Assert.Equal("addMessage(hi)", client.Last) \ No newline at end of file