XML deserialization in C#: retarget net10.0, cache the serializer, read the XML files - #2231
Open
vladimir-pecanac-main wants to merge 1 commit into
Conversation
…ad the XML files - Retarget both projects from net7.0 to net10.0. - Collapse MSTest.TestAdapter and MSTest.TestFramework 2.2.10 into MSTest 4.4.1; Microsoft.NET.Test.Sdk 18.10.1, coverlet.collector 10.0.1. - Program.cs moves to top-level statements. The Person and Library examples read person.xml and library.xml, which the project already copies to the output folder, so the sample runs the same code as the article. The record examples keep their raw strings. - Remove the stray BlobBuilder using directive and the duplicated one-line PersonRecord example (it also carried the only CS8602 warning of the retarget). - DeserializeXmlData<T> moves into its own static class, XmlDeserializer; the four test call sites follow it. - Remove the unreachable private LibraryRecord(List<BookRecord>) constructor. - Add PersonSerializer, a static readonly XmlSerializer built with an XmlRootAttribute, and a test for it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sample update for the article XML Deserialization in C# (https://code-maze.com/csharp-xml-deserialization/). This PR touches only xml-csharp/XMLDeserializationInCsharp.
Changes:
using static System.Reflection.Metadata.BlobBuilder;and the duplicated PersonRecord example squashed onto one line. That line was also the only warning the retarget produced (CS8602), so the build is now warning free.Package versions were re-queried on nuget.org on 2026-09-23, the day this PR opened: MSTest 4.4.1 and Microsoft.NET.Test.Sdk 18.10.1 are newer than the 4.4.0 and 18.10.0 in the batch plan, so the newer ones are used. coverlet.collector 10.0.1 is unchanged.
Verified locally on SDK 10.0.302, runtime 10.0.10: dotnet build -c Release, 0 warnings, 0 errors. dotnet test, 5 passed, 0 failed. dotnet list package --vulnerable --include-transitive reports no vulnerable packages. dotnet run prints both XML files and both record examples.