diff --git a/src/compiler/WebSharper.Core/Macros.fs b/src/compiler/WebSharper.Core/Macros.fs index cb5308dd7..52ba4400c 100644 --- a/src/compiler/WebSharper.Core/Macros.fs +++ b/src/compiler/WebSharper.Core/Macros.fs @@ -403,6 +403,11 @@ type NumericMacro() = translateCompareTo c.Compilation (ConcreteType c.DefiningType) c.This.Value c.Arguments.Head | _ -> MacroFallback + override this.TranslateCtor(c) = + match c.Arguments with + | [] -> MacroOk (Value (Int 0)) + | _ -> MacroError "numericMacro error: contructor with arguments" + let charTy, charParse = let t = typeof Reflection.ReadTypeDefinition t, diff --git a/src/sitelets/WebSharper.Sitelets/RouterInfer.Client.fs b/src/sitelets/WebSharper.Sitelets/RouterInfer.Client.fs index d210c8189..3b18e8869 100644 --- a/src/sitelets/WebSharper.Sitelets/RouterInfer.Client.fs +++ b/src/sitelets/WebSharper.Sitelets/RouterInfer.Client.fs @@ -86,6 +86,14 @@ module private ClientRoutingInternals = let rIntOp = getMethod <@ RouterOperators.rInt @> let rDoubleOp = getMethod <@ RouterOperators.rDouble @> let rDateTimeOp = getMethod <@ RouterOperators.rDateTime @> + let rSByteOp = getMethod <@ RouterOperators.rSByte @> + let rByteOp = getMethod <@ RouterOperators.rByte @> + let rInt16Op = getMethod <@ RouterOperators.rInt16 @> + let rUInt16Op = getMethod <@ RouterOperators.rUInt16 @> + let rUInt32Op = getMethod <@ RouterOperators.rUInt @> + let rInt64Op = getMethod <@ RouterOperators.rInt64 @> + let rUInt64Op = getMethod <@ RouterOperators.rUInt64 @> + let rSingleOp = getMethod <@ RouterOperators.rSingle @> let TupleOp = getMethod <@ RouterOperators.JSTuple [||] @> let ArrayOp = getMethod <@ RouterOperators.JSArray RouterOperators.rInt @> let ListOp = getMethod <@ RouterOperators.JSList RouterOperators.rInt @> @@ -228,6 +236,22 @@ type RoutingMacro() = true, Call(None, NonGeneric routerOpsModule, NonGeneric rDoubleOp, []) | C (T "System.DateTime", []) -> true, Call(None, NonGeneric routerOpsModule, NonGeneric rDateTimeOp, []) + | C (T "System.SByte", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rSByteOp, []) + | C (T "System.Byte", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rByteOp, []) + | C (T "System.Int16", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rInt16Op, []) + | C (T "System.UInt16", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rUInt16Op, []) + | C (T "System.UInt32", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rUInt32Op, []) + | C (T "System.Int64", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rInt64Op, []) + | C (T "System.UInt64", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rUInt64Op, []) + | C (T "System.Single", []) -> + true, Call(None, NonGeneric routerOpsModule, NonGeneric rSingleOp, []) | TupleType (ts, _) -> let fields = NewArray (ts |> List.map getRouter) true, Call(None, NonGeneric routerOpsModule, NonGeneric TupleOp, [ fields ]) diff --git a/src/sitelets/WebSharper.Sitelets/RouterInfer.Server.fs b/src/sitelets/WebSharper.Sitelets/RouterInfer.Server.fs index 18944febe..3db9f4cd0 100644 --- a/src/sitelets/WebSharper.Sitelets/RouterInfer.Server.fs +++ b/src/sitelets/WebSharper.Sitelets/RouterInfer.Server.fs @@ -259,22 +259,22 @@ module internal ServerRouting = match t.Namespace with | "System" -> match t.Name with - | "Object" -> - IEmpty - | "String" -> - iString - | "Char" -> - iChar - | "Guid" -> - iGuid - | "Boolean" -> - iBool - | "Int32" -> - iInt - | "Double" -> - iDouble - | "DateTime" -> - iDateTime None + | "Object" -> IEmpty + | "String" -> iString + | "Char" -> iChar + | "Guid" -> iGuid + | "Boolean" -> iBool + | "Int32" -> iInt + | "Double" -> iDouble + | "DateTime" -> iDateTime None + | "SByte" -> iSByte + | "Byte" -> iByte + | "Int16" -> iInt16 + | "UInt16" -> iUInt16 + | "UInt32" -> iUInt + | "Int64" -> iInt64 + | "UInt64" -> iUInt64 + | "Single" -> iSingle | "Nullable`1" -> let item = t.GetGenericArguments().[0] INullable (getRouter item) diff --git a/tests/WebSharper.Web.Tests/Routers.fs b/tests/WebSharper.Web.Tests/Routers.fs index 8297137d3..f55dc72ff 100644 --- a/tests/WebSharper.Web.Tests/Routers.fs +++ b/tests/WebSharper.Web.Tests/Routers.fs @@ -20,6 +20,7 @@ namespace WebSharper.Sitelets.Tests +open System open WebSharper open WebSharper.Sitelets open WebSharper.CSharp.Sitelets.Tests @@ -86,6 +87,8 @@ module PerformanceTests = | [] UWildcardList of int list | [] UTwoUnions of MultipleTest * MultipleTest | [] UCSharp of CSharpEndPointRoot + | [] TypeTests of + Guid * single * double * sbyte * byte * int16 * uint16 * uint32 * int64 * uint64 let TestValues = [ @@ -129,6 +132,7 @@ module PerformanceTests = UTwoUnions (A1 1, A1 1) UCSharp (new CSharpEndPointRoot()) UCSharp (new CSharpEndPointRoot.Sub1(X = 42)) + TypeTests (Guid.NewGuid(), 1.3f, 1.4, 15y, 16uy, 64s, 65us, 66u, 67L, 68UL) ] let ExtraTestValues =