-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove incorrect ExceptionArgument.length
for ArgumentOutOfRangeException
in MemoryMarshal
#105475
Remove incorrect ExceptionArgument.length
for ArgumentOutOfRangeException
in MemoryMarshal
#105475
Conversation
…ception` in `MemoryMarshal` Arguably an `ArgumentException` should be thrown in these case, not `ArgumentOutOfRangeException`, but it would be a breaking change to change this.
Tagging subscribers to this area: @dotnet/interop-contrib |
While I know it's not perfect, I prefer it the way it is: the caller is told that the length is the problem. In an ideal world, maybe it would be span.Length, but I'd rather just leave things as they are. |
In the case of The documentation for ArgumentOutOfRangeException states: "The exception that is thrown when the value of an argument is outside the allowable range of values as defined by the invoked method." In this case it is the property of the argument that is out of range. Perhaps the documentation should be updated? |
What else would the "length" be other than "source.Length"? |
I mean what else would the |
It tells you what's wrong with it. The length is wrong. |
I tend to agree. I don't think this clarifies all that much and since it is a breaking change I don't think it is appropriate. |
I hadn't considered that changing the But the |
The actual name of the argument is
source
orspan
therefore this is incorrect.Arguably an
ArgumentException
should be thrown in these case, notArgumentOutOfRangeException
, but it would be a breaking change to change this.Just remove the
ExceptionArgument
like inSpan.Slice
.Relatively large diff improvements as a result:
-34 (-15.32 % of base) - System.IO.Hashing.XxHash32+State:Complete(int,System.ReadOnlySpan`1[ubyte]):uint:this
MihuBot/runtime-utils#557