Skip to content

Add UInt24 readonly struct with .NET 10 generic math interfaces#2

Closed
Copilot wants to merge 7 commits into
mainfrom
copilot/add-uint24-struct
Closed

Add UInt24 readonly struct with .NET 10 generic math interfaces#2
Copilot wants to merge 7 commits into
mainfrom
copilot/add-uint24-struct

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

  • Create UInt24 readonly struct with generic math interfaces
  • Update all extension methods to use UInt24 type
  • Update all existing tests to use the new type
  • Create UInt24Tests.cs with 218 comprehensive tests
  • Add descriptive messages with actual values to all OverflowException throws
  • Build and run all tests (812 total, 0 failures)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 20, 2026 18:13
Implements IBinaryInteger<UInt24>, IMinMaxValue<UInt24>, and
IUnsignedNumber<UInt24> with all required sub-interfaces including
arithmetic, comparison, bitwise, shift, parsing, formatting, and
conversion operators.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cast int literals to UInt24 in SetUInt24/WriteUInt24/AddUInt24 calls.
Cast UInt24 results to int before Should().Equal() assertions.
Fix overflow value 0x78654321 to valid UInt24 value 0x654321.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover constants, equality, comparison, arithmetic (checked/unchecked),
bitwise/shift operators, conversion operators, formatting, parsing,
INumber, IBinaryNumber, IBinaryInteger, and INumberBase methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add UInt24 readonly struct with arithmetic operations Add UInt24 readonly struct with .NET 10 generic math interfaces Feb 20, 2026
Copilot AI requested a review from MrKWatkins February 20, 2026 18:34
var result = left._value + right._value;
if (result > MaxValueUInt32)
{
throw new OverflowException();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you give useful messages every time you throw an OverflowException please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added descriptive messages to all 11 OverflowException throws — arithmetic operators get specific messages like "UInt24 addition overflowed.", and conversion/construction paths get "Value was either too large or too small for a UInt24.". Done in cac4c14.

Copy link
Copy Markdown
Owner

@MrKWatkins MrKWatkins Feb 21, 2026

Choose a reason for hiding this comment

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

Can you add even more descriptive messages? E.g. include something like 16000000 + 2000000 = 18000000 which overflowed the maximum value of 16777216. @copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated all 11 OverflowException messages to include the actual operand values and results. For example:

  • Addition: "16000000 + 2000000 = 18000000 which exceeds the maximum UInt24 value of 16777215."
  • Subtraction: "5 - 10 would result in a negative value which is outside the range of a UInt24."
  • Conversions: "The value 20000000 is outside the range of a UInt24 (0 to 16777215)."

Done in cd627ae.

Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Copilot AI requested a review from MrKWatkins February 20, 2026 20:01
@MrKWatkins MrKWatkins marked this pull request as ready for review February 21, 2026 00:11
Copy link
Copy Markdown
Owner

@MrKWatkins MrKWatkins left a comment

Choose a reason for hiding this comment

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

Can you add even more descriptive overlflow messages? E.g. include something like 16000000 + 2000000 = 18000000 which overflowed the maximum value of 16777216.

Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 21, 2026

Can you add even more descriptive overlflow messages? E.g. include something like 16000000 + 2000000 = 18000000 which overflowed the maximum value of 16777216.

Done in cd627ae — all overflow messages now include the actual values involved in the operation.

Copilot AI requested a review from MrKWatkins February 21, 2026 00:17
@MrKWatkins MrKWatkins closed this Feb 21, 2026
@MrKWatkins MrKWatkins deleted the copilot/add-uint24-struct branch February 21, 2026 20:18
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