Custom naming policy: retarget net10.0, consolidate four projects to two, NUnit 4 - #2155
Open
vladimir-pecanac-main wants to merge 1 commit into
Open
Conversation
…two, NUnit 4 - Both surviving projects move from net7 to net10.0. - The .NET8 sample and its four tests merge into CustomNamingPolicy and Test; both .NET8 projects are deleted and the solution loses their entries. The split only existed because the .NET 8 policies would not compile on net7. CustomNamingPolicy.NET8.Test had no ProjectReference, so nothing depended on the removed projects. - Test packages to current stable: NUnit 4.6.1, NUnit3TestAdapter 6.3.0, NUnit.Analyzers 4.14.0, Microsoft.NET.Test.Sdk 18.9.0, coverlet.collector 10.0.1. The seven assertions move to Assert.That(..., Is.EqualTo(...)). - Program.cs converts to top-level statements, which also removes a class that shared its name with its namespace. - NodeSeparatorPolicy uses ArgumentNullException.ThrowIfNull and CamelCasePolicy uses a range indexer; both land in the article's snippets. Build: 0 warnings, 0 errors. Tests: 7/7 passing. SDK 10.0.302, runtime 10.0.10.
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 republished article "JsonNamingPolicy in C#: Built-in and Custom Naming Policies" (
/csharp-custom-naming-policy-for-json/).What changed
net7->net10.0on both surviving projects. The moniker was the non-canonicalnet7, and it is out of support either way.CustomNamingPolicy.NET8(the built-in-policy demo) andCustomNamingPolicy.NET8.Test(its four tests) merge intoCustomNamingPolicyandTest, and the solution loses their two entries. The split existed only because the .NET 8 policies would not compile onnet7; atnet10.0that reason is gone.CustomNamingPolicy.NET8.Test.csprojcarried noProjectReferenceat all - its tests exerciseJsonNamingPolicystatics from the BCL - so nothing depended on the removed projects.Assert.AreEqualcalls move toAssert.That(actual, Is.EqualTo(expected)).Program.csconverts to top-level statements, matching the article's snippets and removing a class that shared its name with its namespace.ArgumentNullException.ThrowIfNull(name)inNodeSeparatorPolicy, andname[1..]inCamelCasePolicy. Both land in the article's code blocks in the same edit.Person.surNameis left exactly as it is on purpose. The deliberately lower-cased property is the article's demonstration that the serializer copies member names verbatim.Verification
SDK 10.0.302, runtime 10.0.10.
dotnet build -c Release: 0 errors, 0 warnings.dotnet test -c Release: 7/7 passing (3 existing plus the 4 moved).dotnet runprints, in order:Every output string quoted in the article matches this run.