diff --git a/Nu.sln b/Nu.sln
index d87e5c3ad5..29b1d33df6 100644
--- a/Nu.sln
+++ b/Nu.sln
@@ -18,8 +18,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Nu.Template", "Nu\Nu.Templa
{85D631A5-821A-4755-A68E-C1FFC64E469A} = {85D631A5-821A-4755-A68E-C1FFC64E469A}
EndProjectSection
EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Prime", "Prime\Prime\Prime.fsproj", "{FE09AE81-B66B-42E0-8192-EADECEFC9893}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nu.AStar", "Nu\Nu.AStar\Nu.AStar.csproj", "{61667008-EE77-43B4-8825-0231D241CCA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nu.SDL2", "Nu\Nu.SDL2\Nu.SDL2.csproj", "{F184A111-8C28-40B4-8CDE-7BF2A64B3CA7}"
@@ -50,10 +48,6 @@ Global
{F1768F36-9ED3-4C36-9DCE-9535AEFB0732}.Release|Any CPU.Build.0 = Release|Any CPU
{4DBBAA23-56BA-43CB-AB63-C45D5FC1016F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DBBAA23-56BA-43CB-AB63-C45D5FC1016F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FE09AE81-B66B-42E0-8192-EADECEFC9893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FE09AE81-B66B-42E0-8192-EADECEFC9893}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FE09AE81-B66B-42E0-8192-EADECEFC9893}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FE09AE81-B66B-42E0-8192-EADECEFC9893}.Release|Any CPU.Build.0 = Release|Any CPU
{61667008-EE77-43B4-8825-0231D241CCA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{61667008-EE77-43B4-8825-0231D241CCA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{61667008-EE77-43B4-8825-0231D241CCA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/Nu/Nu.Gaia/Nu.Gaia.fsproj b/Nu/Nu.Gaia/Nu.Gaia.fsproj
index e2bdd2ae18..1214dcf435 100644
--- a/Nu/Nu.Gaia/Nu.Gaia.fsproj
+++ b/Nu/Nu.Gaia/Nu.Gaia.fsproj
@@ -1,5 +1,7 @@
+
+
Debug
@@ -14,6 +16,8 @@
Nu.Gaia
4.4.3.0
+
+
true
@@ -83,10 +87,16 @@
- ..\..\Prime\Prime.Dependencies\FParsec\FParsec.dll
+ ..\..\packages\FParsec.1.0.3\lib\net40-client\FParsec.dll
- ..\..\Prime\Prime.Dependencies\FParsec\FParsecCS.dll
+ ..\..\packages\FParsec.1.0.3\lib\net40-client\FParsecCS.dll
+
+
+ ..\..\packages\FsCheck.2.10.10\lib\net452\FsCheck.dll
+
+
+ ..\..\packages\FsCheck.Xunit.2.10.10\lib\net452\FsCheck.Xunit.dll
True
@@ -101,6 +111,9 @@
..\Nu.Dependencies\Nito.Collections.Deque\Nito.Collections.Deque.dll
+
+ ..\..\packages\Prime.2.7.0\lib\net46\Prime.exe
+
..\Nu.Dependencies\ScintillaNET\ScintillaNET.dll
@@ -112,17 +125,12 @@
- ..\..\Prime\Prime.Dependencies\System.ValueTuple.4.3.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll
+ ..\..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll
..\Nu.Dependencies\TiledSharp\Release\TiledSharp.dll
-
- Prime
- {fe09ae81-b66b-42e0-8192-eadecefc9893}
- True
-
Nu.SDL2
{f184a111-8c28-40b4-8cde-7bf2a64b3ca7}
@@ -139,16 +147,16 @@
True
- ..\..\Prime\Prime.Dependencies\xunit\xunit.abstractions.dll
+ ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll
- ..\..\Prime\Prime.Dependencies\xunit\xunit.assert.dll
+ ..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll
- ..\..\Prime\Prime.Dependencies\xunit\xunit.core.dll
+ ..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll
- ..\..\Prime\Prime.Dependencies\xunit\xunit.execution.desktop.dll
+ ..\..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll
@@ -158,4 +166,13 @@
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Nu/Nu.Gaia/Packages.config b/Nu/Nu.Gaia/Packages.config
index 77b54a2758..febaef4574 100644
--- a/Nu/Nu.Gaia/Packages.config
+++ b/Nu/Nu.Gaia/Packages.config
@@ -1,4 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Nu/Nu.Pipe/Nu.Pipe.fsproj b/Nu/Nu.Pipe/Nu.Pipe.fsproj
index 941fbed4ff..d587afe982 100644
--- a/Nu/Nu.Pipe/Nu.Pipe.fsproj
+++ b/Nu/Nu.Pipe/Nu.Pipe.fsproj
@@ -1,5 +1,7 @@
+
+
Debug
@@ -14,6 +16,8 @@
4.4.3.0
Nu.Pipe
+
+
true
@@ -71,10 +75,16 @@
- ..\..\Prime\Prime.Dependencies\FParsec\FParsec.dll
+ ..\..\packages\FParsec.1.0.3\lib\net40-client\FParsec.dll
- ..\..\Prime\Prime.Dependencies\FParsec\FParsecCS.dll
+ ..\..\packages\FParsec.1.0.3\lib\net40-client\FParsecCS.dll
+
+
+ ..\..\packages\FsCheck.2.10.10\lib\net452\FsCheck.dll
+
+
+ ..\..\packages\FsCheck.Xunit.2.10.10\lib\net452\FsCheck.Xunit.dll
..\Nu.Dependencies\FSharpx.Collections\FSharpx.Collections.dll
@@ -86,26 +96,45 @@
True
+
+ ..\..\packages\Prime.2.7.0\lib\net46\Prime.exe
+
..\Nu.Dependencies\SDL2#\Release\SDL2#.dll
-
- Prime
- {fe09ae81-b66b-42e0-8192-eadecefc9893}
- True
-
Nu
{a7a6f758-e122-4c2c-9525-1f29802d007c}
True
- ..\..\Prime\Prime.Dependencies\System.ValueTuple.4.3.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll
+ ..\..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll
+
+
+ ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll
+
+
+ ..\..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll
+
+
+ ..\..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll
+
+
+ ..\..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/Prime/Prime/Prime.xunit b/Prime/Prime/Prime.xunit
deleted file mode 100644
index 97b5503e00..0000000000
--- a/Prime/Prime/Prime.xunit
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Prime/Prime/Program.fs b/Prime/Prime/Program.fs
deleted file mode 100644
index 39b6c9c394..0000000000
--- a/Prime/Prime/Program.fs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Prime - A PRIMitivEs code library.
-// Copyright (C) Bryan Edds, 2013-2018.
-
-namespace Prime
-open System
-open System.Collections.Generic
-open System.Diagnostics
-open Prime
-module Program =
-
- /// The number of samples taken for each timing.
- let [] Samples = 3
-
- /// Performs some ad-hoc tests to compare performance of fns.
- let runTimings fn name =
- printfn "%s timings..." name
- for _ in 1 .. Samples do
- GC.Collect ()
- let watch = Stopwatch.StartNew ()
- fn () |> ignore
- watch.Stop ()
- printfn "Run time: %A" watch.Elapsed
-
- /// Performs some ad-hoc tests to compare performance of maps.
- let runMapTimings make lookup name =
- printfn "%s timings..." name
- let rand = Random 1
- let entries = [|for _ in 0 .. 524280 do yield let n = rand.Next () in (string n, (string n, string n))|]
- for _ in 1 .. Samples do
- GC.Collect ()
- let watch = Stopwatch.StartNew ()
- let made = make entries
- watch.Stop ()
- GC.Collect ()
- let watch2 = Stopwatch.StartNew ()
- lookup entries made
- watch2.Stop ()
- printfn "Make time: %A\tLookup time: %A\tRun time: %A" watch.Elapsed watch2.Elapsed (watch.Elapsed + watch2.Elapsed)
-
- /// Run timings.
- /// NOTE: even if this timing functionality is cleared out, the main entry point must remain in tact due to -
- /// https://github.com/Microsoft/visualfsharp/issues/1371#issuecomment-235101700
- let [] main _ =
-
- // run array timings
- let array = [|0 .. 10000000|]
- runTimings (fun () -> array |> Array.rev |> Array.sort |> Array.map (fun x -> x * 13) |> Array.filter (fun x -> x % 2 = 0)) "Array Compute"
-
- // run ulist timings
- let ulist = UList.makeFromSeq Functional [|0 .. 10000000|]
- runTimings (fun () -> ulist |> UList.rev |> UList.sort |> UList.map (fun x -> x * 13) |> UList.filter (fun x -> x % 2 = 0)) "UList Compute"
-
- // run ulist imperative timings
- let ulist = UList.makeFromSeq Imperative [|0 .. 10000000|]
- runTimings (fun () -> ulist |> UList.rev |> UList.sort |> UList.map (fun x -> x * 13) |> UList.filter (fun x -> x % 2 = 0)) "UList Imperative Compute"
-
- // run list timings
- let list = [0 .. 10000000]
- runTimings (fun () -> list |> List.rev |> List.sort |> List.map (fun x -> x * 13) |> List.filter (fun x -> x % 2 = 0)) "F# List Compute"
-
- // run map timings
- runMapTimings
- (fun entries -> Array.fold (fun map (k, v) -> Map.add k v map) Map.empty entries)
- (fun entries map -> Array.iter (fun (k, _) -> Map.find k map |> ignore) entries)
- "F# Map"
-
- // run hmap timings
- runMapTimings
- (fun entries -> Array.fold (fun map (k, v) -> HMap.add k v map) (HMap.makeEmpty ()) entries)
- (fun entries map -> Array.iter (fun (k, _) -> HMap.find k map |> ignore) entries)
- "HMap"
-
- // run tmap timings with computation expressions
- runMapTimings
- (fun entries -> Array.fold (fun map (k, v) -> TMap.add k v map) (TMap.makeEmpty Functional) entries)
- (fun entries map -> entries |> Array.iter (fun (k, _) -> TMap.find k map |> ignore))
- "TMap"
-
- // run umap timings without computation expressions
- runMapTimings
- (fun entries -> Array.fold (fun map (k, v) -> UMap.add k v map) (UMap.makeEmpty Functional) entries)
- (fun entries map -> Array.iter (fun (k, _) -> UMap.find k map |> ignore) entries)
- "UMap"
-
- // run umap imperative timings without computation expressions
- runMapTimings
- (fun entries -> Array.fold (fun map (k, v) -> UMap.add k v map) (UMap.makeEmpty Imperative) entries)
- (fun entries map -> Array.iter (fun (k, _) -> UMap.find k map |> ignore) entries)
- "UMap Imperative"
-
- // run dictionary timings
- let dic = Dictionary ()
- runMapTimings
- (fun entries -> Array.iter (fun (k, v) -> if not (dic.ContainsKey k) then dic.Add (k, v)) entries)
- (fun entries () -> Array.iter (fun (k, _) -> dic.[k] |> ignore) entries)
- ".NET Dictionary"
-
- // success
- 0
diff --git a/Prime/Prime/Rand.fs b/Prime/Prime/Rand.fs
deleted file mode 100644
index 4bb9bc2e15..0000000000
--- a/Prime/Prime/Rand.fs
+++ /dev/null
@@ -1,106 +0,0 @@
-// Prime - A PRIMitivEs code library.
-// Copyright (C) Bryan Edds, 2013-2018.
-
-namespace Prime
-open System
-
-[]
-module RandModule =
-
- /// An immutable random number generator using the xorshift* algorithm.
- type [] Rand =
- private
- { RandState : uint64 }
-
- []
- module Rand =
-
- /// Get the sample value used to generate the current random value.
- let private sample rand =
- let result = rand.RandState * 2685821657736338717UL
- if result = UInt64.MaxValue then 0UL else result
-
- /// The default seed state for rand.
- /// NOTE: number generated via http://www.random.org/bytes/
- let DefaultSeedState = 0xa529cb6f5f0385edUL
-
- /// Advance the state of rand, thus yielding a new outcome.
- let advance rand =
- let c = rand.RandState
- let c = c ^^^ (c >>> 12)
- let c = c ^^^ (c <<< 25)
- let c = c ^^^ (c >>> 27)
- { RandState = c }
-
- /// The internal state of rand, useful for serialization and duplication.
- let getState rand =
- rand.RandState
-
- /// Get the next random value as a double type.
- let nextDouble rand =
- let rand = advance rand
- let sampleDouble = double (sample rand)
- let sampleDoubleMax = double UInt64.MaxValue
- let number = sampleDouble / sampleDoubleMax
- (number, rand)
-
- /// Get the next random value below the given maximum as a double type.
- let nextDoubleUnder max rand =
- let (number, rand) = nextDouble rand
- (number % max, rand)
-
- /// Get the next random value as a double type.
- let nextSingle rand =
- let (numberDouble, rand) = nextDouble rand
- (single numberDouble, rand)
-
- /// Get the next random value below the given maximum as a single type.
- let nextSingleUnder max rand =
- let (number, rand) = nextSingle rand
- (number % max, rand)
-
- /// Get the next random value as an int type.
- /// NOTE: System.Random.Next will never return Int32.MaxValue, but this will.
- let nextInt rand =
- let rand = advance rand
- let sampleInt = int (sample rand >>> 32)
- let number = if sampleInt < 0 then sampleInt + Int32.MaxValue else sampleInt
- (number, rand)
-
- /// Get the next random value below the given maximum as an int type.
- let nextIntUnder max rand =
- let (number, rand) = nextInt rand
- (number % max, rand)
-
- /// Get the next random value as an int64 type.
- /// NOTE: System.Random.Next will never return Int64.MaxValue, but this will.
- let nextInt64 rand =
- let rand = advance rand
- let number = sample rand
- (number, rand)
-
- /// Get the next random value below the given maximum as an int64 type.
- let nextInt64Under max rand =
- let (number, rand) = nextInt64 rand
- (number % max, rand)
-
- /// Make a rand value generator from the given seed state.
- /// May not be zero.
- let makeFromSeedState seedState =
- if seedState = 0UL then failwith "Seed for Rand may not be zero."
- { RandState = seedState }
-
- /// Make a rand value generator from the given int seed state.
- /// May not be zero.
- let makeFromInt (intSeedState : int) =
- let lowState = uint64 intSeedState
- let highState = uint64 intSeedState <<< 32
- let seedState = highState ||| lowState
- makeFromSeedState seedState
-
- /// Make a rand value generator from the default seed state.
- let make () =
- makeFromSeedState DefaultSeedState
-
-/// An immutable random number generator using the xorshift* algorithm.
-type Rand = RandModule.Rand
\ No newline at end of file
diff --git a/Prime/Prime/RandTests.fs b/Prime/Prime/RandTests.fs
deleted file mode 100644
index 36a704a6e1..0000000000
--- a/Prime/Prime/RandTests.fs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Prime - A PRIMitivEs code library.
-// Copyright (C) Bryan Edds, 2013-2018.
-
-namespace Prime.Tests
-open System
-open Xunit
-open Prime
-module RandTests =
-
- let [] Samples = 32768
-
- let makeSamples (next : Rand -> ('n * Rand)) =
- let randRef = ref (Rand.make ())
- [for _ in 0 .. Samples - 1 do
- let (n, r) = next !randRef
- randRef := r
- yield n]
-
- let [] nextDoubleIsInRange () =
- let samples = makeSamples Rand.nextDouble
- let avg = List.average samples
- Assert.InRange (avg, 0.49, 0.51)
-
- let [] nextSingleIsInRange () =
- let samples = makeSamples Rand.nextSingle
- let avg = List.average samples
- Assert.InRange (avg, 0.49f, 0.51f)
-
- let [] nextIntIsInRange () =
- let samples = makeSamples Rand.nextInt
- let sampleDoubles = List.map double samples
- let avg = List.average sampleDoubles
- Assert.InRange (avg, 1003741823.0, 1143741823.0)
\ No newline at end of file
diff --git a/Prime/Prime/Reflection.fs b/Prime/Prime/Reflection.fs
deleted file mode 100644
index 4e7213216b..0000000000
--- a/Prime/Prime/Reflection.fs
+++ /dev/null
@@ -1,324 +0,0 @@
-// Prime - A PRIMitivEs code library.
-// Copyright (C) Bryan Edds, 2013-2018.
-
-namespace Prime
-open System
-open System.ComponentModel
-open System.Collections
-open System.Collections.Generic
-open System.Text
-open System.Reflection
-open Microsoft.FSharp.Reflection
-
-/// An attribute to specify the default value of a property.
-type [] DefaultValueAttribute (defaultValue : obj) =
- inherit Attribute ()
- member this.DefaultValue = defaultValue
-
-/// An evaluatable expression for defining a property.
-type [] PropertyExpr =
- | DefineExpr of DefineExpr : obj
- | VariableExpr of VariableExpr : (unit -> obj)
-
- /// Evaluate a property expression.
- static member eval expr =
- match expr with
- | DefineExpr value -> value
- | VariableExpr fn -> fn ()
-
-/// The definition of a data-driven property.
-type [] PropertyDefinition =
- { PropertyName : string
- PropertyType : Type
- PropertyExpr : PropertyExpr }
-
- /// Validate a property definition.
- static member validate propertyDefinition =
- if propertyDefinition.PropertyName = "FacetNames" then failwith "FacetNames cannot be an intrinsic property."
- if propertyDefinition.PropertyName = "OverlayNameOpt" then failwith "OverlayNameOpt cannot be an intrinsic property."
- if Array.exists (fun gta -> gta = typeof) propertyDefinition.PropertyType.GenericTypeArguments then
- failwith
- ("Generic property definition lacking type information for property '" + propertyDefinition.PropertyName + "'. " +
- "Use explicit typing on all values that carry incomplete type information such as empty lists, empty sets, and none options.")
-
- /// Make a property definition.
- static member make propertyName propertyType propertyExpr =
- { PropertyName = propertyName; PropertyType = propertyType; PropertyExpr = propertyExpr }
-
- /// Make a property definition, validating it in the process.
- static member makeValidated propertyName propertyType propertyExpr =
- let result = PropertyDefinition.make propertyName propertyType propertyExpr
- PropertyDefinition.validate result
- result
-
-/// In tandem with the define literal, grants a nice syntax to define value properties.
-type [] ValueDescription =
- { ValueDescription : unit }
-
- /// Some magic syntax for composing value properties.
- static member (?) (_, propertyName) =
- fun (value : 'v) ->
- PropertyDefinition.makeValidated propertyName typeof<'v> (DefineExpr value)
-
-/// In tandem with the variable literal, grants a nice syntax to define variable properties.
-type [] VariableDescription =
- { VariableDescription : unit }
-
- /// Some magic syntax for composing variable properties.
- static member (?) (_, propertyName) =
- fun (variable : unit -> 'v) ->
- PropertyDefinition.makeValidated propertyName typeof<'v> (VariableExpr (fun () -> variable () :> obj))
-
-/// In tandem with the property literal, grants a nice syntax to denote properties.
-type [] PropertyDescription =
- { PropertyDescription : unit }
-
- /// Some magic syntax for composing value properties.
- static member inline (?) (_, propertyName : string) =
- propertyName
-
-/// Describes a property.
-type [] PropertyDescriptor =
- { PropertyName : string
- PropertyType : Type }
-
-/// A vanilla property.
-type [] Property =
- { mutable PropertyType : Type
- mutable PropertyValue : obj }
-
-/// A designer-defined property.
-type [] DesignerProperty =
- { mutable DesignerType : Type
- mutable DesignerValue : obj }
-
-/// A map of propertyies.
-/// NOTE: Xtension uses UMap because it's slightly faster when used in the Nu game engine, but
-/// it's not necessarily the right decision in other contexts. However, I'm sticking with this
-/// choice since the performance of Nu trumps other usages for now.
-type PropertyMap = UMap
-
-[]
-module ReflectionModule =
-
- /// In tandem with the ValueDefinition type, grants a nice syntax to define value properties.
- let Define = { ValueDescription = () }
-
- /// In tandem with the VariableDefinition type, grants a nice syntax to define variable properties.
- let Variable = { VariableDescription = () }
-
- /// In tandem with the PropertyDescriptor type, grants a nice syntax to denote properties.
- let Property = { PropertyDescription = () }
-
-module Reflection =
-
- // NOTE: had to do some reflection hacking get this assembly as it was the only way I could
- // access ListModule.OfSeq dynamically.
- let private FSharpCoreAssembly =
- Array.find
- (fun (assembly : Assembly) -> assembly.FullName.StartsWith ("FSharp.Core,", StringComparison.Ordinal))
- (AppDomain.CurrentDomain.GetAssemblies ())
-
- let objToObjList (source : obj) =
- let iEnumerable = source :?> IEnumerable
- List.ofSeq (enumerable iEnumerable)
-
- let objToKeyValuePair (source : obj) =
- let kvpType = source.GetType ()
- let key = (kvpType.GetProperty "Key").GetValue (source, null)
- let value = (kvpType.GetProperty "Value").GetValue (source, null)
- KeyValuePair (key, value)
-
- let objToOption (source : obj) =
- if isNotNull source then
- let optType = source.GetType ()
- let value = (optType.GetProperty "Value").GetValue (source, null)
- Some value
- else None
-
- let objToComparableSet (source : obj) =
- let iEnumerable = source :?> IEnumerable
- Set.ofSeq (enumerable iEnumerable)
-
- let objsToKeyValuePair fst snd (pairType : Type) =
- Activator.CreateInstance (pairType, [|fst; snd|])
-
- let objsToCollection collectionTypeName (sequenceType : Type) (objs : _ seq) =
- let gargs = if sequenceType.IsArray then [|sequenceType.GetElementType ()|] else (sequenceType.GetGenericArguments ())
- let cast = (typeof.GetMethod ("Cast", BindingFlags.Static ||| BindingFlags.Public)).MakeGenericMethod gargs
- let ofSeq = ((FSharpCoreAssembly.GetType collectionTypeName).GetMethod ("OfSeq", BindingFlags.Static ||| BindingFlags.Public)).MakeGenericMethod gargs
- ofSeq.Invoke (null, [|cast.Invoke (null, [|objs|])|])
-
- let pairsToMapping collectionTypeName (mappingType : Type) (pairs : _ seq) =
- let gargs = mappingType.GetGenericArguments ()
- match gargs with
- | [|fstType; sndType|] ->
- let pairType = typedefof>.MakeGenericType [|fstType; sndType|]
- let cast = (typeof.GetMethod ("Cast", BindingFlags.Static ||| BindingFlags.Public)).MakeGenericMethod [|pairType|]
- let ofSeq = ((FSharpCoreAssembly.GetType collectionTypeName).GetMethod ("OfSeq", BindingFlags.Static ||| BindingFlags.Public)).MakeGenericMethod [|fstType; sndType|]
- ofSeq.Invoke (null, [|cast.Invoke (null, [|pairs|])|])
- | _ -> failwithumf ()
-
- let objsToArray arrayType objs =
- objsToCollection "Microsoft.FSharp.Collections.ArrayModule" arrayType objs
-
- let objsToList listType objs =
- objsToCollection "Microsoft.FSharp.Collections.ListModule" listType objs
-
- let objsToSet setType objs =
- objsToCollection "Microsoft.FSharp.Collections.SetModule" setType objs
-
- let pairsToMap mapType objs =
- pairsToMapping "Microsoft.FSharp.Collections.MapModule" mapType objs
-
-module Type =
-
- /// Try to get an existing type with the given unqualified name. Time-intensive.
- let TryGetTypeUnqualified name =
- match Type.GetType name with
- | null ->
- let allAssemblies = AppDomain.CurrentDomain.GetAssemblies ()
- let types =
- Array.choose
- (fun (assembly : Assembly) ->
- match assembly.GetType name with
- | null -> None
- | ty -> Some ty)
- allAssemblies
- Array.tryHead types
- | ty -> Some ty
-
- /// Get an existing type with the given unqualified name. Time-intensive.
- let GetTypeUnqualified name =
- match TryGetTypeUnqualified name with
- | Some ty -> ty
- | None -> failwith ("Could not find type with unqualified name '" + name + "'.")
-
- /// Get the first property that is signalled to be preferred by the 'preference' predicate.
- let GetPropertyByPreference (preference, properties) =
- let preferredOpt = Array.tryFind preference properties
- if Array.isEmpty properties then null
- else
- match preferredOpt with
- | Some preferred -> preferred
- | None -> Array.head properties
-
-[]
-module TypeExtension =
-
- /// Type extension for Type.
- type Type with
-
- /// Attempt to get the default value for a type.
- /// Never returns null.
- member this.TryGetDefaultValue () =
- if this.IsPrimitive then Some (Activator.CreateInstance this)
- elif this = typeof then Some (String.Empty :> obj)
- elif this.Name = typedefof<_ array>.Name then Some (Reflection.objsToArray this [||])
- elif this.Name = typedefof<_ list>.Name then Some (Reflection.objsToList this [])
- elif this.Name = typedefof<_ Set>.Name then Some (Reflection.objsToSet this Set.empty)
- elif this.Name = typedefof