[repo-assist] feat: declare IParsable(T), ISpanParsable(T), and IMinMaxValue(T)#187
Merged
NichUK merged 1 commit intoJun 17, 2026
Conversation
…erfaces FixedPointNano already had Parse/TryParse methods and MaxValue/MinValue properties. This commit formally declares the three interfaces on the struct so consumers can use generic constraints against them. Also adds 11 tests covering Parse, TryParse, and the new interface contracts via generic helper methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR formally declares IParsable<FixedPointNano>, ISpanParsable<FixedPointNano>, and IMinMaxValue<FixedPointNano> on the FixedPointNano struct so consumers can use generic constraints for parsing and bounds in generic-math scenarios. The underlying members already existed; this change makes the type “discoverable” to generic code and adds targeted tests to prevent regressions.
Changes:
- Added
IParsable<T>,ISpanParsable<T>, andIMinMaxValue<T>toFixedPointNano’s implemented interface list (no method body changes). - Added parsing and interface-constraint tests covering string/span parse, invalid inputs, convenience overloads, culture-specific parsing, and
MinValue/MaxValueexposure.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/FixedPointNano/FixedPointNano.cs |
Declares IParsable<T>, ISpanParsable<T>, and IMinMaxValue<T> on the struct to enable generic constraints. |
tests/FixedPointNano.Tests/FixedPointNanoTests.cs |
Adds tests validating parsing behavior and that the new interfaces work via generic constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3 tasks
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.
🤖 This is an automated pull request from Repo Assist.
Summary
FixedPointNanoalready hadParse/TryParsemethods andMaxValue/MinValueproperties, but had not formally declared the corresponding generic-math interfaces. This PR wires up three lightweight interface declarations so consumers can use them with generic constraints.Changes
src/FixedPointNano/FixedPointNano.cs— three interfaces added to the struct declaration:IParsable<FixedPointNano>Parse(string, IFormatProvider?),TryParse(string?, IFormatProvider?, out T)ISpanParsable<FixedPointNano>Parse(ReadOnlySpan<char>, IFormatProvider?),TryParse(ReadOnlySpan<char>, IFormatProvider?, out T)IMinMaxValue<FixedPointNano>MaxValue,MinValueNo method bodies were added or changed — only the
struct : ...interface list.tests/FixedPointNano.Tests/FixedPointNanoTests.cs— 11 new test methods covering:ParseShouldRoundtripFormattedValuesParseSpanShouldRoundtripFormattedValuesParseShouldThrowOnInvalidInputTryParseShouldReturnTrueForValidInputTryParseShouldReturnFalseForInvalidInputTryParseSpanShouldWorkCorrectlyTryParseConvenienceOverloadsShouldWorkParseShouldUseFormatProviderForCultureSpecificInputIParsableInterfaceShouldWork(via generic constraintwhere T : IParsable<T>)ISpanParsableInterfaceShouldWork(via generic constraintwhere T : ISpanParsable<T>)IMinMaxValueInterfaceShouldExposeCorrectBounds(via generic constraintwhere T : IMinMaxValue<T>)Rationale
Declaring these interfaces enables:
IParsable<T>orISpanParsable<T>to work withFixedPointNanowithout a castIMinMaxValue<T>allows generic range-checking utilities to useFixedPointNanodirectlyThese are the natural next step after
IParsable/ISpanParsablewere discussed in memory as the pending follow-up.Test Status
All 1437 tests pass (11 new tests added, 0 regressions).
Add this agentic workflows to your repo
To install this agentic workflow, run