Retarget to .NET Standard 2.0#20
Closed
syedrizwanmy wants to merge 8 commits intotoon-format:mainfrom
Closed
Conversation
added 4 commits
December 8, 2025 00:46
- Convert file-scoped namespaces to traditional format - Fix nullable type declarations - Replace BitConverter.SingleToInt32Bits with unsafe code - Fix double.IsFinite/float.IsFinite checks - Fix StreamReader constructor calls - Fix collection expressions and char-to-string conversions - Fix regex pattern for numeric-like string detection - Convert test namespaces from file-scoped to traditional
added 4 commits
December 8, 2025 00:51
Restore file-level #nullable enable directives that were present in the original code. The project-level <Nullable>enable</Nullable> setting is maintained, and file-level directives provide explicit per-file control and match the original code style.
Restore all nullable annotations (JsonNode?, JsonObject?, JsonArray?) that were present in the original code. This includes: - Method return types and parameters - Property types in internal classes - Generic type parameters in collections - Restore IReadOnlySet<string>? to ISet<string>? (IReadOnlySet not available in .NET Standard 2.0)
…ine, and related types Restore all nullable annotations that were removed: - ArrayHeaderParseResult? return type - ArrayHeaderInfo.Key as string? - ArrayHeaderParseResult.InlineValues as string? - ParsedLine? return types for Peek(), Next(), Current(), PeekAtDepth() - JsonNode? return type for ParsePrimitiveToken() - string? key variable in ParseArrayHeaderLine()
- Remove PR_DESCRIPTION.md and test-failures-before-retargeting.txt from tracking - Restore string? inlineValues nullable annotation in DecodeArrayFromHeader and DecodeInlinePrimitiveArray
Contributor
|
Thanks for your contribution, this will help expand support greatly! We're working on getting the library in alignment with the V3 Toon Spec. Once we have this, we'll have to resolve some conflicts here. |
|
Related to #25 |
Contributor
|
Closing in favor of #28 which has a smaller surface area of change |
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.
Retarget to .NET Standard 2.0
Motivation
This PR retargets the
toon-dotnetlibrary from .NET 8.0/9.0 to .NET Standard 2.0, significantly expanding compatibility to include:This change makes the library accessible to a much broader range of .NET applications, including legacy projects and enterprise environments that may not have upgraded to the latest .NET versions.
Benefits
✅ Maximum Compatibility: Works with .NET Framework 4.6.1+ and all modern .NET versions
✅ Enterprise Ready: Supports legacy systems that haven't migrated to .NET 8/9
✅ Broader Adoption: Enables usage in projects constrained to older .NET versions
✅ No Breaking Changes: API remains identical, only the target framework changes
Technical Details
Framework Changes
ToonFormat.csproj): Retargeted fromnet8.0;net9.0tonetstandard2.0ToonFormat.Tests.csproj): Retargeted fromnet9.0tonetcoreapp3.1(compatible with .NET Standard 2.0)ToonFormat.SpecGenerator.csproj): Kept atnet9.0(tool-only, no compatibility requirement)Code Compatibility Fixes
To ensure compatibility with .NET Standard 2.0 and C# 9.0, the following changes were made:
Language Version: Upgraded to C# 9.0 (from 7.3) to support nullable reference types while maintaining .NET Standard 2.0 compatibility
Namespace Conversions: Converted all file-scoped namespaces (
namespace X;) to traditional format (namespace X { ... })Nullable Types: Fixed nullable type declarations:
intparameters withnulldefaults toint?ToonFormatExceptionproperties to use nullable typesAPI Compatibility:
BitConverter.SingleToInt32Bits()(not available in .NET Standard 2.0) with unsafe codedouble.IsFinite()/float.IsFinite()withIsNaN()/IsInfinity()checksStreamReaderconstructor calls to includebufferSizeparameterIReadOnlySet<T>toISet<T>for compatibilityrequiredkeyword usage (C# 11 feature)Regex Pattern Fix: Fixed malformed regex pattern in
ValidationShared.cs:"^-\\d+(:\\.\\d+)(:e[+-]\\d+)$"(invalid syntax)"^-?\\d+(\\.\\d+)?(e[+-]?\\d+)?$"(correct pattern)QuotesStringThatLooksLikeScientificNotationtest failureDependencies: Added explicit
System.Text.Json8.0.0 NuGet package reference (required for .NET Standard 2.0)Test Results
Before Retargeting: 16 failing tests (documented in
test-failures-before-retargeting.txt)After Retargeting: 16 failing tests (same tests, all pre-existing)
✅ All tests that were passing before retargeting continue to pass
✅ One new test failure was identified and fixed (
QuotesStringThatLooksLikeScientificNotation)The 16 remaining failures are all pre-existing issues unrelated to the retargeting:
Package Compatibility
✅ Successfully builds and packages as
.nupkg✅
System.Text.Json8.0.0 is compatible with .NET Standard 2.0✅ All dependencies resolve correctly
Documentation Updates
README.mdto reflect .NET Standard 2.0 targetCONTRIBUTING.mdto document .NET Standard 2.0 supportTesting
Checklist
Breaking Changes
None - This is a purely additive change that expands compatibility without modifying the public API.
Migration Guide
No migration required! The library works exactly the same way, just with broader framework support.
For projects already using the library:
Note: This PR includes comprehensive test failure documentation in
test-failures-before-retargeting.txtfor reference.