From e0a868ba42c6a4bf253a73a7db1cc1f0d76f7e2c Mon Sep 17 00:00:00 2001 From: "Andy De George (from Dev Box)" Date: Thu, 26 Feb 2026 15:49:32 -0800 Subject: [PATCH 1/4] Move includes only used once into their articles --- .../datetime/how-to-use-dateonly-timeonly.md | 22 +++++++++++++++++- .../dateonly-and-timeonly-serialization-cs.md | 21 ----------------- .../dateonly-and-timeonly-serialization.md | 23 ------------------- .../datetime/system-text-json-support.md | 19 ++++++++++++++- 4 files changed, 39 insertions(+), 46 deletions(-) delete mode 100644 docs/standard/datetime/includes/dateonly-and-timeonly-serialization-cs.md delete mode 100644 docs/standard/datetime/includes/dateonly-and-timeonly-serialization.md diff --git a/docs/standard/datetime/how-to-use-dateonly-timeonly.md b/docs/standard/datetime/how-to-use-dateonly-timeonly.md index e4ebb68226a66..6f7486b8855a9 100644 --- a/docs/standard/datetime/how-to-use-dateonly-timeonly.md +++ b/docs/standard/datetime/how-to-use-dateonly-timeonly.md @@ -127,7 +127,27 @@ Because `TimeOnly` only represents a 24-hour period, it rolls over forwards or b ### Serialize DateOnly and TimeOnly types -[!INCLUDE [dateonly-and-timeonly-serialization](includes/dateonly-and-timeonly-serialization.md)] + + +Starting with .NET 7, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: + +:::code source="./snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="appointment"::: +:::code source="./snippets/how-to-use-dateonly-timeonly/vb/Program.vb" id="appointment"::: + +The following example serializes an `Appointment` object, displays the resulting JSON, and then deserializes it back into a new instance of the `Appointment` type. Finally, the original and newly deserialized instances are compared for equality and the results are written to the console: + +:::code source="./snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="serialization"::: +:::code source="./snippets/how-to-use-dateonly-timeonly/vb/Program.vb" id="serialization"::: + +In the preceding code: + +- An `Appointment` object is instantiated and assigned to the `appointment` variable. +- The `appointment` instance is serialized to JSON using . +- The resulting JSON is written to the console. +- The JSON is deserialized back into a new instance of the `Appointment` type using . +- The original and newly deserialized instances are compared for equality. +- The result of the comparison is written to the console. + For more information, see [How to serialize and deserialize JSON in .NET](../serialization/system-text-json/how-to.md). diff --git a/docs/standard/datetime/includes/dateonly-and-timeonly-serialization-cs.md b/docs/standard/datetime/includes/dateonly-and-timeonly-serialization-cs.md deleted file mode 100644 index 68d8b78560323..0000000000000 --- a/docs/standard/datetime/includes/dateonly-and-timeonly-serialization-cs.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -ms.date: 01/11/2023 -ms.topic: include ---- - -With .NET 7+, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: - -:::code source="../snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="appointment"::: - -The following example serializes an `Appointment` object, displays the resulting JSON, and then deserializes it back into a new instance of the `Appointment` type. Finally, the original and newly deserialized instances are compared for equality and the results are written to the console: - -:::code source="../snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="serialization"::: - -In the preceding code: - -- An `Appointment` object is instantiated and assigned to the `appointment` variable. -- The `appointment` instance is serialized to JSON using . -- The resulting JSON is written to the console. -- The JSON is deserialized back into a new instance of the `Appointment` type using . -- The original and newly deserialized instances are compared for equality. -- The result of the comparison is written to the console. diff --git a/docs/standard/datetime/includes/dateonly-and-timeonly-serialization.md b/docs/standard/datetime/includes/dateonly-and-timeonly-serialization.md deleted file mode 100644 index 992c3e32acd7e..0000000000000 --- a/docs/standard/datetime/includes/dateonly-and-timeonly-serialization.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -ms.date: 01/11/2023 -ms.topic: include ---- - -With .NET 7+, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: - -:::code source="../snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="appointment"::: -:::code source="../snippets/how-to-use-dateonly-timeonly/vb/Program.vb" id="appointment"::: - -The following example serializes an `Appointment` object, displays the resulting JSON, and then deserializes it back into a new instance of the `Appointment` type. Finally, the original and newly deserialized instances are compared for equality and the results are written to the console: - -:::code source="../snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="serialization"::: -:::code source="../snippets/how-to-use-dateonly-timeonly/vb/Program.vb" id="serialization"::: - -In the preceding code: - -- An `Appointment` object is instantiated and assigned to the `appointment` variable. -- The `appointment` instance is serialized to JSON using . -- The resulting JSON is written to the console. -- The JSON is deserialized back into a new instance of the `Appointment` type using . -- The original and newly deserialized instances are compared for equality. -- The result of the comparison is written to the console. diff --git a/docs/standard/datetime/system-text-json-support.md b/docs/standard/datetime/system-text-json-support.md index e995755d37193..61c91231751e2 100644 --- a/docs/standard/datetime/system-text-json-support.md +++ b/docs/standard/datetime/system-text-json-support.md @@ -59,7 +59,24 @@ If you attempt to read non-compliant formats with and types. Consider the following object: + + + +:::code source="snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="appointment"::: + +The following example serializes an `Appointment` object, displays the resulting JSON, and then deserializes it back into a new instance of the `Appointment` type. Finally, the original and newly deserialized instances are compared for equality and the results are written to the console: + +:::code source="snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="serialization"::: + +In the preceding code: + +- An `Appointment` object is instantiated and assigned to the `appointment` variable. +- The `appointment` instance is serialized to JSON using . +- The resulting JSON is written to the console. +- The JSON is deserialized back into a new instance of the `Appointment` type using . +- The original and newly deserialized instances are compared for equality. +- The result of the comparison is written to the console. ## Custom support for and From cbdf28a93a5165a3b0335076c77e8e38e953b292 Mon Sep 17 00:00:00 2001 From: "Andy De George (from Dev Box)" Date: Thu, 26 Feb 2026 15:52:17 -0800 Subject: [PATCH 2/4] Fix line --- docs/standard/datetime/how-to-use-dateonly-timeonly.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/standard/datetime/how-to-use-dateonly-timeonly.md b/docs/standard/datetime/how-to-use-dateonly-timeonly.md index 6f7486b8855a9..65a509eb75702 100644 --- a/docs/standard/datetime/how-to-use-dateonly-timeonly.md +++ b/docs/standard/datetime/how-to-use-dateonly-timeonly.md @@ -148,7 +148,6 @@ In the preceding code: - The original and newly deserialized instances are compared for equality. - The result of the comparison is written to the console. - For more information, see [How to serialize and deserialize JSON in .NET](../serialization/system-text-json/how-to.md). ### Work with TimeSpan and DateTime From c7dba5914d0cd6b9fc037c7e92086730666e644c Mon Sep 17 00:00:00 2001 From: "Andy (Steve) De George" <67293991+adegeo@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:10:23 -0800 Subject: [PATCH 3/4] Fix typo in DateOnly and TimeOnly serialization section --- docs/standard/datetime/how-to-use-dateonly-timeonly.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard/datetime/how-to-use-dateonly-timeonly.md b/docs/standard/datetime/how-to-use-dateonly-timeonly.md index 65a509eb75702..71954d5d41c04 100644 --- a/docs/standard/datetime/how-to-use-dateonly-timeonly.md +++ b/docs/standard/datetime/how-to-use-dateonly-timeonly.md @@ -129,7 +129,7 @@ Because `TimeOnly` only represents a 24-hour period, it rolls over forwards or b -Starting with .NET 7, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: +Starting in .NET 7, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: :::code source="./snippets/how-to-use-dateonly-timeonly/csharp/Program.cs" id="appointment"::: :::code source="./snippets/how-to-use-dateonly-timeonly/vb/Program.vb" id="appointment"::: From 2fa2353212e6551894936aba39a080bb378306f6 Mon Sep 17 00:00:00 2001 From: "Andy (Steve) De George" <67293991+adegeo@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:10:42 -0800 Subject: [PATCH 4/4] Fix typo in serialization support documentation --- docs/standard/datetime/system-text-json-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/standard/datetime/system-text-json-support.md b/docs/standard/datetime/system-text-json-support.md index 61c91231751e2..8d67d2948aaf5 100644 --- a/docs/standard/datetime/system-text-json-support.md +++ b/docs/standard/datetime/system-text-json-support.md @@ -59,7 +59,7 @@ If you attempt to read non-compliant formats with and types. Consider the following object: +Starting in .NET 7, `System.Text.Json` supports serializing and deserializing and types. Consider the following object: