Skip to content

Commit

Permalink
Use System.Text.Json instead of Newtonsoft.Json in Fake.Core.Integrat…
Browse files Browse the repository at this point in the history
…ionTests
  • Loading branch information
Numpsy committed Dec 18, 2024
1 parent 048b97b commit ce3af58
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
3 changes: 1 addition & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ group fakerunner
nuget Microsoft.TestPlatform.TestHost
nuget FsCheck
nuget FParsec
nuget Newtonsoft.Json

group fakemodule
source https://api.nuget.org/v3/index.json
Expand Down Expand Up @@ -68,4 +67,4 @@ group fakemodule
nuget BlackFox.VsWhere
nuget System.Runtime.Loader
nuget System.Collections.Immutable
nuget System.Data.SqlClient
nuget System.Data.SqlClient
12 changes: 6 additions & 6 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ NUGET
System.Runtime.Extensions (>= 4.3) - restriction: || (&& (== net472) (< net45)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Memory (4.5.5)
System.Buffers (>= 4.5.1) - restriction: || (== net472) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (&& (== netcoreapp2.1) (>= monotouch)) (&& (== netcoreapp2.1) (>= net461)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netstandard1.1)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (>= xamarinios)) (&& (== netcoreapp2.1) (>= xamarinmac)) (&& (== netcoreapp2.1) (>= xamarintvos)) (&& (== netcoreapp2.1) (>= xamarinwatchos)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net472) (< net45)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.4) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (== netcoreapp2.1)) (&& (== net472) (< net45)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (== netstandard2.0)
System.Numerics.Vectors (>= 4.5) - restriction: || (== net472) (&& (== net6.0) (>= net461)) (&& (== netcoreapp2.1) (>= net461)) (&& (== netstandard2.0) (>= net461))
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (== net472) (&& (== net6.0) (>= monotouch)) (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.0)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== net6.0) (>= xamarinios)) (&& (== net6.0) (>= xamarinmac)) (&& (== net6.0) (>= xamarintvos)) (&& (== net6.0) (>= xamarinwatchos)) (&& (== netcoreapp2.1) (>= monotouch)) (&& (== netcoreapp2.1) (>= net461)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netstandard1.1)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (>= uap10.1)) (&& (== netcoreapp2.1) (>= xamarinios)) (&& (== netcoreapp2.1) (>= xamarinmac)) (&& (== netcoreapp2.1) (>= xamarintvos)) (&& (== netcoreapp2.1) (>= xamarinwatchos)) (== netstandard2.0)
System.Net.Http (4.3.4) - restriction: || (&& (== net472) (< net461)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
Expand Down Expand Up @@ -1092,7 +1092,7 @@ NUGET
System.Reflection.Primitives (>= 4.3) - restriction: || (&& (== net472) (< net45)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Runtime (>= 4.3) - restriction: || (&& (== net472) (< net45)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Reflection.Emit (4.7)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net472) (< net45)) (&& (== net472) (< netstandard1.1)) (&& (== net472) (< netstandard2.0) (>= wpa81)) (&& (== net472) (>= uap10.1)) (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netstandard1.1)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (>= 4.7) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (== netcoreapp2.1)) (&& (== net472) (< net45)) (&& (== net472) (< netstandard1.1)) (&& (== net472) (< netstandard2.0) (>= wpa81)) (&& (== net472) (>= uap10.1)) (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netstandard1.1)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Emit.ILGeneration (4.7) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (== netcoreapp2.1)) (&& (== net472) (< net45)) (&& (== net472) (< netstandard1.1)) (&& (== net472) (< netstandard2.0) (>= wpa81)) (&& (== net472) (>= uap10.1)) (&& (== net6.0) (< netcoreapp2.0) (< netstandard2.1)) (&& (== net6.0) (< netstandard1.1)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= uap10.1)) (&& (== netcoreapp2.1) (< netcoreapp2.0)) (&& (== netcoreapp2.1) (< netstandard1.1)) (&& (== netcoreapp2.1) (< netstandard2.0)) (&& (== netcoreapp2.1) (>= uap10.1)) (== netstandard2.0)
System.Reflection.Metadata (8.0)
System.Collections.Immutable (>= 8.0)
Expand Down Expand Up @@ -1178,10 +1178,10 @@ NUGET
System.Security.Cryptography.OpenSsl (5.0) - restriction: || (&& (== net472) (< net45)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Formats.Asn1 (>= 5.0) - restriction: || (&& (== net472) (>= netcoreapp3.0)) (== net6.0) (&& (== netcoreapp2.1) (>= netcoreapp3.0)) (&& (== netstandard2.0) (>= netcoreapp3.0))
System.Security.Cryptography.Pkcs (7.0.3) - restriction: || (&& (== net472) (>= net5.0)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net472) (< net462)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (< net462)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Formats.Asn1 (>= 7.0) - restriction: || (&& (== net472) (< net462)) (&& (== net472) (>= netstandard2.1)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net472) (< net462)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (== net472) (< net462)) (&& (== net472) (>= netstandard2.1)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Memory (>= 4.5.5) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (< net462)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Security.Cryptography.Cng (>= 5.0) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (< net462)) (&& (== net472) (>= netstandard2.1)) (&& (== net6.0) (< netstandard2.1)) (== netcoreapp2.1) (== netstandard2.0)
System.Security.Cryptography.Primitives (4.3) - restriction: || (&& (== net472) (< net45)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Diagnostics.Debug (>= 4.3) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Globalization (>= 4.3) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
Expand All @@ -1191,7 +1191,7 @@ NUGET
System.Threading (>= 4.3) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Threading.Tasks (>= 4.3) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
System.Security.Cryptography.ProtectedData (6.0)
System.Memory (>= 4.5.4) - restriction: || (&& (== net472) (< net461)) (== netcoreapp2.1) (== netstandard2.0)
System.Memory (>= 4.5.4) - restriction: || (&& (== net472) (== net6.0)) (&& (== net472) (< net461)) (== netcoreapp2.1) (== netstandard2.0)
System.Security.Cryptography.X509Certificates (4.3.2) - restriction: || (&& (== net472) (< net45)) (&& (== net472) (< net461)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
runtime.native.System (>= 4.3) - restriction: || (&& (== net472) (< net46)) (== net6.0) (== netcoreapp2.1) (== netstandard2.0)
Expand Down
53 changes: 28 additions & 25 deletions src/test/Fake.Core.IntegrationTests/SimpleHelloWorldTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Expecto
open Expecto.Flip
open System
open System.IO
open Newtonsoft.Json.Linq
open System.Text.Json
open Fake.Core

let fail s = Expect.isTrue s false
Expand Down Expand Up @@ -216,30 +216,33 @@ let tests =
|> ignProc

let json = File.ReadAllText tempFile
let obj = JObject.Parse json
let targets = obj["targets"] :?> JArray

let parseDecl (t: JToken) =
{ File = string t["file"]
Line = int t["line"]
Column = int t["column"]
ErrorDetail = string t["errorDetail"] }

let parseDep (t: JToken) =
{ Name = string t["name"]
Declaration = parseDecl t["declaration"] }

let parseArray parseItem (a: JToken) =
(a :?> JArray) |> Seq.map parseItem |> Seq.toList

let parseTarget (t: JToken) =
{ Name = string t["name"]
Declaration = parseDecl t["declaration"]
HardDependencies = parseArray parseDep t["hardDependencies"]
SoftDependencies = parseArray parseDep t["softDependencies"]
Description = string t["description"] }

let dict = targets |> Seq.map (fun t -> let t = parseTarget t in t.Name, t) |> dict
let obj = JsonDocument.Parse(json)
let targets = obj.RootElement.GetProperty("targets")

let parseDecl (t: JsonElement) =
{ File = string (t.GetProperty("file"))
Line = t.GetProperty("line").GetInt32()
Column = t.GetProperty("column").GetInt32()
ErrorDetail = string (t.GetProperty("errorDetail")) }

let parseDep (t: JsonElement) =
{ Name = string (t.GetProperty("name"))
Declaration = parseDecl (t.GetProperty("declaration")) }

let parseArray parseItem (a: JsonElement) =
a.EnumerateArray() |> Seq.map parseItem |> Seq.toList

let parseTarget (t: JsonElement) =
{ Name = string (t.GetProperty("name"))
Declaration = parseDecl (t.GetProperty("declaration"))
HardDependencies = parseArray parseDep (t.GetProperty("hardDependencies"))
SoftDependencies = parseArray parseDep (t.GetProperty("softDependencies"))
Description = string (t.GetProperty("description")) }

let dict =
targets.EnumerateArray()
|> Seq.map (fun t -> let t = parseTarget t in t.Name, t)
|> dict

Expect.equal "Expected correct number of targets" 4 dict.Count

Expand Down
4 changes: 1 addition & 3 deletions src/test/Fake.Core.IntegrationTests/paket.references
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
group fakerunner

YoloDev.Expecto.TestSdk
Microsoft.TestPlatform.TestHost
FSharp.Core
NETStandard.Library
Expecto
FParsec
Newtonsoft.Json
FParsec

0 comments on commit ce3af58

Please sign in to comment.