Skip to content

Commit

Permalink
Merge pull request #233 from dotnet-websharper/removewarnings
Browse files Browse the repository at this point in the history
Remove warnings
  • Loading branch information
granicz committed Feb 7, 2022
2 parents a47e598 + ec25a05 commit e06fc7d
Show file tree
Hide file tree
Showing 28 changed files with 697 additions and 696 deletions.
8 changes: 4 additions & 4 deletions WebSharper.UI.CSharp.Templating/CodeGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let private invalidIdentifierCharRE =
Regex("[^a-zA-Z0-9_]", RegexOptions.Compiled)

let normalizeIdent (s: string) =
let s = s.[0..0].ToUpperInvariant() + s.[1..]
let s = s[0..0].ToUpperInvariant() + s[1..]
invalidIdentifierCharRE.Replace(s, "_")

let private invalidNamespaceCharRE =
Expand Down Expand Up @@ -234,7 +234,7 @@ let getRelPath (baseDir: string) (fullPath: string) =
let baseDir = baseDir.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar) + string Path.DirectorySeparatorChar
let fullPath = fullPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
if fullPath.StartsWith baseDir then
fullPath.[baseDir.Length..]
fullPath[baseDir.Length..]
else
failwith "filePath is not a subdirectory of projectDirectory"
else fullPath
Expand Down Expand Up @@ -309,15 +309,15 @@ let GetCode namespaceName projectDirectory filePath
([<Optional; DefaultParameterValue(ServerLoad.WhenChanged)>] serverLoad)
([<Optional; DefaultParameterValue(ClientLoad.Inline)>] clientLoad) =
let parsed = Parsing.Parse (getRelPath projectDirectory filePath) projectDirectory serverLoad clientLoad
let item = parsed.Items.[0] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
let item = parsed.Items[0] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
let templateName = normalizeIdent item.Id
let namespaceName = normalizeNamespace namespaceName
autoGeneratedComment + getCodeInternal namespaceName templateName item

let GetCodeClientOnly namespaceName templateName htmlString
([<Optional; DefaultParameterValue(ClientLoad.Inline)>] clientLoad) =
let parsed = Parsing.Parse htmlString null ServerLoad.Once clientLoad
let item = parsed.Items.[0] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
let item = parsed.Items[0] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
let templateName = normalizeIdent templateName
let namespaceName = normalizeNamespace namespaceName
autoGeneratedComment + getCodeInternal namespaceName templateName item
Expand Down
1 change: 1 addition & 0 deletions WebSharper.UI.CSharp/Models.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type ListModelExtensions =
/// Creates a new ListModel of 'V that is two-way bound to the underlying ListModel of 'T
/// but wraps each item with some extra data.
/// </summary>
/// <param name="model">The underlying ListModel used for the Wrap function</param>
/// <param name="extract">Extract the underlying item from a wrapped item</param>
/// <param name="wrap">Construct a wrapped item from an underlying item</param>
/// <param name="update">Update a wrapped item's underlying data</param>
Expand Down
34 changes: 17 additions & 17 deletions WebSharper.UI.CSharp/Routing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module private Internals =
(^T : (member GetCustomAttributesData : unit -> IList<Reflection.CustomAttributeData>)(x))
|> Seq.tryPick (fun cad ->
if cad.Constructor.DeclaringType = typeof<NameAttribute> then
Some (cad.ConstructorArguments.[0].Value :?> string)
Some (cad.ConstructorArguments[0].Value :?> string)
else None
)
defaultArg o (^T : (member Name : string)(x))
Expand Down Expand Up @@ -199,7 +199,7 @@ and private RouteMapBuilderMacro() =
match t with
| ConcreteType td ->
if td.Entity = listT then
let itemT = td.Generics.[0]
let itemT = td.Generics[0]
let fromArray =
Hashed {
MethodName = "ToList"
Expand Down Expand Up @@ -270,20 +270,20 @@ and private RouteMapBuilderMacro() =
)
|> List.ofSeq
let isHole (n: string) = n.StartsWith "{" && n.EndsWith "}"
match endpoint.[endpoint.IndexOf('/') + 1 ..].Split([|'/'|], StringSplitOptions.RemoveEmptyEntries) with
match endpoint[endpoint.IndexOf('/') + 1 ..].Split([|'/'|], StringSplitOptions.RemoveEmptyEntries) with
| [||] -> MetaObject (ctor, None, fields)
| [| name |] when not (isHole name) -> MetaObject (ctor, Some name, fields)
| a ->
let name, a =
if isHole a.[0] then
if isHole a[0] then
None, a
else
Some a.[0], a.[1..]
Some a[0], a[1..]
let args =
a.[1..]
a[1..]
|> Array.map (fun n ->
if isHole n then
let name = n.[1..n.Length-2]
let name = n[1..n.Length-2]
match fields |> List.tryFind (fun (n, _, _) -> name = n) with
| Some f -> f
| None -> failwithf "Path argument doesn't correspond to a field: %s" n
Expand Down Expand Up @@ -353,7 +353,7 @@ and private RouteMapBuilderMacro() =

override __.TranslateCall(c) =
comp <- c.Compilation
let targ = c.Method.Generics.[0]
let targ = c.Method.Generics[0]
if targ.IsParameter then MacroNeedsResolvedTypeArg targ else
try
match c.Method.Entity.Value.MethodName with
Expand All @@ -375,7 +375,7 @@ and private RouteMapBuilderMacro() =
| "Render" ->
let go = Id.New()
let action = Id.New()
let render = c.Arguments.[0]
let render = c.Arguments[0]
Lambda([go; action],
Conditional (TypeCheck (Var action, targ),
some targ (Application (render, [Var go; Var action], Pure, Some 2)),
Expand Down Expand Up @@ -451,7 +451,7 @@ and [<JavaScript>] private RouteItemParsers =
match parseItem (rest, query) with
| None -> None
| Some (item, rest) ->
arr.[i] <- item
arr[i] <- item
set (i + 1) rest
set 0 rest
)
Expand Down Expand Up @@ -484,29 +484,29 @@ and [<JavaScript>] private RouteItemParsers =
match queryItem with
| QueryItem.NotQuery ->
let l, m = link value?(name)
map := Map.foldBack Map.add m !map
map.Value <- Map.foldBack Map.add m map.Value
l
| QueryItem.Option ->
match value?(name) with
| None -> ()
| Some x ->
let x = link x |> fst |> List.head
map := Map.add name x !map
map.Value <- Map.add name x map.Value
[]
| QueryItem.Nullable ->
let v = As<Nullable<_>> (value?(name))
if v.HasValue then
let x = link v.Value |> fst |> List.head
map := Map.add name x !map
map.Value <- Map.add name x map.Value
[]
| QueryItem.Mandatory ->
let x = link value?(name) |> fst |> List.head
map := Map.add name x !map
map.Value <- Map.add name x map.Value
[]
| _ -> failwith "invalid QueryItem enum value"
)
|> List.ofSeq)
l, !map
l, map.Value
| Sequence (_, _, linkItem) ->
let s = value :?> seq<obj>
string (Seq.length s) ::
Expand All @@ -530,7 +530,7 @@ and [<JavaScript>] private RouteItemParsers =
| x :: rest ->
match RegExp("^[0-9]+$").Exec(x) with
| null -> None
| a -> Some (JS.ParseInt a.[0], rest)
| a -> Some (JS.ParseInt a[0], rest)

[<Inline>]
static member ``System.SByte``(xq: list<string> * Map<string, string>) = As<option<System.SByte * list<string>>>(RouteItemParsers.``System.Int32``(xq))
Expand All @@ -553,7 +553,7 @@ and [<JavaScript>] private RouteItemParsers =
| x :: rest ->
match RegExp(@"^[0-9](?:\.[0-9]*)?$").Exec(x) with
| null -> None
| a -> Some (JS.ParseFloat a.[0], rest)
| a -> Some (JS.ParseFloat a[0], rest)

[<Inline>]
static member ``System.Single``(xq: list<string> * Map<string, string>) = As<option<System.Single * list<string>>>(RouteItemParsers.``System.Double``(xq))
Loading

0 comments on commit e06fc7d

Please sign in to comment.