diff --git a/AltCover.Engine/Json.fs b/AltCover.Engine/Json.fs index b20ba4006..0853c9bbe 100644 --- a/AltCover.Engine/Json.fs +++ b/AltCover.Engine/Json.fs @@ -13,7 +13,7 @@ open Manatee.Json module internal Json = let internal path : Option ref = ref None - let simpleAttributeToValue (a:XAttribute) = + let internal simpleAttributeToValue (a:XAttribute) = let value = a.Value let b,v = Double.TryParse value if b then JsonValue v @@ -22,7 +22,7 @@ module internal Json = if b2 then JsonValue v2 else JsonValue value - let mappedElementToJSon mappings (xElement : XElement) = + let internal mappedElementToJSon mappings (xElement : XElement) = let element = JsonObject() if xElement.HasAttributes then @@ -38,10 +38,10 @@ module internal Json = element.Add (a.Name.LocalName, attribute)) JsonValue element - let simpleElementToJSon (xElement : XElement) = + let internal simpleElementToJSon (xElement : XElement) = mappedElementToJSon [] xElement - let addMethodSeqpnts (mjson:JsonValue) (m:XContainer) = + let internal addMethodSeqpnts (mjson:JsonValue) (m:XContainer) = let seqpnts = JsonArray() m.Descendants(XName.Get "seqpnt") |> Seq.iter(fun sp -> @@ -51,7 +51,7 @@ module internal Json = if seqpnts.Count > 0 then mjson.Object.Add("seqpnt", JsonValue seqpnts) - let addModuleMethods (mjson:JsonValue) (m:XElement) = + let internal addModuleMethods (mjson:JsonValue) (m:XElement) = let methods = JsonArray() m.Descendants(XName.Get "method") |> Seq.iter(fun m2 -> @@ -62,7 +62,10 @@ module internal Json = if methods.Count > 0 then mjson.Object.Add("method", JsonValue methods) - let addGenericGroup mappings group item f (json:JsonValue) (x:XContainer) = + [] + let internal addGenericGroup mappings group item f (json:JsonValue) (x:XContainer) = let items = JsonArray() x.Descendants(XName.Get group) |> Seq.collect (fun f -> f.Descendants(XName.Get item)) @@ -74,10 +77,10 @@ module internal Json = if items.Count > 0 then json.Object.Add(item, JsonValue items) - let addTerminalGroup mappings group item (json:JsonValue) (x:XContainer) = + let internal addTerminalGroup mappings group item (json:JsonValue) (x:XContainer) = addGenericGroup mappings group item (fun _ _ -> ()) json x - let formatSingleTime (t:String) = + let internal formatSingleTime (t:String) = let formatTimeValue l = let million = 1000000L let rem = (l/million)*million @@ -92,17 +95,17 @@ module internal Json = |> Seq.tryHead |> Option.defaultValue JsonValue.Null - let formatTimeValue (a:XAttribute) = + let internal formatTimeValue (a:XAttribute) = formatSingleTime a.Value - let formatTimeList (a:XAttribute) = + let internal formatTimeList (a:XAttribute) = a.Value.Split([|';'|], StringSplitOptions.RemoveEmptyEntries) |> Seq.map formatSingleTime |> Seq.filter (fun t -> t <> JsonValue.Null) |> JsonArray |> JsonValue - let formatOffsetChain (a:XAttribute) = + let internal formatOffsetChain (a:XAttribute) = a.Value.Split([|' '|], StringSplitOptions.RemoveEmptyEntries) |> Seq.map Int32.TryParse |> Seq.filter fst @@ -110,12 +113,12 @@ module internal Json = |> JsonArray |> JsonValue - let addMethodPoints mappings group item (json:JsonValue) (x:XContainer) = + let internal addMethodPoints mappings group item (json:JsonValue) (x:XContainer) = addGenericGroup mappings group item (fun point x -> addTerminalGroup ["time", formatTimeValue ]"Times" "Time" point x addTerminalGroup [] "TrackedMethodRefs" "TrackedMethodRef" point x) json x - let addIntermediateGroup group item perItem (json:JsonValue) (x:XContainer) = + let internal addIntermediateGroup group item perItem (json:JsonValue) (x:XContainer) = let items = JsonArray() x.Descendants(XName.Get group) |> Seq.collect (fun c -> c.Descendants(XName.Get item)) @@ -123,7 +126,7 @@ module internal Json = if items.Count > 0 then json.Object.Add(item, JsonValue items) - let addClassMethods (mjson:JsonValue) (m:XContainer) = + let internal addClassMethods (mjson:JsonValue) (m:XContainer) = addIntermediateGroup "Methods" "Method" (fun items x -> let ``method`` = simpleElementToJSon x items.Add ``method`` @@ -149,7 +152,7 @@ module internal Json = addMethodPoints ["offsetchain", formatOffsetChain ] "BranchPoints" "BranchPoint" ``method`` x ) mjson m - let addModuleClasses (mjson:JsonValue) (m:XContainer) = + let internal addModuleClasses (mjson:JsonValue) (m:XContainer) = addIntermediateGroup "Classes" "Class" (fun items c -> let ``class`` = simpleElementToJSon c items.Add ``class`` @@ -167,7 +170,7 @@ module internal Json = addClassMethods ``class`` c ) mjson m - let topLevelToJson coverage ``module`` f report = + let internal topLevelToJson coverage ``module`` f report = let json = simpleElementToJSon report let modules = JsonArray() f json report modules