diff --git a/.gitignore b/.gitignore
index 0bc215fba..6dbeb44f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,7 @@ TestResults
*.orig
Help/*
release/*
-/_ReSharper.*
+_ReSharper.*
*.pidb
*.userprefs
packages
diff --git a/Dockerfile b/Dockerfile
index af31659b8..2437eff04 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -40,15 +40,15 @@ COPY . .
RUN dotnet build -c Release --framework net47 YamlDotNet/YamlDotNet.csproj -o /output/net47
RUN dotnet build -c Release --framework netstandard2.0 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.0
RUN dotnet build -c Release --framework netstandard2.1 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.1
-RUN dotnet build -c Release --framework net60 YamlDotNet/YamlDotNet.csproj -o /output/net60
-RUN dotnet build -c Release --framework net70 YamlDotNet/YamlDotNet.csproj -o /output/net70
-RUN dotnet build -c Release --framework net80 YamlDotNet/YamlDotNet.csproj -o /output/net80
+RUN dotnet build -c Release --framework net6.0 YamlDotNet/YamlDotNet.csproj -o /output/net6.0
+RUN dotnet build -c Release --framework net7.0 YamlDotNet/YamlDotNet.csproj -o /output/net7.0
+RUN dotnet build -c Release --framework net8.0 YamlDotNet/YamlDotNet.csproj -o /output/net8.0
RUN dotnet pack -c Release YamlDotNet/YamlDotNet.csproj -o /output/package /p:Version=$PACKAGE_VERSION
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net80 --logger:"trx;LogFileName=/output/tests.net80.trx" --logger:"console;Verbosity=detailed"
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net70 --logger:"trx;LogFileName=/output/tests.net70.trx" --logger:"console;Verbosity=detailed"
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net60 --logger:"trx;LogFileName=/output/tests.net60.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net8.0 --logger:"trx;LogFileName=/output/tests-net8.0.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net7.0 --logger:"trx;LogFileName=/output/tests-net7.0.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net6.0 --logger:"trx;LogFileName=/output/tests-net6.0.trx" --logger:"console;Verbosity=detailed"
FROM alpine
VOLUME /output
diff --git a/Dockerfile.NonEnglish b/Dockerfile.NonEnglish
index 69c454a7e..20d6cf1d5 100644
--- a/Dockerfile.NonEnglish
+++ b/Dockerfile.NonEnglish
@@ -42,9 +42,9 @@ COPY . .
RUN dotnet build -c Release --framework net47 YamlDotNet/YamlDotNet.csproj -o /output/net47
RUN dotnet build -c Release --framework netstandard2.0 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.0
RUN dotnet build -c Release --framework netstandard2.1 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.1
-RUN dotnet build -c Release --framework net60 YamlDotNet/YamlDotNet.csproj -o /output/net60
-RUN dotnet build -c Release --framework net70 YamlDotNet/YamlDotNet.csproj -o /output/net70
-RUN dotnet build -c Release --framework net80 YamlDotNet/YamlDotNet.csproj -o /output/net80
+RUN dotnet build -c Release --framework net6.0 YamlDotNet/YamlDotNet.csproj -o /output/net6.0
+RUN dotnet build -c Release --framework net7.0 YamlDotNet/YamlDotNet.csproj -o /output/net7.0
+RUN dotnet build -c Release --framework net8.0 YamlDotNet/YamlDotNet.csproj -o /output/net8.0
RUN dotnet pack -c Release YamlDotNet/YamlDotNet.csproj -o /output/package /p:Version=$PACKAGE_VERSION
@@ -62,10 +62,10 @@ RUN echo -n "${LC_ALL}" > /etc/locale.gen && \
apt install -y locales && \
locale-gen
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net80 --logger:"trx;LogFileName=/output/tests.net80.trx" --logger:"console;Verbosity=detailed"
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net70 --logger:"trx;LogFileName=/output/tests.net70.trx" --logger:"console;Verbosity=detailed"
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net60 --logger:"trx;LogFileName=/output/tests.net60.trx" --logger:"console;Verbosity=detailed"
-RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework netcoreapp3.1 --logger:"trx;LogFileName=/output/tests.netcoreapp3.1.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net8.0 --logger:"trx;LogFileName=/output/tests-net8.0.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net7.0 --logger:"trx;LogFileName=/output/tests-net7.0.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework net6.0 --logger:"trx;LogFileName=/output/tests-net6.0.trx" --logger:"console;Verbosity=detailed"
+RUN dotnet test -c Release YamlDotNet.Test/YamlDotNet.Test.csproj --framework netcoreapp3.1 --logger:"trx;LogFileName=/output/tests-netcoreapp3.1.trx" --logger:"console;Verbosity=detailed"
FROM alpine
VOLUME /output
diff --git a/YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.nuspec b/YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.nuspec
index bcf94d114..e902f69d4 100644
--- a/YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.nuspec
+++ b/YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.nuspec
@@ -8,7 +8,7 @@
Roslyn Code Generator that will generate a static context for use with YamlDotNet to support ahead-of-time and library trimming.
Static context generator for YamlDotNet.
en-US
- LICENSE.txt
+ MIT
https://github.com/aaubry/YamlDotNet/wiki
http://aaubry.net/images/yamldotnet.png
images/yamldotnet.png
diff --git a/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj b/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
index 9ade62825..79208c1f6 100644
--- a/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
+++ b/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
@@ -2,7 +2,7 @@
Exe
- net80
+ net8.0
enable
enable
diff --git a/YamlDotNet.Fsharp.Test/DeserializerTests.fs b/YamlDotNet.Fsharp.Test/DeserializerTests.fs
new file mode 100644
index 000000000..3f48a4ff7
--- /dev/null
+++ b/YamlDotNet.Fsharp.Test/DeserializerTests.fs
@@ -0,0 +1,87 @@
+module DeserializerTests
+
+open System
+open Xunit
+open YamlDotNet.Serialization
+open YamlDotNet.Serialization.NamingConventions
+open FsUnit.Xunit
+open System.ComponentModel
+
+[]
+type Spec = {
+ EngineType: string
+ DriveType: string
+}
+
+[]
+type Car = {
+ Name: string
+ Year: int
+ Spec: Spec option
+ Nickname: string option
+}
+
+[]
+type Person = {
+ Name: string
+ MomentOfBirth: DateTime
+ Cars: Car array
+}
+
+[]
+let Deserialize_YamlWithScalarOptions() =
+ let yaml = """
+name: Jack
+momentOfBirth: 1983-04-21T20:21:03.0041599Z
+cars:
+- name: Mercedes
+ year: 2018
+ nickname: Jessy
+- name: Honda
+ year: 2021
+"""
+ let sut = DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
+
+ let person = sut.Deserialize(yaml)
+ person.Name |> should equal "Jack"
+ person.Cars |> should haveLength 2
+ person.Cars[0].Name |> should equal "Mercedes"
+ person.Cars[0].Nickname |> should equal (Some "Jessy")
+ person.Cars[1].Name |> should equal "Honda"
+ person.Cars[1].Nickname |> should equal None
+
+
+[]
+let Deserialize_YamlWithObjectOptions() =
+ let yaml = """
+name: Jack
+momentOfBirth: 1983-04-21T20:21:03.0041599Z
+cars:
+- name: Mercedes
+ year: 2018
+ spec:
+ engineType: V6
+ driveType: AWD
+- name: Honda
+ year: 2021
+"""
+ let sut = DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
+
+ let person = sut.Deserialize(yaml)
+ person.Name |> should equal "Jack"
+ person.Cars |> should haveLength 2
+
+ person.Cars[0].Name |> should equal "Mercedes"
+ person.Cars[0].Spec |> should not' (be null)
+ person.Cars[0].Spec |> Option.isSome |> should equal true
+ person.Cars[0].Spec.Value.EngineType |> should equal "V6"
+ person.Cars[0].Spec.Value.DriveType |> should equal "AWD"
+
+ person.Cars[1].Name |> should equal "Honda"
+ person.Cars[1].Spec |> should be null
+ person.Cars[1].Spec |> should equal None
+ person.Cars[1].Nickname |> should equal None
diff --git a/YamlDotNet.Fsharp.Test/SerializerTests.fs b/YamlDotNet.Fsharp.Test/SerializerTests.fs
new file mode 100644
index 000000000..d612647cc
--- /dev/null
+++ b/YamlDotNet.Fsharp.Test/SerializerTests.fs
@@ -0,0 +1,152 @@
+module SerializerTests
+
+open System
+open Xunit
+open YamlDotNet.Serialization
+open YamlDotNet.Serialization.NamingConventions
+open FsUnit.Xunit
+open YamlDotNet.Core
+
+[]
+type Spec = {
+ EngineType: string
+ DriveType: string
+}
+
+[]
+type Car = {
+ Name: string
+ Year: int
+ Spec: Spec option
+ Nickname: string option
+}
+
+[]
+type Person = {
+ Name: string
+ MomentOfBirth: DateTime
+ KidsSeat: int option
+ Cars: Car array
+}
+
+[]
+let Serialize_YamlWithScalarOptions() =
+ let jackTheDriver = {
+ Name = "Jack"
+ MomentOfBirth = DateTime(1983, 4, 21, 20, 21, 03, 4)
+ KidsSeat = Some 1
+ Cars = [|
+ { Name = "Mercedes"
+ Year = 2018
+ Nickname = Some "Jessy"
+ Spec = None };
+ { Name = "Honda"
+ Year = 2021
+ Nickname = None
+ Spec = None }
+ |]
+ }
+
+ let yaml = """name: Jack
+momentOfBirth: 1983-04-21T20:21:03.0040000
+kidsSeat: 1
+cars:
+- name: Mercedes
+ year: 2018
+ spec:
+ nickname: Jessy
+- name: Honda
+ year: 2021
+ spec:
+ nickname:
+"""
+ let sut = SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
+
+ let person = sut.Serialize(jackTheDriver)
+ person |> should equal yaml
+
+
+[]
+let Serialize_YamlWithScalarOptions_OmitNull() =
+ let jackTheDriver = {
+ Name = "Jack"
+ MomentOfBirth = DateTime(1983, 4, 21, 20, 21, 03, 4)
+ KidsSeat = Some 1
+ Cars = [|
+ { Name = "Mercedes"
+ Year = 2018
+ Nickname = Some "Jessy"
+ Spec = None };
+ { Name = "Honda"
+ Year = 2021
+ Nickname = None
+ Spec = None }
+ |]
+ }
+
+ let yaml = """name: Jack
+momentOfBirth: 1983-04-21T20:21:03.0040000
+kidsSeat: 1
+cars:
+- name: Mercedes
+ year: 2018
+ nickname: Jessy
+- name: Honda
+ year: 2021
+"""
+ let sut = SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
+
+ let person = sut.Serialize(jackTheDriver)
+ person |> should equal yaml
+
+
+[]
+let Serialize_YamlWithObjectOptions_OmitNull() =
+ let jackTheDriver = {
+ Name = "Jack"
+ MomentOfBirth = DateTime(1983, 4, 21, 20, 21, 03, 4)
+ KidsSeat = Some 1
+ Cars = [|
+ { Name = "Mercedes"
+ Year = 2018
+ Nickname = None
+ Spec = Some {
+ EngineType = "V6"
+ DriveType = "AWD"
+ } };
+ { Name = "Honda"
+ Year = 2021
+ Nickname = None
+ Spec = None }
+ |]
+ }
+
+ let yaml = """name: Jack
+momentOfBirth: 1983-04-21T20:21:03.0040000
+kidsSeat: 1
+cars:
+- name: Mercedes
+ year: 2018
+ spec:
+ engineType: V6
+ driveType: AWD
+- name: Honda
+ year: 2021
+"""
+ let sut = SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
+
+ let person = sut.Serialize(jackTheDriver)
+ person |> should equal yaml
+
+type TestOmit = {
+ name: string
+ plop: int option
+}
diff --git a/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj b/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj
new file mode 100644
index 000000000..300cec1f9
--- /dev/null
+++ b/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj
@@ -0,0 +1,25 @@
+
+
+ net8.0;net7.0;net6.0;net47
+ false
+ ..\YamlDotNet.snk
+ true
+ 8.0
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/YamlDotNet.Samples/YamlDotNet.Samples.csproj b/YamlDotNet.Samples/YamlDotNet.Samples.csproj
index 5ca9b2c46..e8d4b0d0e 100644
--- a/YamlDotNet.Samples/YamlDotNet.Samples.csproj
+++ b/YamlDotNet.Samples/YamlDotNet.Samples.csproj
@@ -1,7 +1,7 @@
- net80
+ net8.0
false
diff --git a/YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs b/YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs
index d1475c5fe..913f5aa89 100644
--- a/YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs
+++ b/YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs
@@ -47,22 +47,26 @@ public void LoadSimpleDocument()
Assert.Equal(YamlNodeType.Scalar, stream.Documents[0].RootNode.NodeType);
}
- [Fact]
- public void AccessingAllNodesOnInfinitelyRecursiveDocumentThrows()
+ [Theory]
+ [InlineData("&a [*a]")]
+ [InlineData("?\n key: &id1\n recursion: *id1\n: foo")]
+ public void AccessingAllNodesOnInfinitelyRecursiveDocumentThrows(string yaml)
{
var stream = new YamlStream();
- stream.Load(Yaml.ParserForText("&a [*a]"));
+ stream.Load(Yaml.ParserForText(yaml));
var accessAllNodes = new Action(() => stream.Documents.Single().AllNodes.ToList());
accessAllNodes.ShouldThrow("because the document is infinitely recursive.");
}
- [Fact]
- public void InfinitelyRecursiveNodeToStringSucceeds()
+ [Theory]
+ [InlineData("&a [*a]")]
+ [InlineData("?\n key: &id1\n recursion: *id1\n: foo")]
+ public void InfinitelyRecursiveNodeToStringSucceeds(string yaml)
{
var stream = new YamlStream();
- stream.Load(Yaml.ParserForText("&a [*a]"));
+ stream.Load(Yaml.ParserForText(yaml));
var toString = stream.Documents.Single().RootNode.ToString();
diff --git a/YamlDotNet.Test/Serialization/DeserializerTest.cs b/YamlDotNet.Test/Serialization/DeserializerTest.cs
index 95ce8a39a..526596fc3 100644
--- a/YamlDotNet.Test/Serialization/DeserializerTest.cs
+++ b/YamlDotNet.Test/Serialization/DeserializerTest.cs
@@ -265,7 +265,7 @@ public static IEnumerable