You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[API Proposal]: VectorXXX types, ISpanFormattable, and other interfaces (debugging QoL mostly) #121100
There was an issue back in the 3.0 days about IFormattable and VectorXXX types, and ultimately we did get an IFormattable implementation for Vector<T>, which is helpful for sure and is a lot nicer than having to step through the debugger on large datasets.
However, it looks like maybe the work to implement that got abandoned at some point and not carried through to the other VectorXXX types - only Vector.
It sure is handy, especially, for debugging purposes to be able to dump a bunch of hex representations of your vectors using the same syntax as any other numeric scalar type. But Vector(64|128|256|512)<T> don't implement IFormattable or any others.
Interestingly, the ISimdVector<TSelf, T> type (which is internal) that they all implement has this to say about it.
So it looks like the ISpanFormattable and IUtf8SpanFormattable interfaces (and a few others) have been commented out since that type was added 2 years ago, here.
Any chance an implementation of the commented-out interfaces, at least on the VectorXXX types themselves (especially for formatting), might sneak their way into .net10? 🥺
Also, that ISimdVector seems like an interface that might be reasonable to promote to public, perhaps? Could be handy for type parameter constraints in user code. 🤷♂️
Vector256<long>longVector=Vector256.Create(0x5555555555555555L);Console.WriteLine($"{longVector:X16}");// <---- Currently just prints the decimal value. Want format string to be respected.
Alternative Designs
None, really. IFormattable is an old interface.
But I suppose an option is to uncomment the other interfaces on ISimdVector to declare it for all implementing types. That might be riskier though, for other runtimes, perhaps?
Risks
None that I can immediately think of, unless the ISimdVector interface were made public before doing this. But I'm not sure, personally, what sorts of breakage of user code might be possible due to alterations to an interface that is currently non-public. 🤔
It sure is handy, especially, for debugging purposes to be able to dump a bunch of hex representations of your vectors using the same syntax as any other numeric scalar type.
You can easily implement your extension method by iterating through the elements. You just need to create an generic overload for each vector length.
Interestingly, the ISimdVector<TSelf, T> type (which is internal) that they all implement has this to say about it.
It's just a rough plan about what might be implemented.
Any chance an implementation of the commented-out interfaces, at least on the VectorXXX types themselves (especially for formatting), might sneak their way into .net10?
Never. .NET 10 has reached feature freeze 2 months ago.
Also, that ISimdVector seems like an interface that might be reasonable to promote to public, perhaps?
You can easily implement your extension method by iterating through the elements. You just need to create an generic overload for each vector length.
Yep, certainly. And that's part of my boilerplate code in projects where these are in use. It's available on Vector<T>, so it seems only natural for the same facility to exist on the rest of them. 🤷♂️
It's just a rough plan about what might be implemented.
Gotcha. Well, here's my upvote on them. 😊
Never. .NET 10 has reached feature freeze 2 months ago.
I was just scanning through some vectorized code and my oh my ISimdVector being public would come in handy to address the "all-but-lenght" cases. The referenced PR is 3 years old. It worries me that it might not be pushed.
I was just scanning through some vectorized code and my oh my ISimdVector being public would come in handy to address the "all-but-lenght" cases. The referenced PR is 3 years old. It worries me that it might not be pushed.
Yeah there's some delicious stuff in there, for sure. I suppose you could always just grab the code and include the necessary license if you want to use parts of it in your application. Could even use extension everything in C#14 to make it feel more natural, too, probably. 🤔
Activity
huoyaoyuan commentedon Oct 26, 2025
You can easily implement your extension method by iterating through the elements. You just need to create an generic overload for each vector length.
It's just a rough plan about what might be implemented.
Never. .NET 10 has reached feature freeze 2 months ago.
#76244. It's still early WIP.
They are only in implementation, not the exposed API reference. They are not ready for public usage.
dodexahedron commentedon Oct 27, 2025
Yep, certainly. And that's part of my boilerplate code in projects where these are in use. It's available on
Vector<T>, so it seems only natural for the same facility to exist on the rest of them. 🤷♂️Gotcha. Well, here's my upvote on them. 😊
Bummer. Oh well. 🫠
Thanks for that reference!
That tracks from the above as well.
Feel free to close in favor of #76244 or otherwise, as desired, if this fits under that scope, I suppose.
Scooletz commentedon Dec 18, 2025
I was just scanning through some vectorized code and my oh my
ISimdVectorbeing public would come in handy to address the "all-but-lenght" cases. The referenced PR is 3 years old. It worries me that it might not be pushed.dodexahedron commentedon Dec 19, 2025
Yeah there's some delicious stuff in there, for sure. I suppose you could always just grab the code and include the necessary license if you want to use parts of it in your application. Could even use extension everything in C#14 to make it feel more natural, too, probably. 🤔