Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/FSharp.Data.Csv.Core/CsvInference.fs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ type CsvFile with
/// <param name="assumeMissingValues"> - Assumes all columns can have missing values</param>
/// <param name="preferOptionals"> - when set to true, inference will prefer to use the option type instead of nullable types, double.NaN or "" for missing values</param>
/// <param name="unitsOfMeasureProvider"> - optional function to resolve Units of Measure</param>
/// <param name="inferenceMode"> - how to infer types: from values only, from values and units, or not at all</param>
member internal x.InferColumnTypes
(
inferRows,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ module internal ProviderHelpers =
match Uri.TryCreate(str, UriKind.RelativeOrAbsolute) with
| false, _ -> None
| true, uri ->
if str.Trim() = "" || not uri.IsAbsoluteUri && Seq.exists invalidChars.Contains str then
if
String.IsNullOrWhiteSpace str
|| not uri.IsAbsoluteUri && Seq.exists invalidChars.Contains str
then
None
else
Some uri
Expand Down
30 changes: 17 additions & 13 deletions src/FSharp.Data.Html.Core/HtmlOperations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,26 @@ module HtmlNode =
n |> elements |> List.filter (name >> nameSet.Contains)

let private descendantsBy includeSelf recurseOnMatch predicate n =
let rec descendantsBy includeSelf n =
seq {
let proceed = ref true
// one sequence with an explicit stack: pre-order, children in
// document order (pushed reversed), no enumerator per level
seq {
let stack = System.Collections.Generic.Stack<HtmlNode * bool>()
stack.Push((n, includeSelf))

if includeSelf && predicate n then
yield n
while stack.Count > 0 do
let node, considerSelf = stack.Pop()
let mutable proceed = true

if not recurseOnMatch then
proceed := false
if considerSelf && predicate node then
yield node

if !proceed then
for element in elements n do
yield! descendantsBy true element
}
if not recurseOnMatch then
proceed <- false

descendantsBy includeSelf n
if proceed then
for element in List.rev (elements node) do
stack.Push((element, true))
}

/// <summary>
/// Gets all of the descendants of this node that statisfy the given predicate
Expand Down Expand Up @@ -235,7 +239,7 @@ module HtmlNode =

/// Returns true if the current node has the specified name
let inline hasName (expectedName: string) n =
name n = expectedName.ToLowerInvariant()
String.Equals(name n, expectedName, StringComparison.OrdinalIgnoreCase)

/// Returns true if the current node has the specified id
let inline hasId id n = hasAttribute "id" id n
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.Json.Core/JsonSchema.fs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ module JsonSchema =
match Array.tryFind (fun (name, _) -> name = parts.[0]) fields with
| Some(_, value) -> navigate value parts.[1..]
| None -> failwith $"Reference part '{parts.[0]}' not found"
| _ -> failwith "Invalid reference path"
| _ -> failwith $"Invalid reference path: '{path}' does not lead through a record"

let referencedValue = navigate rootSchema parts
parseSchema referencedValue
Expand Down
Loading