Skip to content

Update TomlFloat and DecimalFormatter#100

Merged
prozolic merged 3 commits into
mainfrom
pr
Mar 24, 2026
Merged

Update TomlFloat and DecimalFormatter#100
prozolic merged 3 commits into
mainfrom
pr

Conversation

@prozolic

Copy link
Copy Markdown
Owner

This PR change TomlFloat and DecimalFormatter process.

Change:

  • TomlFloat: Utf8Parser.TryParse
  • DecimalFormatter : TomlDocumentNode.TryGetDouble and Utf8TomlDocumentWriter.WriteDecimal

This change was created by Claude Code.

Copilot AI review requested due to automatic review settings March 24, 2026 13:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates numeric handling in CsToml by switching float parsing to Utf8Parser.TryParse and refactoring decimal serialization/deserialization to use TomlDocumentNode.TryGetDouble plus a new Utf8TomlDocumentWriter.WriteDecimal helper, with added test coverage for float boundaries and generated decimal types.

Changes:

  • Update TomlFloat.Parse to use System.Buffers.Text.Utf8Parser.TryParse.
  • Add Utf8TomlDocumentWriter.WriteDecimal and use it from DecimalFormatter / NullableDecimalFormatter.
  • Add/extend tests for float boundary values and generator-driven decimal serialization/deserialization.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/CsToml.Tests/DefaultTest.cs Adds additional float boundary tests (max/min/epsilon, exponents, negative zero).
tests/CsToml.Generator.Tests/Generator/TypeDecimalTest.cs New generator tests for decimal serialization/deserialization, including many edge cases.
tests/CsToml.Generator.Tests/Declarations/TypeDeclarations.cs Adds a generated TypeDecimal model for generator tests.
src/CsToml/Values/TomlFloat.cs Switches float parsing to Utf8Parser.TryParse.
src/CsToml/Utf8TomlDocumentWriter.cs Adds WriteDecimal(decimal) implementation.
src/CsToml/Formatter/DecimalFormatter.cs Refactors decimal formatter to deserialize via TryGetDouble and serialize via WriteDecimal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/CsToml/Values/TomlFloat.cs Outdated
Comment thread src/CsToml/Formatter/DecimalFormatter.cs
Comment thread src/CsToml/Formatter/DecimalFormatter.cs
Comment thread tests/CsToml.Tests/DefaultTest.cs
Comment thread tests/CsToml.Generator.Tests/Generator/TypeDecimalTest.cs Outdated
Comment thread tests/CsToml.Generator.Tests/Generator/TypeDecimalTest.cs
Comment thread tests/CsToml.Generator.Tests/Generator/TypeDecimalTest.cs
prozolic and others added 2 commits March 24, 2026 22:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants