Skip to content

Commit

Permalink
Fix #424: reflecting nested types from quotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jand42 committed Jun 25, 2015
1 parent 06b8354 commit 29dc198
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 242 deletions.
2 changes: 1 addition & 1 deletion src/compiler/WebSharper.Compiler/ReflectionLayer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ module Reflection =
lazy
try
d.GetTypes()
|> Array.map (fun x -> conv.ConvertType(x))
|> Array.choose (fun x -> if x.IsNested then None else Some (conv.ConvertType(x)))
with :? ReflectionTypeLoadException as e ->
failwith "Reflection type load error: %s" e.LoaderExceptions.[0].Message

Expand Down
60 changes: 31 additions & 29 deletions tests/Website/Client.fs
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
// $begin{copyright}
//
// This file is part of WebSharper
//
// Copyright (c) 2008-2014 IntelliFactory
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You may
// obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.
//
// $end{copyright}

/// Client-side (JavaScript) code.
module Website.Client

open WebSharper
open WebSharper.JavaScript

[<JavaScript>]
let EntryPoint () =
Console.Log("Loaded OK")
// $begin{copyright}
//
// This file is part of WebSharper
//
// Copyright (c) 2008-2014 IntelliFactory
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You may
// obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.
//
// $end{copyright}

/// Client-side (JavaScript) code.
module Website.Client

open WebSharper
open WebSharper.JavaScript
open WebSharper.Html.Client

[<JavaScript>]
let EntryPoint () =
Console.Log("Loaded OK")
Span []
34 changes: 0 additions & 34 deletions tests/Website/Controls.fs

This file was deleted.

168 changes: 84 additions & 84 deletions tests/Website/Skin.fs
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
// $begin{copyright}
//
// This file is part of WebSharper
//
// Copyright (c) 2008-2014 IntelliFactory
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You may
// obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.
//
// $end{copyright}

/// Utilities for server-side markup generation.
module Website.Skin

open System
open System.Web
open WebSharper
open WebSharper.Html.Server
open WebSharper.Sitelets

let Footer =
[
Text (String.Format("Copyright (c) 2008-{0} IntelliFactory", DateTime.Now.Year))
]

type Page =
{
Body : list<Content.HtmlElement>
Footer : list<Content.HtmlElement>
Menu : list<Content.HtmlElement>
Project : string
Title : string
Version : string
}

static member Default(title) =
{
Footer = Footer
Body = [Div [Style "display:none"] -< [new Controls.EntryPoint()]]
Menu = []
Project = "Site"
Title = title
Version = Config.Version
}

let MainTemplate =
Content.Template<Page>("~/Main.html")
.With("body", fun x -> x.Body)
.With("menu", fun x -> x.Menu)
.With("footer", fun x -> x.Footer)
.With("project", fun x -> x.Project)
.With("title", fun x -> x.Title)
.With("version", fun x -> x.Version)

let FrontTempalte =
Content.Template<Page>("~/Front.html")
.With("body", fun x -> x.Body)
.With("menu", fun x -> x.Menu)
.With("footer", fun x -> x.Footer)
.With("project", fun x -> x.Project)
.With("title", fun x -> x.Title)
.With("version", fun x -> x.Version)

let RenderFront (ctx: Context<_>) =
let front = FrontTempalte.Compile(ctx.RootFolder)
fun x -> front.Run(x, ctx.RootFolder)

let WithTemplate title menu body : Content<_> =
Content.WithTemplate MainTemplate <| fun context ->
let p = Page.Default title
{
p with
Menu = p.Menu @ menu context
Body = p.Body @ body context
}
// $begin{copyright}
//
// This file is part of WebSharper
//
// Copyright (c) 2008-2014 IntelliFactory
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You may
// obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.
//
// $end{copyright}

/// Utilities for server-side markup generation.
module Website.Skin

open System
open System.Web
open WebSharper
open WebSharper.Html.Server
open WebSharper.Sitelets

let Footer =
[
Text (String.Format("Copyright (c) 2008-{0} IntelliFactory", DateTime.Now.Year))
]

type Page =
{
Body : list<Content.HtmlElement>
Footer : list<Content.HtmlElement>
Menu : list<Content.HtmlElement>
Project : string
Title : string
Version : string
}

static member Default(title) =
{
Footer = Footer
Body = [Div [Style "display:none"] -< [ClientSide <@ Client.EntryPoint() @>]]
Menu = []
Project = "Site"
Title = title
Version = Config.Version
}

let MainTemplate =
Content.Template<Page>("~/Main.html")
.With("body", fun x -> x.Body)
.With("menu", fun x -> x.Menu)
.With("footer", fun x -> x.Footer)
.With("project", fun x -> x.Project)
.With("title", fun x -> x.Title)
.With("version", fun x -> x.Version)

let FrontTempalte =
Content.Template<Page>("~/Front.html")
.With("body", fun x -> x.Body)
.With("menu", fun x -> x.Menu)
.With("footer", fun x -> x.Footer)
.With("project", fun x -> x.Project)
.With("title", fun x -> x.Title)
.With("version", fun x -> x.Version)

let RenderFront (ctx: Context<_>) =
let front = FrontTempalte.Compile(ctx.RootFolder)
fun x -> front.Run(x, ctx.RootFolder)

let WithTemplate title menu body : Content<_> =
Content.WithTemplate MainTemplate <| fun context ->
let p = Page.Default title
{
p with
Menu = p.Menu @ menu context
Body = p.Body @ body context
}
Loading

0 comments on commit 29dc198

Please sign in to comment.