diff --git a/.build/Build.fs b/.build/Build.fs index 2bfe767d..c7851457 100644 --- a/.build/Build.fs +++ b/.build/Build.fs @@ -1,4 +1,4 @@ -// $begin{copyright} +// $begin{copyright} // // This file is part of Bolero // @@ -86,7 +86,7 @@ let escapeDashes s = m.Groups[1].Value.ToUpperInvariant()) let replace rows marker writeItem input = - Regex(sprintf """(?<=// BEGIN %s\r?\n)(?:\w|\W)*(?=// END %s)""" marker marker, + Regex($"""(?<=// BEGIN %s{marker}\r?\n)(?:\w|\W)*(?=// END %s{marker})""", RegexOptions.Multiline) .Replace(input, fun _ -> let s = StringBuilder() @@ -107,9 +107,9 @@ Target.create "tags" (fun _ -> replace (Tags.GetSample().Rows) "TAGS" (fun s tag -> let esc = escapeDashes tag.Name let ident = if tag.NeedsEscape then "``" + esc + "``" else esc - s.AppendLine(sprintf """/// Computation expression to create an HTML <%s> element.""" tag.Name) - .AppendLine( """/// HTML tag names""") - .AppendLine(sprintf "let %s : ElementBuilder = elt \"%s\"" ident tag.Name) + s.AppendLine($"""/// Computation expression to create an HTML <%s{tag.Name}> element.""") + .AppendLine( """/// HTML tag names""") + .AppendLine($"""let %s{ident} : ElementBuilder = elt "%s{tag.Name}" """) .AppendLine() ) >> replace (Attrs.GetSample().Rows) "ATTRS" (fun s attr -> @@ -118,38 +118,38 @@ Target.create "tags" (fun _ -> if attr.NeedsRename then esc + "'" elif attr.NeedsEscape then "``" + esc + "``" else esc - s.AppendLine(sprintf """ /// Create an HTML %s attribute.""" attr.Name) - .AppendLine( """ /// The value of the attribute.""") - .AppendLine(sprintf """ let inline %s (v: obj) : Attr = "%s" => v""" ident attr.Name) + s.AppendLine($""" /// Create an HTML %s{attr.Name} attribute.""") + .AppendLine( """ /// The value of the attribute.""") + .AppendLine($""" let inline %s{ident} (v: obj) : Attr = "%s{attr.Name}" => v""") .AppendLine() ) >> replace (Events.GetSample().Rows) "EVENTS" (fun s event -> let esc = escapeDashes event.Name - s.AppendLine(sprintf """ /// Create a handler for HTML event %s.""" event.Name) - .AppendLine( """ /// The event callback.""") - .AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> unit) : Attr =""" esc event.Type) - .AppendLine(sprintf """ attr.callback<%sEventArgs> "on%s" callback""" event.Type esc) + s.AppendLine($""" /// Create a handler for HTML event %s{event.Name}.""") + .AppendLine( """ /// The event callback.""") + .AppendLine($""" let inline %s{esc} (callback: %s{event.Type}EventArgs -> unit) : Attr =""") + .AppendLine($""" attr.callback<%s{event.Type}EventArgs> "on%s{esc}" callback""") .AppendLine() ) >> replace (Events.GetSample().Rows) "ASYNCEVENTS" (fun s event -> let esc = escapeDashes event.Name - s.AppendLine(sprintf """ /// Create an asynchronous handler for HTML event %s.""" event.Name) - .AppendLine( """ /// The event callback.""") - .AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> Async) : Attr =""" esc event.Type) - .AppendLine(sprintf """ attr.async.callback<%sEventArgs> "on%s" callback""" event.Type esc) + s.AppendLine($""" /// Create an asynchronous handler for HTML event %s{event.Name}.""") + .AppendLine( """ /// The event callback.""") + .AppendLine($""" let inline %s{esc} (callback: %s{event.Type}EventArgs -> Async) : Attr =""") + .AppendLine($""" attr.async.callback<%s{event.Type}EventArgs> "on%s{esc}" callback""") ) >> replace (Events.GetSample().Rows) "TASKEVENTS" (fun s event -> let esc = escapeDashes event.Name - s.AppendLine(sprintf """ /// Create an asynchronous handler for HTML event %s.""" event.Name) - .AppendLine( """ /// The event callback.""") - .AppendLine(sprintf """ let inline %s (callback: %sEventArgs -> Task) : Attr =""" esc event.Type) - .AppendLine(sprintf """ attr.task.callback<%sEventArgs> "on%s" callback""" event.Type esc) + s.AppendLine($""" /// Create an asynchronous handler for HTML event %s{event.Name}.""") + .AppendLine( """ /// The event callback.""") + .AppendLine($""" let inline %s{esc} (callback: %s{event.Type}EventArgs -> Task) : Attr =""") + .AppendLine($""" attr.task.callback<%s{event.Type}EventArgs> "on%s{esc}" callback""") ) ) runTags "src/Bolero.Templating.Provider/Parsing.fs" ( replace (Events.GetSample().Rows) "EVENTS" (fun s event -> if event.Type <> "" then - s.AppendLine(sprintf """ | "on%s" -> typeof<%sEventArgs>""" event.Name event.Type) + s.AppendLine($""" | "on%s{event.Name}" -> typeof<%s{event.Type}EventArgs>""") else s ) diff --git a/src/Bolero/Remoting.fs b/src/Bolero/Remoting.fs index cc41f832..4f055d9f 100644 --- a/src/Bolero/Remoting.fs +++ b/src/Bolero/Remoting.fs @@ -94,7 +94,7 @@ type RemotingExtensions = (fields, Ok []) ||> Array.foldBack (fun field res -> let fail fmt = - let msg = sprintf fmt (ty.FullName + "." + field.Name) + let msg = sprintf fmt ($"{ty.FullName}.{field.Name}") match res with | Ok _ -> Error [msg] | Error e -> Error (msg :: e)