-
Notifications
You must be signed in to change notification settings - Fork 236
Add System.Numerics Interfaces to Vector wrappers #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 adds System.Numerics interfaces to vector wrapper types (Vector2, Vector3, Vector4, Vector2Int, Vector3Int) to enable generic math operations. The changes make these types compatible with .NET's generic math interfaces introduced in recent .NET versions.
Changes:
- Added System.Numerics operator interfaces (
IAdditionOperators,IMultiplyOperators, etc.) to all vector types - Added identity interfaces (
IAdditiveIdentity,IMultiplicativeIdentity) with implementations - Removed
inmodifiers from operator parameters to maintain interface compatibility - Reorganized code in Vector4.cs to match the structure of Vector2/Vector3
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Vector4.cs | Added numerics interfaces, removed duplicate operators, reorganized indexer/region placement |
| Vector3.cs | Added numerics interfaces, removed in modifier from division operator |
| Vector2.cs | Added numerics interfaces and identity properties |
| Vector3Int.cs | Added comprehensive numerics interfaces including cross-type operations |
| Vector2Int.cs | Added comprehensive numerics interfaces, reordered operators, added missing operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
What the fuck These don't seem to be on System.Numerics.Vectors? |
|
Removing the Also would like to see an actual use case where this is needed. |
Yeah, it is very much a breaking change, at least I am hopeful that ppl don't just throw
I am updating my nodes |
|
@lolleko , tl;dr, it's either interfaces, op_?'s in the TypeLibrary or LINQ expressions |
|
If there are any other alternatives I would really like to know |
Fixes: #908
TL;DR: Adds
I?Operatorsinterfaces to vector types, so that you can do math on them as generics:Also added
IAdditiveIdentityandIMultiplicativeIdentitywhile I am at itAs boonoos - cleaned up some minor stuff:
#regiondirective inVector4to matchVector2andVector3ins from operator arguments (incompatible with interfaces, (if there was a reason to pass vector3s by reference instead of by value - tell me)