diff --git a/Directory.Build.props b/Directory.Build.props
index 6df06ad9..4901cc7b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -10,7 +10,13 @@
+ 9999
+ True
12.0
+
+
+ true
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index b6940f44..c23f4025 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -9,6 +9,7 @@
+
diff --git a/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj b/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
index 1f21fa0a..a7f96711 100644
--- a/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
+++ b/YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj
@@ -1,27 +1,27 @@
-
- Exe
- net8.0;net472
- enable
- enable
-
+
+ Exe
+ net8.0;net472
+ enable
+ enable
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs b/YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs
index 241c9618..0f324e09 100644
--- a/YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs
+++ b/YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs
@@ -1,4 +1,25 @@
-namespace YamlDotNet.Core7AoTCompileTest.Model;
+// This file is part of YamlDotNet - A .NET library for YAML.
+// Copyright (c) Antoine Aubry and contributors
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of
+// this software and associated documentation files (the "Software"), to deal in
+// the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+// of the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+namespace YamlDotNet.Core7AoTCompileTest.Model;
public class ExternalModel
{
diff --git a/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj b/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj
index 89b0c600..30402ac0 100644
--- a/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj
+++ b/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj
@@ -4,7 +4,6 @@
net8.0
enable
enable
- true
diff --git a/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj b/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj
index 0fe07dab..aaeb2c1d 100644
--- a/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj
+++ b/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj
@@ -6,7 +6,6 @@
true
true
enable
- true
@@ -17,7 +16,6 @@
bin\Debug\
DEBUG;TRACE
prompt
- 4
diff --git a/YamlDotNet.Fsharp.Test/DeserializerTests.fs b/YamlDotNet.Fsharp.Test/DeserializerTests.fs
index 9e0bb282..422f5cfe 100644
--- a/YamlDotNet.Fsharp.Test/DeserializerTests.fs
+++ b/YamlDotNet.Fsharp.Test/DeserializerTests.fs
@@ -8,29 +8,33 @@ open YamlDotNet.Serialization.NamingConventions
open System.ComponentModel
[]
-type Spec = {
- EngineType: string
- DriveType: string
-}
+type Spec =
+ {
+ EngineType: string
+ DriveType: string
+ }
[]
-type Car = {
- Name: string
- Year: int
- Spec: Spec option
- Nickname: string option
-}
+type Car =
+ {
+ Name: string
+ Year: int
+ Spec: Spec option
+ Nickname: string option
+ }
[]
-type Person = {
- Name: string
- MomentOfBirth: DateTime
- Cars: Car array
-}
+type Person =
+ {
+ Name: string
+ MomentOfBirth: DateTime
+ Cars: Car array
+ }
[]
-let Deserialize_YamlWithScalarOptions() =
- let yaml = """
+let Deserialize_YamlWithScalarOptions () =
+ let yaml =
+ """
name: Jack
momentOfBirth: 1983-04-21T20:21:03.0041599Z
cars:
@@ -40,21 +44,24 @@ cars:
- name: Honda
year: 2021
"""
- let sut = DeserializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Deserialize(yaml)
Assert.Equal("Jack", person.Name)
Assert.Equal(2, person.Cars.Length)
Assert.Equal("Mercedes", person.Cars[0].Name)
- Assert.Equal(Some "Jessy", person.Cars[0].Nickname)// |> should equal (Some "Jessy")
+ Assert.Equal(Some "Jessy", person.Cars[0].Nickname) // |> should equal (Some "Jessy")
Assert.Equal("Honda", person.Cars[1].Name)
Assert.Equal(None, person.Cars[1].Nickname)
[]
-let Deserialize_YamlWithObjectOptions() =
- let yaml = """
+let Deserialize_YamlWithObjectOptions () =
+ let yaml =
+ """
name: Jack
momentOfBirth: 1983-04-21T20:21:03.0041599Z
cars:
@@ -66,48 +73,56 @@ cars:
- name: Honda
year: 2021
"""
- let sut = DeserializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Deserialize(yaml)
Assert.Equal("Jack", person.Name)
Assert.Equal(2, person.Cars.Length)
-
+
Assert.Equal("Mercedes", person.Cars[0].Name)
Assert.NotNull(person.Cars[0].Spec)
Assert.True(person.Cars[0].Spec |> Option.isSome)
Assert.Equal("V6", person.Cars[0].Spec.Value.EngineType)
Assert.Equal("AWD", person.Cars[0].Spec.Value.DriveType)
-
+
Assert.Equal("Honda", person.Cars[1].Name)
Assert.Null(person.Cars[1].Spec)
Assert.Equal(None, person.Cars[1].Spec)
Assert.Equal(None, person.Cars[1].Nickname)
-
[]
-type TestSeq = {
- name: string
- numbers: int seq
-}
+[]
+type TestSeq = { name: string; numbers: int seq }
[]
-let Deserialize_YamlSeq() =
- let jackTheDriver = {
- name = "Jack"
- numbers = seq { 12; 2; 2 }
- }
-
- let yaml = """name: Jack
+let Deserialize_YamlSeq () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers =
+ seq {
+ 12
+ 2
+ 2
+ }
+ }
+
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = DeserializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Deserialize(yaml)
Assert.Equal(jackTheDriver.name, person.name)
@@ -118,27 +133,28 @@ numbers:
Assert.Equal(2, numbers[2])
[]
-type TestList = {
- name: string
- numbers: int list
-}
+type TestList = { name: string; numbers: int list }
[]
-let Deserialize_YamlList() =
- let jackTheDriver = {
- name = "Jack"
- numbers = [ 12; 2; 2 ]
- }
-
- let yaml = """name: Jack
+let Deserialize_YamlList () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers = [ 12; 2; 2 ]
+ }
+
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = DeserializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Deserialize(yaml)
Assert.Equal(jackTheDriver.name, person.name)
@@ -148,29 +164,29 @@ numbers:
Assert.Equal(2, numbers[1])
Assert.Equal(2, numbers[2])
-
[]
-type TestArray = {
- name: string
- numbers: int array
-}
+type TestArray = { name: string; numbers: int array }
[]
-let Deserialize_YamlArray() =
- let jackTheDriver = {
- name = "Jack"
- numbers = [| 12; 2; 2 |]
- }
-
- let yaml = """name: Jack
+let Deserialize_YamlArray () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers = [| 12; 2; 2 |]
+ }
+
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = DeserializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ DeserializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Deserialize(yaml)
Assert.Equal(jackTheDriver.name, person.name)
diff --git a/YamlDotNet.Fsharp.Test/SerializerTests.fs b/YamlDotNet.Fsharp.Test/SerializerTests.fs
index a7bd209b..c8ad17c6 100644
--- a/YamlDotNet.Fsharp.Test/SerializerTests.fs
+++ b/YamlDotNet.Fsharp.Test/SerializerTests.fs
@@ -8,46 +8,56 @@ open YamlDotNet.Core
open YamlDotNet.Fsharp.Test
[]
-type Spec = {
- EngineType: string
- DriveType: string
-}
+type Spec =
+ {
+ EngineType: string
+ DriveType: string
+ }
[]
-type Car = {
- Name: string
- Year: int
- Spec: Spec option
- Nickname: string option
-}
+type Car =
+ {
+ Name: string
+ Year: int
+ Spec: Spec option
+ Nickname: string option
+ }
[]
-type Person = {
- Name: string
- MomentOfBirth: DateTime
- KidsSeat: int option
- Cars: Car array
-}
+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 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
+ let yaml =
+ """name: Jack
momentOfBirth: 1983-04-21T20:21:03.0040000
kidsSeat: 1
cars:
@@ -60,32 +70,41 @@ cars:
spec:
nickname:
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
[]
-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 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
+ let yaml =
+ """name: Jack
momentOfBirth: 1983-04-21T20:21:03.0040000
kidsSeat: 1
cars:
@@ -95,36 +114,42 @@ cars:
- name: Honda
year: 2021
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
[]
-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 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
+ let yaml =
+ """name: Jack
momentOfBirth: 1983-04-21T20:21:03.0040000
kidsSeat: 1
cars:
@@ -136,91 +161,97 @@ cars:
- name: Honda
year: 2021
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
[]
-type TestSeq = {
- name: string
- numbers: int seq
-}
+[]
+type TestSeq = { name: string; numbers: int seq }
[]
-let Serialize_YamlSeq() =
- let jackTheDriver = {
- name = "Jack"
- numbers = [ 12; 2; 2 ]
- }
+let Serialize_YamlSeq () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers = [ 12; 2; 2 ]
+ }
- let yaml = """name: Jack
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
[]
-type TestList = {
- name: string
- numbers: int list
-}
+type TestList = { name: string; numbers: int list }
[]
-let Serialize_YamlList() =
- let jackTheDriver = {
- name = "Jack"
- numbers = [ 12; 2; 2 ]
- }
+let Serialize_YamlList () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers = [ 12; 2; 2 ]
+ }
- let yaml = """name: Jack
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
[]
-type TestArray = {
- name: string
- numbers: int array
-}
+type TestArray = { name: string; numbers: int array }
[]
-let Serialize_YamlArray() =
- let jackTheDriver = {
- name = "Jack"
- numbers = [| 12; 2; 2 |]
- }
+let Serialize_YamlArray () =
+ let jackTheDriver =
+ {
+ name = "Jack"
+ numbers = [| 12; 2; 2 |]
+ }
- let yaml = """name: Jack
+ let yaml =
+ """name: Jack
numbers:
- 12
- 2
- 2
"""
- let sut = SerializerBuilder()
- .WithNamingConvention(CamelCaseNamingConvention.Instance)
- .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
- .Build()
+
+ let sut =
+ SerializerBuilder()
+ .WithNamingConvention(CamelCaseNamingConvention.Instance)
+ .ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
+ .Build()
let person = sut.Serialize(jackTheDriver)
Assert.Equal(yaml.Clean(), person.Clean())
diff --git a/YamlDotNet.Fsharp.Test/StringExtensions.fs b/YamlDotNet.Fsharp.Test/StringExtensions.fs
index 5bf956d2..5094b2f3 100644
--- a/YamlDotNet.Fsharp.Test/StringExtensions.fs
+++ b/YamlDotNet.Fsharp.Test/StringExtensions.fs
@@ -7,9 +7,9 @@ type StringExtensions() =
[]
static member NormalizeNewLines(x: string) =
x.Replace("\r\n", "\n").Replace("\n", System.Environment.NewLine)
+
[]
- static member TrimNewLines(x: string) =
- x.TrimEnd('\r').TrimEnd('\n')
+ static member TrimNewLines(x: string) = x.TrimEnd('\r').TrimEnd('\n')
+
[]
- static member Clean(x: string) =
- x.NormalizeNewLines().TrimNewLines()
+ static member Clean(x: string) = x.NormalizeNewLines().TrimNewLines()
diff --git a/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj b/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj
index f330335e..9c61a02e 100644
--- a/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj
+++ b/YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj
@@ -1,4 +1,4 @@
-
+
net8.0;net6.0;net47
false
@@ -6,7 +6,7 @@
true
true
- true
+ 5
@@ -15,9 +15,13 @@
+
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/YamlDotNet.Samples.Fsharp/DeserializeObjectGraph.fs b/YamlDotNet.Samples.Fsharp/DeserializeObjectGraph.fs
index 6a2e0bb5..daa9626e 100644
--- a/YamlDotNet.Samples.Fsharp/DeserializeObjectGraph.fs
+++ b/YamlDotNet.Samples.Fsharp/DeserializeObjectGraph.fs
@@ -24,6 +24,7 @@ type Address =
State: string }
[]
+[]
type Order =
{ Receipt: string
Date: DateTime
diff --git a/YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj b/YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj
index c0a9f26e..72f23d12 100644
--- a/YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj
+++ b/YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj
@@ -5,6 +5,7 @@
net8.0
false
+ 5
diff --git a/YamlDotNet.Samples/UseTypeConverters.cs b/YamlDotNet.Samples/UseTypeConverters.cs
index f60f0d73..b141767c 100644
--- a/YamlDotNet.Samples/UseTypeConverters.cs
+++ b/YamlDotNet.Samples/UseTypeConverters.cs
@@ -33,7 +33,7 @@ namespace YamlDotNet.Samples
{
public class UseTypeConverters
{
- ITestOutputHelper output;
+ private readonly ITestOutputHelper output;
public UseTypeConverters(ITestOutputHelper output)
{
diff --git a/YamlDotNet.Test/Analyzers/StaticGenerator/RootCollectionTests.cs b/YamlDotNet.Test/Analyzers/StaticGenerator/RootCollectionTests.cs
index 70614e63..0ce08fb1 100644
--- a/YamlDotNet.Test/Analyzers/StaticGenerator/RootCollectionTests.cs
+++ b/YamlDotNet.Test/Analyzers/StaticGenerator/RootCollectionTests.cs
@@ -80,7 +80,7 @@ public void RootObjectWorks()
b: world
";
- var actual = (IDictionary